public static async Task <int> Execute(Arguments arguments) { if (arguments == null) { throw new NoDeveloperMethodException(); } var sw = new Stopwatch(); sw.Start(); ISourcePreparer sourcePreparer = new LocalSourcePreparer(filterShortSegments: true, useOldNamingFormat: false); //create analysis settings using arguments AnalysisSettings settings = new AnalysisSettings() { AnalysisMaxSegmentDuration = TimeSpan.FromSeconds(arguments.SegmentDuration), SegmentMediaType = MediaTypes.GetMediaType(arguments.SegmentFileExtension), AnalysisMinSegmentDuration = TimeSpan.FromSeconds(arguments.SegmentDurationMinimum), SegmentOverlapDuration = TimeSpan.FromSeconds(arguments.SegmentOverlap), AnalysisTargetSampleRate = arguments.SampleRate, AnalysisTempDirectory = (arguments.TemporaryFilesDir ?? arguments.OutputDir).ToDirectoryInfo(), }; // create segments from file var fileSegment = new FileSegment(arguments.InputFile.ToFileInfo(), TimeAlignment.None, dateBehavior: FileSegment.FileDateBehavior.None) { SegmentStartOffset = TimeSpan.FromSeconds(arguments.StartOffset), }; if (arguments.EndOffset.HasValue) { fileSegment.SegmentEndOffset = TimeSpan.FromSeconds(arguments.EndOffset.Value); } var fileSegments = sourcePreparer.CalculateSegments(new[] { fileSegment }, settings).ToList(); LoggedConsole.WriteLine( "Started segmenting at {0} {1}: {2}.", DateTime.Now, arguments.Parallel ? "in parallel" : "sequentially", arguments.InputFile); if (arguments.Parallel) { RunParallel(fileSegments, sourcePreparer, settings, arguments); } else { var runTime = await RunSequential(fileSegments, sourcePreparer, settings, arguments); } sw.Stop(); LoggedConsole.WriteLine("Took {0}. Done.", sw.Elapsed); return(ExceptionLookup.Ok); }
public void Initialize() { this.testDirectory = PathHelper.GetTempDir(); this.preparer = new LocalSourcePreparer(); this.settings = new AnalysisSettings(); }