I need to pass a very large amount of video through ffmpeg to be encoded to h264. I've figured out my processing workflow and am happy with the results. The machine is currently sporting one GTX1070. I'm wondering if I'll benefit from adding a second card in SLI configuration? Will it double the performance? Is there considerable overhead?

Thanks for any input.


There is not necessary to add a card in SLI. Is enough to buy another card to double the performance. By default NVIDIA supports only 2 encoding streams in parallel for consumer level cards. For your goals it should be enough.
You may buy another one GTX 1070, but it's not necessary as you need to transcode a vary large amount of video files in 2 parallel streams. Will be better to buy another video card on the Pascal architecture. In this case you will safe some money and get very similar result as on GTX 1070. GTX 1050 should be enough, because the NVENC SIP which uses for encoding the same as on GTX 1070, as on GTX 1050.

In FFmpeg you can specify the gpu for encoding via -gpu key like follow:

ffmpeg -i video_for_gtx1070.mpg -vcodec h264_nvenc \
       -gpu 0 -acodec copy -f mpegts transcoded_on_gtx1070.mpg

ffmpeg -i video_for_other_card.mpg -vcodec h264_nvenc \
       -gpu 1 -acodec copy -f mpegts transcoded_on_other_card.mpg

We can use the nvidia-smi tool to find an index for each video card. Also we can check it via other tools like GPU-Z or any afterburner, but nvidia-smi is installing together with the video driver.

About overhead: you will get CPU load by decoding video as the video files be decode on CPU and encode on GPU, but you can keep CPU almost clean if you'll also decode the video on GPU. The same examples with decoding h264 on different GPUs:

ffmpeg hwaccel cuvid -c:v h264_cuvid -gpu 0 \
       -i video_for_gtx1070.mpg -vcodec h264_nvenc \
       -gpu 0 -acodec copy -f mpegts transcoded_on_gtx1070.mpg

ffmpeg hwaccel cuvid -c:v h264_cuvid -gpu 1 \
       -i video_for_other_card.mpg -vcodec h264_nvenc \
       -gpu 1 -acodec copy -f mpegts transcoded_on_other_card.mpg

If we need to decode other codecs then we can choose the appropriate one from the following list:

ffmpeg -decoders | grep cuvid
 V..... h264_cuvid           Nvidia CUVID H264 decoder (codec h264)
 V..... hevc_cuvid           Nvidia CUVID HEVC decoder (codec hevc)
 V..... mjpeg_cuvid          Nvidia CUVID MJPEG decoder (codec mjpeg)
 V..... mpeg1_cuvid          Nvidia CUVID MPEG1VIDEO decoder (codec mpeg1video)
 V..... mpeg2_cuvid          Nvidia CUVID MPEG2VIDEO decoder (codec mpeg2video)
 V..... mpeg4_cuvid          Nvidia CUVID MPEG4 decoder (codec mpeg4)
 V..... vc1_cuvid            Nvidia CUVID VC1 decoder (codec vc1)
 V..... vp8_cuvid            Nvidia CUVID VP8 decoder (codec vp8)
 V..... vp9_cuvid            Nvidia CUVID VP9 decoder (codec vp9)

Please make sure that FFmpeg configured correctly with support nvenc and cuvid. You can find correct configuration parameters on the NVIDIA site (scroll down)

If you need to transcode a lot of streams|files in parallel then need to buy the video card(s) with unrestricted amount of encoding sessions. You can find the information there.
OR you can go by the hack way and remove the sessions limitation for the consumer level video cards. It's possible as this limitation managed on the video driver level. In this case I recommend you to buy GTX 1060 6GB or GTX 1070 as in this situation the amount of video memory is also very important. You can find more useful info about multiple streams transcoding in this old answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.