Beispiel #1
0
        public void Process()
        {
            using (MFSystem.Start())
            {
                var readWriteFactory = new ReadWriteClassFactory();

                var attributes = new Attributes
                {
                    ReadWriterEnableHardwareTransforms = true,
                    SourceReaderEnableVideoProcessing = true,
                };

                var destAttributes = new Attributes
                {
                    ReadWriterEnableHardwareTransforms = true,
                    SourceReaderEnableVideoProcessing = true,
                    MaxKeyFrameSpacing = 3000
                };

                var shortSourceReader = readWriteFactory.CreateSourceReaderFromURL(shortSourceFile, attributes);
                var shortSourceReader2 = readWriteFactory.CreateSourceReaderFromURL(shortSourceFile, attributes);
                var mainSourceReader = readWriteFactory.CreateSourceReaderFromURL(mainSourceFile, attributes);
                var sinkWriter = readWriteFactory.CreateSinkWriterFromURL(destinationFile, destAttributes);

                var writeToSink = ConnectStreams(shortSourceReader, shortSourceReader2, mainSourceReader, sinkWriter);

                ProcessSample progress = sample =>
                {
                    if(!sample.Flags.EndOfStream)
                        Trace.WriteLine(string.Format("sourceTime: {0}, sampleTime: {1}", sample.Timestamp.FromNanoToSeconds(), sample.SampleTime.FromNanoToSeconds()));
                    return writeToSink(sample);
                };

                var fadeSegments = AVOperations.FadeIn(AVOperations.FadeOut(progress));

                var editoutMiddle = AVOperations.Cut(9.FromSecondsToNano(), 19.FromSecondsToNano(), fadeSegments);

                var overlay = AVOperations.Overlay(applyOverlay, editoutMiddle);

                var first4Seconds = AVOperations.Cut(0.FromSecondsToNano(), 4.FromSecondsToNano(), progress, progress);

                var readers = AVOperations.Combine(new[] { shortSourceReader, mainSourceReader }, 1.1);

                using (sinkWriter.BeginWriting())
                {
                    AVOperations.StartConcat(readers, overlay,
                            AVOperations.Concat(shortSourceReader, first4Seconds, () => false), () => false);
                }
            }
        }
Beispiel #2
0
        public void Process()
        {
            using (MFSystem.Start())
            {
                var readWriteFactory = new ReadWriteClassFactory();

                var attributes = new Attributes
                {
                    ReadWriterEnableHardwareTransforms = true,
                    SourceReaderEnableVideoProcessing = true,
                };

                var destAttributes = new Attributes
                {
                    ReadWriterEnableHardwareTransforms = true,
                    SourceReaderEnableVideoProcessing = true,
                    MaxKeyFrameSpacing = 3000
                };

                var sourceReader = readWriteFactory.CreateSourceReaderFromURL(sourceFile, attributes);
                var sinkWriter = readWriteFactory.CreateSinkWriterFromURL(destinationFile, destAttributes);

                var writeToSink = ConnectStreams(sourceReader, sinkWriter);

                using (sinkWriter.BeginWriting())
                {
                    sourceReader.Samples(sample =>
                        {
                            Console.Clear();
                            Console.WriteLine(TimeSpan.FromSeconds(sample.Timestamp.FromNanoToSeconds()));

                            return writeToSink(sample);
                        });
                }
            }
        }