Ffmpeg: Mixing CPU and GPU processing

I have an old i7-2700K, an old ASUS GTX 760 and last ffmpeg version ffmpeg-n4.4-latest-win64-gpl-4.4.zip from BtbN

I want to transcoding a h.265 mkv file (1920x1080) to h.264 (downresizing to 444x250).

I want to use:

  • CPU (Sandy Bridge supports h.265 encoding/decoding also via Quick Sync Video) for decoding and
  • GPU for encoding (since my GPU card does not support h.265 format)

On developer.nvidia.com site I find only this hint for Mixing CPU and GPU processing:

ffmpeg -vsync 0 -c:v h264_cuvid -i input.264 -vf "fade,hwupload_cuda,scale_npp=1280:720" -c:v h264_nvenc output.264

What’s the right command for my problem?
Thanks

For source with h.265 10 bit :
ffmpeg -y -hwaccel qsv -c:v hevc_qsv -i input.mkv -vf “hwdownload,format=p010le” -s 444x250 -c:a copy -c:v h264_nvenc -pix_fmt nv12 -preset medium -tune ull -multipass fullres -rc-lookahead 32 -rc vbr -cq 29 -zerolatency 1 output.mkv

For source with h.265 8 bit :
ffmpeg -y -hwaccel qsv -c:v hevc_qsv -i input.mkv -vf “hwdownload,format=nv12” -s 444x250 -c:a copy -c:v h264_nvenc -preset medium -tune ull -multipass fullres -rc-lookahead 32 -rc vbr -cq 29 -zerolatency 1 output.mkv

1 Like

Thanks rroben27!

  1. is the order of params of vf important? Ex.: “hwdownload,format=nv12” = “format=nv12,hwdownload”

  2. “-tune ull” = “-tune ull 3” = “-tune 3” ? see this url

You welcome .

  1. It’s important if you mix between Quick Sync Video & nvidia .

You can do cpu & gpu, decode and scale and encod without -vf , like this :
For source with h.265 10 bit :
ffmpeg -i input.mkv -s 444x250 -c:a copy -c:v h264_nvenc -pix_fmt yuv420p -preset p7 -tune ull -multipass fullres -rc_lookahead 32 -rc vbr -cq 29 -zerolatency 1 -gpu 0 output.mkv

For source with h.265 8 bit or h.264 :
ffmpeg -i input.mkv -s 444x250 -c:a copy -c:v h264_nvenc -preset p7 -tune ull -multipass fullres -rc_lookahead 32 -rc vbr -cq 29 -zerolatency 1 -gpu 0 output.mkv

If you want full gpu cuda decode and scale and encod :
For source with h.265 10 bit :
ffmpeg -y -hwaccel cuda -hwaccel_output_format cuda -hwaccel_device cuda -i input.mkv -filter_complex scale_cuda=1280:-2,hwdownload,format=p010le,format=nv12,hwupload -sn -c:a copy -c:v h264_nvenc -preset p7 -tune 1 -multipass fullres -rc-lookahead 32 -rc vbr -cq 30 -zerolatency 1 output.mkv

For source with h.265 8 bit or h.264 :
ffmpeg -y -hwaccel cuda -hwaccel_output_format cuda -hwaccel_device cuda -i input.mkv -filter_complex “scale_cuda=1280:-2,hwdownload,format=nv12” -sn -c:a copy -c:v h264_nvenc -preset p7 -tune 1 -multipass fullres -rc-lookahead 32 -rc vbr -cq 30 -zerolatency 1 output.mkv

  1. -tune ull = -tune 3
    You can change it (1,2,3) or name it like 1=hq
1 Like
  1. with “ffmpeg -i input.mkv -s 444x250 -c:a copy -c:v h264_nvenc -pix_fmt yuv420p -preset p7 -tune ull -multipass fullres -rc_lookahead 32 -rc vbr -cq 29 -zerolatency 1 -gpu 0 output.mkv” is the CPU that scales the video, right? How If I want GPU make this? (My GPU “GK104” can only encode/decode h.264, not encode/decode h.265)

  2. thanks for two examples “If you want full gpu cuda decode and scale and encode”, anyway I can’t use them because my GPU card is too old :(

  3. where I can find info about the order of “-vf” and “-filter_complex” params ? Is this the only guide?

Thanks rroben27 for all!

  1. As explained in this link, GK104 does not support H.265 , so I think you can use it only with h.264, sorry for that.
    Nvidia NVENC - Wikipedia

You still can use Quick Sync Video :
ffmpeg -y -c:v hevc_qsv -i input.mkv -s 444x250 -sn -c:a copy -c:v h264_qsv -pix_fmt yuv420p -zerolatency 1 output.mkv
or
ffmpeg -i input.mkv -s 444x250 -sn -c:a copy -c:v h264_qsv -pix_fmt yuv420p -zerolatency 1 output.mkv

  1. You welcome ^_^ , I hope you will be able to do upgrade to your hardware so you can enjoy the great performance Nvidia GPU HWACCEL Transcode .

  2. Here some examples
    git.ffmpeg.org Git - ffmpeg.git/search

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.