Answers.Body: <p>Okay, I found the one option that will show you whether there is hardware support:</p>
  <pre><code>ffmpeg -codecs | less
  </code></pre>
  <p>Then search for your format, it looks like you'd type:</p>
  <pre><code>/h264&lt;enter&gt;
  </code></pre>
  <p>In my case, it shows me that I have <code>nvenc</code> as one of the sub-options:</p>
  <blockquote>
  <p>DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_crystalhd h264_v4l2m2m h264_vdpau h264_cuvid ) (encoders: libx264 libx264rgb h264_nvenc h264_omx h264_v4l2m2m h264_vaapi nvenc nvenc_h264 )</p>
  </blockquote>
  <p>Reading from the <a href="https://developer.nvidia.com/ffmpeg" rel="nofollow noreferrer">nvidia/ffmpeg</a> page, if ffmpeg is compiled with hardware acceleration, it should auto-pickup the available hardware encoder. However, hardware may not always encode with the same level of quality so it may be preferable to use software anyway. If you need realtime, though, you definitely want the hardware when available.</p>
  <p>Next you need the following option:</p>
  <pre><code>... -hwaccel auto ...
  </code></pre>
  <p>The default, as I mentioned in my comment, is <code>none</code>.</p>
  <p>For more info you may want to look at the manual page:</p>
  <pre><code>man ffmpeg
  </code></pre>
  <p>and search for <code>hardware</code> or <code>hw</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-09T20:41:21.590Z
Answers.LastActivityDate: 2021-07-09T20:41:21.590Z
Answers.UserDisplayName: Alexis Wilke
Body: <p>I had initially used VLC to record the screen of computer using the following script:</p>
  <pre><code>/Applications/VLC.app/Contents/MacOS/VLC -I rc screen:// --sout-keep --screen-fps=7.0 --screen-index=0 --sout #transcode{vcodec=h264,vb=1500,width=1280,height=720,acodec=mp3,ab=128,channels=2,samplerate=44100}:file{dst=/Users/shashi/temp/vlctesting4.mp4,no-overwrite}
  </code></pre>
  <p>The audio codec parameters are redundant because I am only recording the screen. However, with these video parameters, I get a decent recording of the screen without a noticeable cpu usage as well as relatively low file size.</p>
  <p>Now I have to achieve the same but using FFmpeg instead of VLC. I thought that should be possible because both use the same underlying library. However, no matter how much I try, FFmpeg recording takes more CPU and the resulting file takes up much more space than what VLC achieves.</p>
  <p>A sample FFmpeg command I tried:</p>
  <pre><code>ffmpeg -hide_banner  -f avfoundation -i &quot;2:none&quot; -r 10 -vf &quot;scale=-1:720,setsar=sar=10/9&quot;  -c:v h264_videotoolbox -b:v 1250K -keyint_min 20 -bf 5 testing_ffmpeg.mp4
  </code></pre>
  <p>Both are using the h264 encoding but how is VLC more efficient by such a degree? In fact VLC does not even seem to use the HW acceleration for encoding.. ? But a 1 minute recording from VLC is around 1 MB with decent quality but to get similar quality from FFmpeg, the file size is around 7 MB...</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-09T17:51:32.533Z
Comments.Text: Yes. The VLC is most certainly using the HW accelerated compressor. For ffmpeg, you'll need to find the correct command line options to _force_ the use of a compressor which supports hardware.
Comments.UserDisplayName: Alexis Wilke
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-12-03T00:27:07.733Z
Comments.Text: What codec does VLC say it is using?
Comments.UserDisplayName: rogerdpack
Tags: <ffmpeg><h.264><vlc>
Title: How to get VLC like screen recording performance with FFmpeg?
UserDisplayName: shashi
ThreadText: # How to get VLC like screen recording performance with FFmpeg?
  
  (Asked by: username_0 on 2021-07-09)
  
  I had initially used VLC to record the screen of computer using the following script:
  
  ```
  /Applications/VLC.app/Contents/MacOS/VLC -I rc screen:// --sout-keep --screen-fps=7.0 --screen-index=0 --sout #transcode{vcodec=h264,vb=1500,width=1280,height=720,acodec=mp3,ab=128,channels=2,samplerate=44100}:file{dst=/Users/username_0/temp/vlctesting4.mp4,no-overwrite}
  
  ```
  
  The audio codec parameters are redundant because I am only recording the screen. However, with these video parameters, I get a decent recording of the screen without a noticeable cpu usage as well as relatively low file size.
  
  Now I have to achieve the same but using FFmpeg instead of VLC. I thought that should be possible because both use the same underlying library. However, no matter how much I try, FFmpeg recording takes more CPU and the resulting file takes up much more space than what VLC achieves.
  
  A sample FFmpeg command I tried:
  
  ```
  ffmpeg -hide_banner  -f avfoundation -i "2:none" -r 10 -vf "scale=-1:720,setsar=sar=10/9"  -c:v h264_videotoolbox -b:v 1250K -keyint_min 20 -bf 5 testing_ffmpeg.mp4
  
  ```
  
  Both are using the h264 encoding but how is VLC more efficient by such a degree? In fact VLC does not even seem to use the HW acceleration for encoding.. ? But a 1 minute recording from VLC is around 1 MB with decent quality but to get similar quality from FFmpeg, the file size is around 7 MB...
  
  **Tags:** ffmpeg, h.264, vlc
  
  > **Comments:**
  > **username_1**: Yes. The VLC is most certainly using the HW accelerated compressor. For ffmpeg, you'll need to find the correct command line options to _force_ the use of a compressor which supports hardware.  
  > **username_2**: What codec does VLC say it is using?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-07-09. Score: 2 | Accepted answer
  
  Okay, I found the one option that will show you whether there is hardware support:
  
  ```
  ffmpeg -codecs | less
  
  ```
  
  Then search for your format, it looks like you'd type:
  
  ```
  /h264<enter>
  
  ```
  
  In my case, it shows me that I have `nvenc` as one of the sub-options:
  
  > DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264\_crystalhd h264\_v4l2m2m h264\_vdpau h264\_cuvid ) (encoders: libx264 libx264rgb h264\_nvenc h264\_omx h264\_v4l2m2m h264\_vaapi nvenc nvenc\_h264 )
  
  Reading from the [nvidia/ffmpeg](https://developer.nvidia.com/ffmpeg) page, if ffmpeg is compiled with hardware acceleration, it should auto-pickup the available hardware encoder. However, hardware may not always encode with the same level of quality so it may be preferable to use software anyway. If you need realtime, though, you definitely want the hardware when available.
  
  Next you need the following option:
  
  ```
  ... -hwaccel auto ...
  
  ```
  
  The default, as I mentioned in my comment, is `none`.
  
  For more info you may want to look at the manual page:
  
  ```
  man ffmpeg
  
  ```
  
  and search for `hardware` or `hw`.
  
  
  ---
  
  