Answers.Body: <p>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.<br>
  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. <br></p>
  
  <p>In FFmpeg you can specify the gpu for encoding via <strong>-gpu key</strong> like follow:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>We can use the <strong>nvidia-smi</strong> tool <strong>to find an index for each video card</strong>. Also we can check it via other tools like GPU-Z or any afterburner, but nvidia-smi is installing together with the video driver. <br></p>
  
  <p>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:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>If we need to decode other codecs then we can choose the appropriate one from the following list:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>Please make sure that FFmpeg configured correctly with support nvenc and cuvid. You can find correct configuration parameters on the 
  <a href="https://developer.nvidia.com/ffmpeg" rel="nofollow noreferrer">NVIDIA site</a> (scroll down)</p>
  
  <p>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 <a href="https://developer.nvidia.com/video-encode-decode-gpu-support-matrix" rel="nofollow noreferrer">there</a>. <br>
  <strong>OR</strong> 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
  <a href="https://video.stackexchange.com/a/17943/14107">this old answer</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-28T14:12:21.137Z
Answers.LastActivityDate: 2018-06-28T14:12:21.137Z
Answers.UserDisplayName: Ivan Kolesnikov
Body: <p>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?</p>
  
  <p>Thanks for any input.</p>
  
Tags: <ffmpeg><nvenc>
Title: Does FFMPEG benefit from SLI when using h264_nvenc?
UserDisplayName: equinoxe5
ThreadText: # Does FFMPEG benefit from SLI when using h264_nvenc?
  
  (Asked by: username_0 on 2017-10-10)
  
  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.
  
  **Tags:** ffmpeg, nvenc
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-06-28. Score: 2 | Accepted answer
  
  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](https://developer.nvidia.com/ffmpeg) (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](https://developer.nvidia.com/video-encode-decode-gpu-support-matrix).   
  **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](https://video.stackexchange.com/a/17943/14107).
  
  
  ---
  
  