本文整理汇总了C#中IProgress.WriteVerbose方法的典型用法代码示例。如果您正苦于以下问题:C# IProgress.WriteVerbose方法的具体用法?C# IProgress.WriteVerbose怎么用?C# IProgress.WriteVerbose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgress
的用法示例。
在下文中一共展示了IProgress.WriteVerbose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteNestedDomainData
internal static void WriteNestedDomainData(IProgress progress, bool writeVerbose, string rootDir,
IDictionary<string, XElement> wellUsedElements,
IDictionary<string, SortedDictionary<string, byte[]>> classData,
Dictionary<string, string> guidToClassMapping)
{
var generalBaseDir = Path.Combine(rootDir, SharedConstants.General);
if (!Directory.Exists(generalBaseDir))
Directory.CreateDirectory(generalBaseDir);
FLExProjectSplitter.CheckForUserCancelRequested(progress);
if (writeVerbose)
{
progress.WriteVerbose("Writing the general data....");
progress.WriteVerbose("Writing user-defined list data....");
}
else
{
progress.WriteMessage("Writing the general data....");
progress.WriteMessage("Writing user-defined list data....");
}
UserDefinedListsBoundedContextService.NestContext(generalBaseDir, wellUsedElements, classData, guidToClassMapping);
FLExProjectSplitter.CheckForUserCancelRequested(progress);
if (writeVerbose)
progress.WriteVerbose("Writing language project data....");
else
progress.WriteMessage("Writing language project data....");
GeneralDomainBoundedContext.NestContext(generalBaseDir, wellUsedElements, classData, guidToClassMapping);
}
示例2: FlattenDomain
internal static void FlattenDomain(IProgress progress, bool writeVerbose, SortedDictionary<string, XElement> highLevelData, SortedDictionary<string, XElement> sortedData, string rootDir)
{
var generalBaseDir = Path.Combine(rootDir, SharedConstants.General);
if (!Directory.Exists(generalBaseDir))
return;
// Do in reverse order from nesting.
if (writeVerbose)
{
progress.WriteVerbose("Collecting the general data....");
progress.WriteVerbose("Collecting the language project data....");
}
else
{
progress.WriteMessage("Collecting the general data....");
progress.WriteMessage("Collecting the language project data....");
}
GeneralDomainBoundedContext.FlattenContext(highLevelData, sortedData, generalBaseDir);
if (writeVerbose)
progress.WriteVerbose("Collecting the user-defined list data....");
else
progress.WriteMessage("Collecting the user-defined list data....");
UserDefinedListsBoundedContextService.FlattenContext(highLevelData, sortedData, generalBaseDir);
}
示例3: PutHumptyTogetherAgain
internal static void PutHumptyTogetherAgain(IProgress progress, bool writeVerbose, string mainFilePathname)
{
Guard.AgainstNull(progress, "progress");
FileWriterService.CheckPathname(mainFilePathname);
using (var tempFile = new TempFile())
{
using (var writer = XmlWriter.Create(tempFile.Path, new XmlWriterSettings // NB: These are the FW bundle of settings, not the canonical settings.
{
OmitXmlDeclaration = false,
CheckCharacters = true,
ConformanceLevel = ConformanceLevel.Document,
Encoding = new UTF8Encoding(false),
Indent = true,
IndentChars = (""),
NewLineOnAttributes = false
}))
{
var pathRoot = Path.GetDirectoryName(mainFilePathname);
// NB: The method calls are strictly ordered.
// Don't even think of changing them.
if (writeVerbose)
progress.WriteVerbose("Processing data model version number....");
else
progress.WriteMessage("Processing data model version number....");
UpgradeToVersion(writer, pathRoot);
if (writeVerbose)
progress.WriteVerbose("Processing custom properties....");
else
progress.WriteMessage("Processing custom properties....");
WriteOptionalCustomProperties(writer, pathRoot);
var sortedData = BaseDomainServices.PutHumptyTogetherAgain(progress, writeVerbose, pathRoot);
if (writeVerbose)
progress.WriteVerbose("Writing temporary fwdata file....");
else
progress.WriteMessage("Writing temporary fwdata file....");
foreach (var rtElement in sortedData.Values)
FileWriterService.WriteElement(writer, rtElement);
writer.WriteEndElement();
}
//Thread.Sleep(2000); In case it blows (access denied) up again on Sue's computer.
if (writeVerbose)
progress.WriteVerbose("Copying temporary fwdata file to main file....");
else
progress.WriteMessage("Copying temporary fwdata file to main file....");
File.Copy(tempFile.Path, mainFilePathname, true);
}
SplitFileAgainIfNeeded(progress, writeVerbose, mainFilePathname);
}
示例4: FlattenDomain
internal static void FlattenDomain(
IProgress progress, bool writeVerbose,
SortedDictionary<string, XElement> highLevelData,
SortedDictionary<string, XElement> sortedData,
string rootDir)
{
var scriptureBaseDir = Path.Combine(rootDir, SharedConstants.Other);
if (!Directory.Exists(scriptureBaseDir))
return;
if (writeVerbose)
progress.WriteVerbose("Collecting the other data....");
else
progress.WriteMessage("Collecting the other data....");
ScriptureReferenceSystemBoundedContextService.FlattenContext(highLevelData, sortedData, scriptureBaseDir);
ScriptureCheckListsBoundedContextService.FlattenContext(highLevelData, sortedData, scriptureBaseDir);
// Have to flatten the main Scripture context before the rest, since the main context owns the other four.
// The main obj gets stuffed into highLevelData, so the owned stuff can have owner guid restored.
ScriptureBoundedContextService.FlattenContext(highLevelData, sortedData, scriptureBaseDir);
if (highLevelData.ContainsKey(SharedConstants.Scripture))
{
ArchivedDraftsBoundedContextService.FlattenContext(highLevelData, sortedData, scriptureBaseDir);
ScriptureStylesBoundedContextService.FlattenContext(highLevelData, sortedData, scriptureBaseDir);
ImportSettingsBoundedContextService.FlattenContext(highLevelData, sortedData, scriptureBaseDir);
}
}
示例5: WriteNestedDomainData
internal static void WriteNestedDomainData(IProgress progress, bool writeVerbose, string rootDir,
IDictionary<string, XElement> wellUsedElements,
IDictionary<string, SortedDictionary<string, byte[]>> classData,
Dictionary<string, string> guidToClassMapping)
{
/*
BC 1. ScrRefSystem (no owner)
Books prop owns seq of ScrBookRef (which has all basic props).
No other props.
[Put all in one file in a subfolder of Scripture?]
[[Nesting]]
BC 2. CheckLists prop on LP that holds col of CmPossibilityList items.
Each CmPossibilityList will hold ChkTerm (called ChkItem in model file) objects (derived from CmPossibility)
[Store each list in a file. Put all lists in subfolder.]
[[Nesting]]
BC 3. Scripture (owned by LP)
Leave in:
Resources prop owns col of CmResource. [Leave.]
Extract:
BC 4. ArchivedDrafts prop owns col of ScrDraft. [Each ScrDraft goes in its own file. Archived stuff goes into subfolder of Scripture.]
BC 5. Styles props owns col of StStyle. [Put styles in subfolder and one for each style.]
BC 6. ImportSettings prop owns col of ScrImportSet. [Put sets in subfolder and one for each set.]
BC 7. NoteCategories prop owns one CmPossibilityList [Put list in its own file.]
BC 8. ScriptureBooks prop owns seq of ScrBook. [Put each book in its own folder (named for its cononical order number).]
BC 9. BookAnnotations prop owns seq of ScrBookAnnotations. [Put each ScrBookAnnotations in corresponding subfolder along with optional book.]
*/
var scriptureBaseDir = Path.Combine(rootDir, SharedConstants.Other);
if (!Directory.Exists(scriptureBaseDir))
Directory.CreateDirectory(scriptureBaseDir);
FLExProjectSplitter.CheckForUserCancelRequested(progress);
if (writeVerbose)
progress.WriteVerbose("Writing the other data....");
else
progress.WriteMessage("Writing the other data....");
ScriptureReferenceSystemBoundedContextService.NestContext(scriptureBaseDir, classData, guidToClassMapping);
var langProj = wellUsedElements[SharedConstants.LangProject];
FLExProjectSplitter.CheckForUserCancelRequested(progress);
ScriptureCheckListsBoundedContextService.NestContext(langProj, scriptureBaseDir, classData, guidToClassMapping);
// These are intentionally out of order from the above numbering scheme.
var scrAsBytes = classData[SharedConstants.Scripture].Values.FirstOrDefault();
// // Lela Teli-3 has null.
if (scrAsBytes != null)
{
var scripture = Utilities.CreateFromBytes(scrAsBytes);
FLExProjectSplitter.CheckForUserCancelRequested(progress);
ArchivedDraftsBoundedContextService.NestContext(scripture.Element(SharedConstants.ArchivedDrafts), scriptureBaseDir, classData, guidToClassMapping);
FLExProjectSplitter.CheckForUserCancelRequested(progress);
ScriptureStylesBoundedContextService.NestContext(scripture.Element(SharedConstants.Styles), scriptureBaseDir, classData, guidToClassMapping);
FLExProjectSplitter.CheckForUserCancelRequested(progress);
ImportSettingsBoundedContextService.NestContext(scripture.Element(SharedConstants.ImportSettings), scriptureBaseDir, classData, guidToClassMapping);
FLExProjectSplitter.CheckForUserCancelRequested(progress);
ScriptureBoundedContextService.NestContext(langProj, scripture, scriptureBaseDir, classData, guidToClassMapping);
}
RemoveFolderIfEmpty(scriptureBaseDir);
}
示例6: FlattenDomain
internal static void FlattenDomain(IProgress progress, bool writeVerbose,
SortedDictionary<string, XElement> highLevelData,
SortedDictionary<string, XElement> sortedData,
string rootDir)
{
var linguisticsBaseDir = Path.Combine(rootDir, SharedConstants.Linguistics);
if (!Directory.Exists(linguisticsBaseDir))
return;
// Do in reverse order from nesting.
if (writeVerbose)
{
progress.WriteVerbose("Collecting the linguistics data....");
progress.WriteVerbose("Collecting the phonology data....");
}
else
{
progress.WriteMessage("Collecting the linguistics data....");
progress.WriteMessage("Collecting the phonology data....");
}
PhonologyBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);
if (writeVerbose)
progress.WriteVerbose("Collecting the discourse data....");
else
progress.WriteMessage("Collecting the discourse data....");
DiscourseAnalysisBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);
if (writeVerbose)
progress.WriteVerbose("Collecting the wordform and punctuation data....");
else
progress.WriteMessage("Collecting the wordform and punctuation data....");
WordformInventoryBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);
if (writeVerbose)
progress.WriteVerbose("Collecting the text corpus data....");
else
progress.WriteMessage("Collecting the text corpus data....");
TextCorpusBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);
// MorphologyAndSyntaxBoundedContextService and ReversalBoundedContextService, both *must* have LexiconBoundedContextService done before them,
// since they re-add stuff to LexDb that they removed
if (writeVerbose)
progress.WriteVerbose("Collecting the lexical data....");
else
progress.WriteMessage("Collecting the lexical data....");
LexiconBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);
if (writeVerbose)
progress.WriteVerbose("Collecting the morphology and syntax data....");
else
progress.WriteMessage("Collecting the morphology and syntax data....");
MorphologyAndSyntaxBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);
if (writeVerbose)
progress.WriteVerbose("Collecting the reversal data....");
else
progress.WriteMessage("Collecting the reversal data....");
ReversalBoundedContextService.FlattenContext(highLevelData, sortedData, linguisticsBaseDir);
}
示例7: WriteNestedDomainData
internal static void WriteNestedDomainData(IProgress progress, bool writeVerbose, string rootDir,
IDictionary<string, XElement> wellUsedElements,
IDictionary<string, SortedDictionary<string, byte[]>> classData,
Dictionary<string, string> guidToClassMapping)
{
var anthropologyBaseDir = Path.Combine(rootDir, SharedConstants.Anthropology);
if (!Directory.Exists(anthropologyBaseDir))
Directory.CreateDirectory(anthropologyBaseDir);
FLExProjectSplitter.CheckForUserCancelRequested(progress);
if (writeVerbose)
progress.WriteVerbose("Writing the anthropology data....");
else
progress.WriteMessage("Writing the anthropology data....");
AnthropologyBoundedContextService.NestContext(anthropologyBaseDir, wellUsedElements, classData, guidToClassMapping);
}
示例8: FlattenDomain
internal static void FlattenDomain(
IProgress progress, bool writeVerbose,
SortedDictionary<string, XElement> highLevelData,
SortedDictionary<string, XElement> sortedData,
string pathRoot)
{
var anthropologyBaseDir = Path.Combine(pathRoot, SharedConstants.Anthropology);
if (!Directory.Exists(anthropologyBaseDir))
return; // Nothing to do.
if (writeVerbose)
progress.WriteVerbose("Collecting the anthropology data....");
else
progress.WriteMessage("Collecting the anthropology data....");
AnthropologyBoundedContextService.FlattenContext(highLevelData, sortedData, anthropologyBaseDir);
}
示例9: UploadBook
public static string UploadBook(string bucketName, string bookZipPath, IProgress progress)
{
try
{
using(var s3Client = new BloomS3Client(bucketName))
{
var url = s3Client.UploadSingleFile(bookZipPath, progress);
progress.WriteMessage("Upload Success");
return url;
}
}
catch (WebException e)
{
progress.WriteError("There was a problem uploading your book: "+e.Message);
throw;
}
catch (AmazonS3Exception e)
{
if (e.Message.Contains("The difference between the request time and the current time is too large"))
{
progress.WriteError(LocalizationManager.GetString("PublishTab.Upload.TimeProblem",
"There was a problem uploading your book. This is probably because your computer is set to use the wrong timezone or your system time is badly wrong. See http://www.di-mgt.com.au/wclock/help/wclo_setsysclock.html for how to fix this."));
}
else
{
progress.WriteError("There was a problem uploading your book: " + e.Message);
}
throw;
}
catch (AmazonServiceException e)
{
progress.WriteError("There was a problem uploading your book: " + e.Message);
throw;
}
catch (Exception e)
{
progress.WriteError("There was a problem uploading your book.");
progress.WriteError(e.Message.Replace("{", "{{").Replace("}", "}}"));
progress.WriteVerbose(e.StackTrace);
throw;
}
}
示例10: UploadBook
//.........这里部分代码省略.........
}
// And similarly it should have SOME title.
if (string.IsNullOrEmpty(metadata.Title))
{
metadata.Title = Path.GetFileNameWithoutExtension(bookFolder);
}
metadata.SetUploader(UserId);
s3BookId = S3BookId(metadata);
metadata.DownloadSource = s3BookId;
// Any updated ID at least needs to become a permanent part of the book.
// The file uploaded must also contain the correct DownloadSource data, so that it can be used
// as an 'order' to download the book.
// It simplifies unit testing if the metadata file is also updated with the uploadedBy value.
// Not sure if there is any other reason to do it (or not do it).
// For example, do we want to send/receive who is the latest person to upload?
metadata.WriteToFolder(bookFolder);
// The metadata is also a book order...but we need it on the server with the desired file name,
// because we can't rename on download. The extension must be the one Bloom knows about,
// and we want the file name to indicate which book, so use the name of the book folder.
var metadataPath = BookMetaData.MetaDataPath(bookFolder);
var orderPath = Path.Combine(bookFolder, Path.GetFileName(bookFolder) + BookOrderExtension);
RobustFile.Copy(metadataPath, orderPath, true);
parseId = "";
try
{
_s3Client.UploadBook(s3BookId, bookFolder, progress, pdfToInclude: pdfToInclude);
metadata.BaseUrl = _s3Client.BaseUrl;
metadata.BookOrder = _s3Client.BookOrderUrlOfRecentUpload;
progress.WriteStatus(LocalizationManager.GetString("PublishTab.Upload.UploadingBookMetadata", "Uploading book metadata", "In this step, Bloom is uploading things like title, languages, and topic tags to the BloomLibrary.org database."));
// Do this after uploading the books, since the ThumbnailUrl is generated in the course of the upload.
var response = _parseClient.SetBookRecord(metadata.WebDataJson);
parseId = response.ResponseUri.LocalPath;
int index = parseId.LastIndexOf('/');
parseId = parseId.Substring(index + 1);
if (parseId == "books")
{
// For NEW books the response URL is useless...need to do a new query to get the ID.
var json = _parseClient.GetSingleBookRecord(metadata.Id);
parseId = json.objectId.Value;
}
// if (!UseSandbox) // don't make it seem like there are more uploads than their really are if this a tester pushing to the sandbox
{
Analytics.Track("UploadBook-Success", new Dictionary<string, string>() { { "url", metadata.BookOrder }, { "title", metadata.Title } });
}
}
catch (WebException e)
{
DisplayNetworkUploadProblem(e, progress);
if (!UseSandbox) // don't make it seem like there are more upload failures than their really are if this a tester pushing to the sandbox
Analytics.Track("UploadBook-Failure", new Dictionary<string, string>() { { "url", metadata.BookOrder }, { "title", metadata.Title }, { "error", e.Message } });
return "";
}
catch (AmazonS3Exception e)
{
if (e.Message.Contains("The difference between the request time and the current time is too large"))
{
progress.WriteError(LocalizationManager.GetString("PublishTab.Upload.TimeProblem",
"There was a problem uploading your book. This is probably because your computer is set to use the wrong timezone or your system time is badly wrong. See http://www.di-mgt.com.au/wclock/help/wclo_setsysclock.html for how to fix this."));
if (!UseSandbox)
Analytics.Track("UploadBook-Failure-SystemTime");
}
else
{
DisplayNetworkUploadProblem(e, progress);
if (!UseSandbox)
// don't make it seem like there are more upload failures than their really are if this a tester pushing to the sandbox
Analytics.Track("UploadBook-Failure",
new Dictionary<string, string>() { { "url", metadata.BookOrder }, { "title", metadata.Title }, { "error", e.Message } });
}
return "";
}
catch (AmazonServiceException e)
{
DisplayNetworkUploadProblem(e, progress);
if (!UseSandbox) // don't make it seem like there are more upload failures than their really are if this a tester pushing to the sandbox
Analytics.Track("UploadBook-Failure", new Dictionary<string, string>() { { "url", metadata.BookOrder }, { "title", metadata.Title }, { "error", e.Message } });
return "";
}
catch (Exception e)
{
progress.WriteError(LocalizationManager.GetString("PublishTab.Upload.UploadProblemNotice",
"There was a problem uploading your book. You may need to restart Bloom or get technical help."));
progress.WriteError(e.Message.Replace("{", "{{").Replace("}", "}}"));
progress.WriteVerbose(e.StackTrace);
if (!UseSandbox) // don't make it seem like there are more upload failures than their really are if this a tester pushing to the sandbox
Analytics.Track("UploadBook-Failure", new Dictionary<string, string>() {{"url", metadata.BookOrder}, {"title", metadata.Title}, {"error", e.Message}});
return "";
}
}
finally
{
if (domForLocking != null && allowLocking && !wasLocked)
{
Book.Book.RecordAsLockedDown(domForLocking, false);
XmlHtmlConverter.SaveDOMAsHtml5(domForLocking.RawDom, htmlFile);
}
}
return s3BookId;
}
示例11: DoNotifications
public void DoNotifications(HgRepository repository, IProgress progress)
{
if(progress.CancelRequested)
{
progress.WriteWarning("Cancelled.");
return;
}
if (InnerException != null)
{
progress.WriteVerbose("inner exception:");
progress.WriteError(Message);
}
progress.WriteError(Message);
progress.WriteVerbose(StackTrace);
if ((WhatToDo & WhatToDo.CheckAddressAndConnection) > 0)
{
//todo: seems we could do some of this ourselves, like pinging the destination
progress.WriteError("Check your network connection and server address, or try again later.");
}
if ((WhatToDo & WhatToDo.CheckSettings) > 0)
{
progress.WriteError("Check your server settings, such as project name, user name, and password.");
}
if ((WhatToDo & WhatToDo.VerifyIntegrity) > 0)
{
if (HgRepository.IntegrityResults.Bad == repository.CheckIntegrity(progress))
{
throw new ApplicationException(
"Bad news: The mecurial repository is damaged. You will need to seek expert help to resolve this problem."
);
// Removing windows forms dependency CP 2012-08
//MessageBox.Show(
// "Bad news: The mecurial repository is damaged. You will need to seek expert help to resolve this problem.", "Chorus", MessageBoxButtons.OK, MessageBoxIcon.Error);
//return;//don't suggest anything else
}
}
if ((WhatToDo & WhatToDo.SuggestRestart) > 0)
{
progress.WriteError("The problem might be helped by restarting your computer.");
}
if ((WhatToDo & WhatToDo.NeedExpertHelp) > 0)
{
progress.WriteError("You may need expert help.");
}
}
示例12: MakeLowQualitySmallPicture
/// <summary>
/// Converts to low-quality, small picture
/// </summary>
/// <returns>log of the run</returns>
public static ExecutionResult MakeLowQualitySmallPicture(string inputPath, string outputPath, IProgress progress)
{
if (string.IsNullOrEmpty(LocateAndRememberFFmpeg()))
{
return new ExecutionResult() { StandardError = "Could not locate FFMpeg" };
}
//enhance: how to lower the quality?
var arguments = "-i \"" + inputPath + "\" -f image2 -s 176x144 \"" + outputPath + "\"";
progress.WriteMessage("ffmpeg " + arguments);
var result = CommandLineProcessing.CommandLineRunner.Run(LocateAndRememberFFmpeg(),
arguments,
Environment.CurrentDirectory,
60 * 10, //10 minutes
progress
);
progress.WriteVerbose(result.StandardOutput);
if (result.StandardError.ToLower().Contains("error")) //ffmpeg always outputs config info to standarderror
progress.WriteError(result.StandardError);
return result;
}
示例13: MakeLowQualitySmallVideo
/// <summary>
/// Converts to low-quality, small video
/// </summary>
/// <param name="maxSeconds">0 if you don't want to truncate at all</param>
/// <returns>log of the run</returns>
public static ExecutionResult MakeLowQualitySmallVideo(string inputPath, string outputPath, int maxSeconds, IProgress progress)
{
if (string.IsNullOrEmpty(LocateAndRememberFFmpeg()))
{
return new ExecutionResult() { StandardError = "Could not locate FFMpeg" };
}
// isn't working: var arguments = "-i \"" + inputPath + "\" -vcodec mpeg4 -s 160x120 -b 800 -acodec libmp3lame -ar 22050 -ab 32k -ac 1 \"" + outputPath + "\"";
var arguments = "-i \"" + inputPath +
"\" -vcodec mpeg4 -s 160x120 -b 800 -acodec libmp3lame -ar 22050 -ab 32k -ac 1 ";
if (maxSeconds > 0)
arguments += " -t " + maxSeconds + " ";
arguments += "\"" + outputPath + "\"";
progress.WriteMessage("ffmpeg " + arguments);
var result = CommandLineProcessing.CommandLineRunner.Run(LocateAndRememberFFmpeg(),
arguments,
Environment.CurrentDirectory,
60 * 10, //10 minutes
progress
);
progress.WriteVerbose(result.StandardOutput);
//hide a meaningless error produced by some versions of liblame
if (result.StandardError.Contains("lame: output buffer too small")
&& File.Exists(outputPath))
{
result = new ExecutionResult
{
ExitCode = 0,
StandardOutput = result.StandardOutput,
StandardError = string.Empty
};
}
if (result.StandardError.ToLower().Contains("error") //ffmpeg always outputs config info to standarderror
|| result.StandardError.ToLower().Contains("unable to")
|| result.StandardError.ToLower().Contains("invalid")
|| result.StandardError.ToLower().Contains("could not"))
progress.WriteWarning(result.StandardError);
return result;
}
示例14: MakeLowQualityCompressedAudio
/// <summary>
/// Converts to low-quality, mono mp3
/// </summary>
/// <returns>log of the run</returns>
public static ExecutionResult MakeLowQualityCompressedAudio(string inputPath, string outputPath, IProgress progress)
{
if (string.IsNullOrEmpty(LocateAndRememberFFmpeg()))
{
return new ExecutionResult() { StandardError = "Could not locate FFMpeg" };
}
var arguments = "-i \"" + inputPath + "\" -acodec libmp3lame -ac 1 -ar 8000 \"" + outputPath + "\"";
progress.WriteMessage("ffmpeg " + arguments);
var result = CommandLineProcessing.CommandLineRunner.Run(LocateAndRememberFFmpeg(),
arguments,
Environment.CurrentDirectory,
60 * 10, //10 minutes
progress
);
progress.WriteVerbose(result.StandardOutput);
//hide a meaningless error produced by some versions of liblame
if (result.StandardError.Contains("lame: output buffer too small")
&& File.Exists(outputPath))
{
result = new ExecutionResult
{
ExitCode = 0,
StandardOutput = result.StandardOutput,
StandardError = string.Empty
};
}
if (result.StandardError.ToLower().Contains("error")
|| result.StandardError.ToLower().Contains("unable to")
|| result.StandardError.ToLower().Contains("invalid")
|| result.StandardError.ToLower().Contains("could not")
) //ffmpeg always outputs config info to standarderror
progress.WriteError(result.StandardError);
return result;
}
示例15: ChangeNumberOfAudioChannels
/// <summary>
/// Creates an audio file, using the received one as the bases, with the specified number
/// of channels. For example, this can be used to convert a 2-channel audio file to a
/// single channel audio file.
/// </summary>
/// <returns>log of the run</returns>
public static ExecutionResult ChangeNumberOfAudioChannels(string inputPath,
string outputPath, int channels, IProgress progress)
{
if (string.IsNullOrEmpty(LocateFFmpeg()))
return new ExecutionResult { StandardError = "Could not locate FFMpeg" };
var arguments = string.Format("-i \"{0}\" -vn -ac {1} \"{2}\"",
inputPath, channels, outputPath);
var result = CommandLineRunner.Run(LocateAndRememberFFmpeg(),
arguments,
Environment.CurrentDirectory,
60 * 10, //10 minutes
progress);
progress.WriteVerbose(result.StandardOutput);
//hide a meaningless error produced by some versions of liblame
if (result.StandardError.Contains("lame: output buffer too small") && File.Exists(outputPath))
{
var doctoredResult = new ExecutionResult
{
ExitCode = 0,
StandardOutput = result.StandardOutput,
StandardError = string.Empty
};
return doctoredResult;
}
// ffmpeg always outputs config info to standarderror
if (result.StandardError.ToLower().Contains("error"))
progress.WriteError(result.StandardError);
return result;
}