示例#1
0
        public IVideoFileWriter GetVideoFileWriter(VideoWriterArgs Args, string OutputArgs)
        {
            var args = FFMpegVideoWriterArgs.FromVideoWriterArgs(Args, _videoArgsProvider, _audioArgsProvider);

            args.OutputArgs = OutputArgs;

            return(new FFMpegWriter(args));
        }
示例#2
0
        public FFMpegPostProcessingWriter(FFMpegVideoWriterArgs Args)
        {
            _args         = Args;
            _tempFileName = Path.GetTempFileName();

            _ffMpegWriter = FFMpegItem.x264.GetVideoFileWriter(new VideoWriterArgs
            {
                AudioProvider = Args.AudioProvider,
                AudioQuality  = Args.AudioQuality,
                FileName      = _tempFileName,
                FrameRate     = Args.FrameRate,
                ImageProvider = Args.ImageProvider,
                VideoQuality  = Args.VideoQuality
            }, "-f mp4 -y");
        }
示例#3
0
        /// <summary>
        /// Creates a new instance of <see cref="FFMpegWriter"/>.
        /// </summary>
        public FFMpegWriter(FFMpegVideoWriterArgs Args)
        {
            var settings = ServiceProvider.Get <Settings>();

            _videoBuffer = new byte[Args.ImageProvider.Width * Args.ImageProvider.Height * 4];

            var audioPipeName = GetPipeName();
            var videoPipeName = GetPipeName();

            var videoInArgs  = $"-framerate {Args.FrameRate} -f rawvideo -pix_fmt rgb32 -video_size {Args.ImageProvider.Width}x{Args.ImageProvider.Height} -i {PipePrefix}{videoPipeName}";
            var videoOutArgs = $"{Args.VideoArgsProvider(Args.VideoQuality)} -r {Args.FrameRate}";

            if (settings.FFMpeg.Resize)
            {
                var width  = settings.FFMpeg.ResizeWidth;
                var height = settings.FFMpeg.ResizeHeight;

                if (width % 2 == 1)
                {
                    ++width;
                }

                if (height % 2 == 1)
                {
                    ++height;
                }

                videoOutArgs += $" -vf scale={width}:{height}";
            }

            string audioInArgs = "", audioOutArgs = "";

            if (Args.AudioProvider != null)
            {
                audioInArgs  = $"-f s16le -acodec pcm_s16le -ar {Args.Frequency} -ac {Args.Channels} -i {PipePrefix}{audioPipeName}";
                audioOutArgs = Args.AudioArgsProvider(Args.AudioQuality);

                _audioPipe = new NamedPipeServerStream(audioPipeName, PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 10000, 10000);
            }

            _ffmpegIn = new NamedPipeServerStream(videoPipeName, PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 10000, 10000);

            _ffmpegProcess = FFMpegService.StartFFMpeg($"{videoInArgs} {audioInArgs} {videoOutArgs} {audioOutArgs} {Args.OutputArgs} \"{Args.FileName}\"", Args.FileName);
        }
示例#4
0
 public virtual IVideoFileWriter GetVideoFileWriter(VideoWriterArgs Args)
 {
     return(new FFMpegWriter(FFMpegVideoWriterArgs.FromVideoWriterArgs(Args, _videoArgsProvider, _audioArgsProvider)));
 }
 public IVideoFileWriter GetVideoFileWriter(VideoWriterArgs Args)
 {
     return(new FFMpegPostProcessingWriter(FFMpegVideoWriterArgs.FromVideoWriterArgs(Args, _videoArgsProvider, _audioArgsProvider)));
 }