preset slow CUDA encoding preset: High Quality 2-Pass Scale_npp=format=yuv420p,hwdownload,format=yuv420p this part of the filter pipeline will convert the pixelformat of the encoded frames to yuv420p (instead of cuda or nv12)
The coding efficiency graph below shows that mpeg2qsv bitrate must be increased by 60 percent to match h264qsv TU7/veryfast. As expected with mpeg2, large bitrate increases are required to match even the lowest range of h264 quality. In the latter case this filter will deinterlace it. Unlike h264qsv, which has a range of preset options to consider, all mpeg2qsv presets execute as TU1/slow. vf yadif_cuda=0:-1:1 the input file might be encode progressive or interlaced. c:v h264_nvenc this instructs the encoder to use the GPI for any encoding of the ouput file c:v mpeg2_cuvid this instructs the decoder to use the GPU for any decoding of the input file hwaccel cuvid this tells ffmpeg to enable CUDA for the pipeline y the script will ultimately run on a headless system and this overwrites any existing output file by default hide_banner this keeps the console log cleaner threads 0 the host is a multicore-CPU system and few tasks in the pipeline are still threadable although the brunt of the work happens during encoding on the GPU, this enables use of all available cores Let's take the plethora of arguments apart piece by piece. The final file size for a same quality video might be a little higher than a pure software/CPU pipeline, but the tradoff is big savings in absolute time spent filtering and encoding the video!Īll right, here is the final command: ( TLDR ) ffmpeg -threads 0 -hide_banner -y -hwaccel cuvid -c:v mpeg2_cuvid -i "$" -c:v h264_nvenc -vf yadif_cuda=0:-1:1,scale_npp=format=yuv420p,hwdownload,format=yuv420p,decimate -preset hq -refs 4 -bf:v 2 -profile:v high -level 4.2 -qmin 19 -qmax 24 -maxrate 6M -bufsize 12M -map 0:0 -map 0:m:language:eng -c:a copy -map 0:s? -c:s copy -movflags +faststart The system is equipped with an RTX 2080 boasting powerfull hardware video encoding capabilities. Hardware encoding pipeline using NVidia CUDA
#Ffmpeg h264 to mpeg2 android
The target is a video file playable natively on modern iOS and Android devices using their platforms native and hardware supported playback capabilities. In addition the video stream might be interlaced. The goal is to transcode a DVR recording containing one video source in mpeg2 format, any number (typically 2-3) of audio sources in ac-3 format and maybe a subtitle source all together in a transport stream container.