private void RunSecondPass()
        {
            var inputFile = new InputFileOptions();
            inputFile.FilePath = Path.GetFullPath(SourceFilePath);

            var outputFile = new OutputFileOptions();

            if (ShouldDeinterlaceVideo)
                outputFile.Add(new DeinterlaceVideoOption());

            if (_VideoWidth.IsSet && _VideoWidth.Value != 0)
                GeckonPresets.ApplyHighQualitySecondPassPreset(outputFile, VideoBitrate, AudioBitrate, VideoWidth, VideoHeight);
            else
                GeckonPresets.ApplyHighQualitySecondPassPreset(outputFile, VideoBitrate, AudioBitrate);

            outputFile.FilePath = Path.GetFullPath(DestinationFilePath);

            outputFile.Add(new ThreadsOption(ThreadsOption.AUTOMATICALLY_SELECT_NUMBER_OF_THREADS));

            using (var wrapper = new FFmpegWrapper())
            {
                wrapper.FFmpegExecutablePath = Path.GetFullPath(FFmpegFilePath);

                wrapper.AddInputFileOptions(inputFile);
                wrapper.OutputFileOptions = outputFile;

                wrapper.WorkingDirectory = TemporaryDirectoryPath;

                wrapper.ProgressDataChanged += SecondPassProgressDataChanged;

                wrapper.UnparsedOutputOccurred += (sender, args) => _FFmpegOutput.AppendLine(args.EventObject);
                wrapper.WarningOccurred += (sender, args) => _FFmpegOutput.AppendLine(args.EventObject.Warning);
                wrapper.ErrorOccurred += (sender, args) => _FFmpegOutput.AppendLine(args.EventObject.ToString());

                wrapper.Execute();

                FFmpegArguments += "\n" + wrapper.FFmpegArguments;

                wrapper.ProgressDataChanged -= SecondPassProgressDataChanged;
            }
        }
Пример #2
0
        private void CutFrame()
        {
            var inputFile = new InputFileOptions();
            inputFile.FilePath = Path.GetFullPath(SourceFilePath);

            var outputFile = new OutputFileOptions();

            if (_Width.IsSet && _Width.Value != 0)
                GeckonPresets.ApplyCutVideoFramePreset(inputFile, outputFile, TimeSpan.Parse(_VideoPosition.Value), Width, Height);
            else
                GeckonPresets.ApplyCutVideoFramePreset(inputFile, outputFile, TimeSpan.Parse(_VideoPosition.Value));

            outputFile.FilePath = Path.GetFullPath(DestinationFilePath);

            using (var wrapper = new FFmpegWrapper())
            {
                wrapper.FFmpegExecutablePath = Path.GetFullPath(FFmpegFilePath);

                wrapper.AddInputFileOptions(inputFile);
                wrapper.OutputFileOptions = outputFile;

                wrapper.ProgressDataChanged += ProgressDataChanged;

                wrapper.RawOutputOccurred += (sender, e) => Console.WriteLine(e.EventObject);

                wrapper.Execute();

                wrapper.ProgressDataChanged -= ProgressDataChanged;
            }
        }
        private void AdjustVideoSize()
        {
            var inputFile = new InputFileOptions();
            inputFile.FilePath = Path.GetFullPath(SourceFilePath);

            using (var wrapper = new FFmpegWrapper())
            {
                wrapper.FFmpegExecutablePath = Path.GetFullPath(FFmpegFilePath);

                wrapper.AddInputFileOptions(inputFile);

                wrapper.WorkingDirectory = TemporaryDirectoryPath;

                wrapper.UnparsedOutputOccurred += (sender, args) => _FFmpegOutput.AppendLine(args.EventObject);
                wrapper.WarningOccurred += (sender, args) => _FFmpegOutput.AppendLine(args.EventObject.Warning);
                wrapper.ErrorOccurred += (sender, args) => _FFmpegOutput.AppendLine(args.EventObject.ToString());

                wrapper.Execute();

                if (wrapper.MediaData.Inputs.Count < 1)
                    return;

                StreamData stream;

                try
                {
                    stream = wrapper.MediaData.Inputs[0].Streams.First(s => s.Value.Type == StreamType.Video).Value;
                }
                catch (InvalidOperationException)
                {
                    return; //No video stream found, so aspectratio can be determined
                }

                var sizeData = stream.ParsedData.OfType<StreamSizeData>();

                if(sizeData.Count() == 0)
                    return;

                var firstSizeData = sizeData.First();

                var aspect = firstSizeData.DisplayAspectRatio ?? firstSizeData.Size.Width / (double)firstSizeData.Size.Height; //Use DAR if available, else use video resolution

                if (VideoWidth / aspect < VideoHeight)
                    _VideoHeight.Value = (uint)(Math.Round(VideoWidth / aspect / 2) * 2); //Make sure size is dividable by two
                else
                    _VideoWidth.Value = (uint)(Math.Round(VideoHeight * aspect / 2) * 2); //Make sure size is dividable by two
            }
        }
Пример #4
0
        private void AdjustVideoSize()
        {
            var inputFile = new InputFileOptions();
            inputFile.FilePath = Path.GetFullPath(SourceFilePath);

            using (var wrapper = new FFmpegWrapper())
            {
                wrapper.FFmpegExecutablePath = Path.GetFullPath(FFmpegFilePath);

                wrapper.AddInputFileOptions(inputFile);

                wrapper.Execute();

                if (wrapper.MediaData.Inputs.Count < 1)
                    return;

                StreamData stream;

                try
                {
                    stream = wrapper.MediaData.Inputs[0].Streams.First(s => s.Value.Type == StreamType.Video).Value;
                }
                catch (InvalidOperationException)
                {
                    return; //No video stream found, so aspectratio can be determined
                }

                var sizeData = stream.ParsedData.OfType<StreamSizeData>();

                if (sizeData.Count() == 0)
                    return;

                var firstSizeData = sizeData.First();

                var aspect = firstSizeData.DisplayAspectRatio ?? firstSizeData.Size.Width / (double)firstSizeData.Size.Height; //Use DAR if available, else use video resolution

                if (Width / aspect < Height)
                    _Height.Value = (uint)(Math.Round(Width / aspect / 2) * 2); //Make sure size is dividable by two
                else
                    _Width.Value = (uint)(Math.Round(Height * aspect / 2) * 2); //Make sure size is dividable by two
            }
        }