ProcessVideo() private method

private ProcessVideo ( Action process ) : void
process Action
return void
        void Process(Transcoder transcoder, bool highlights, Action<long, long> monitorProgress, Func<bool> isAborted)
        {
            try
            {
                TraceInfo.WriteLineIf(highlights, "Transcoding highlights to {0}", transcoder.DestinationFile);
                TraceInfo.WriteLineIf(!highlights, "Transcoding full replay to {0}", transcoder.DestinationFile);

                transcoder.ProcessVideo((readers, saveToSink) =>
                {
                    var writeToSink = monitorProgress == null ? saveToSink : MonitorProgress(saveToSink);

                    var fadeSegments = AVOperations.FadeIn(AVOperations.FadeOut(writeToSink));
                    var edits = highlights ? ApplyEdits(writeToSink) : writeToSink;
                    var mainBodyOverlays = AVOperations.Overlay(applyRaceDataOverlay, edits);
                    var introOverlay = AVOperations.Overlay(applyIntroOverlay, fadeSegments);

                    var sourceReaderExtra = readers.FirstOrDefault(r => ((CapturedVideoFile)r.State).isIntroVideo);
                    if (sourceReaderExtra != null)
                    {
                        var introSourceReader = sourceReaderExtra.SourceReader;
                        var mainReaders = AVOperations.Combine(readers.Skip(1).Select(r => r.SourceReader).ToArray(), Settings.Default.VideoSplitGap);

                        totalDuration += introSourceReader.Duration + mainReaders.Duration;
                        
                        AVOperations.StartConcat(introSourceReader, introOverlay,
                            AVOperations.Concat(mainReaders, mainBodyOverlays, isAborted), isAborted);
                    }
                    else
                    {
                        var mainReaders = AVOperations.Combine(readers.Select(r => r.SourceReader).ToArray(), Settings.Default.VideoSplitGap);

                        totalDuration += mainReaders.Duration;

                        AVOperations.Concat(mainReaders, mainBodyOverlays, isAborted)(0, 0);
                    }
                });
                
                TraceInfo.WriteLineIf(highlights, "Done Transcoding highlights to {0}", transcoder.DestinationFile);
                TraceInfo.WriteLineIf(!highlights, "Done Transcoding full replay to {0}", transcoder.DestinationFile);
            }
            catch (Exception e)
            {
                TraceError.WriteLine(e.Message);
                TraceError.WriteLine(e.StackTrace);
                throw e;
            }
        }
        void TranscodeVideoTest(string filename)
        {
            using (MFSystem.Start())
            {
                var transcoder = new Transcoder
                {
                    VideoFiles = new[] { new SourceReaderExtra(filename, null) },
                    DestinationFile = Path.ChangeExtension(filename, "wmv"),
                    VideoBitRate = 5000000,
                    AudioBitRate = 48000/8
                };

                TraceInfo.WriteLine("Begining video re-encoding.");

                transcoder.ProcessVideo((readers, saveToSink) =>
                {
                    int lastSecond = 0;
                    var fn = AVOperations.FadeIn(saveToSink);

                    readers.First().SourceReader.Samples(sample => {
                        if (sample.Stream.CurrentMediaType.IsVideo && sample.Sample != null)
                        {
                            var s = (int)sample.Sample.SampleTime.FromNanoToSeconds();
                            if (s != lastSecond)
                                TraceInfo.WriteLine("Converted: {0} seconds", s);
                            lastSecond = s;
                        }

                        return fn(sample);

                    });
                });

                TraceInfo.WriteLine("Video converted.  Review the video file {0} to confirm it looks OK.", transcoder.DestinationFile);
                TraceInfo.WriteLine("Success!");
            }
        }
        void TranscodeVideoTest(string filename)
        {
            using (MFSystem.Start())
            {
                var transcoder = new Transcoder
                {
                    VideoFiles = new [] { new SourceReaderExtra(filename, null)},
                    DestinationFile = Path.ChangeExtension(filename, "wmv"),
                    VideoBitRate = 5000000,
                    AudioBitRate = 48000/8
                };

                TraceInfo.WriteLine("Begining video re-encoding.");

                transcoder.ProcessVideo((readers, saveToSink) =>
                {
                    readers.First().SourceReader.Samples(AVOperations.FadeIn(saveToSink));
                });

                TraceInfo.WriteLine("Video converted.  Review the video file {0} to confirm it looks OK.", transcoder.DestinationFile);
                TraceInfo.WriteLine("Success!");
            }
        }