Answers.Body: <p>Libvpx has no hardware encoding or acceleration support of any kind, it's purely a software implementation. There are <a href="https://en.wikipedia.org/wiki/VP9#Hardware_implementations" rel="nofollow noreferrer">some VP9 hardware encoders</a> out there but they're few in number and neither Nvidia or AMD have one. However, if you have an Intel CPU from the Skylake architecture or newer you should be able to use Intel's QuickSync hardware encoder built into their CPUs. I don't have the hardware to test it and don't know which OS you're on, but to use it on Linux I think you'd do something like this: <code>ffmpeg -vaapi_device /dev/dri/renderD128 -i 16.mov -vf 'format=nv12,hwupload' -c:v vp9_vaapi -g 150 -bf 4 -compression_level 1 -bsf:v vp9_raw_reorder,vp9_superframe -b:v 15M -an 16_vp9.webm</code></p>
  
  <p>You may find that the quality leaves much to be desired which is often the case with hardware encoders, most of them are built for speed over quality. So a better approach might be tuning libvpx for faster encoding. For starters you should use <code>-row-mt 1</code> to enable row-based multithreading which can speed up encoding quite a bit, especially at higher resolutions and when you have lots of cores/threads available. Next you might want to adjust the encoding speed for HD resolution videos by setting <code>-cpu-used 2</code>. This is similar to x264's <code>-preset</code> option and it adjusts the speed/efficiency tradeoff. The default in FFmpeg is 1 which is the slowest most people would want to go; 0 basically triples the encoding time.</p>
  
  <p>Depending on how old your version of FFmpeg and libvpx are, you might also want to set the number of encoding threads manually. I'm not sure which version of FFMpeg or libvpx changed this, but in the past you had to set your <code>-threads</code> by hand or else FFmpeg would only use a single thread for encoding. Also, the <code>-frame-parallel</code> option was removed from libvpx quite some time ago. It's ignored in the libvpx code so there's no detriment to using it, but it offers no benefit either.</p>
  
  <p>I also recommend checking out <a href="https://developers.google.com/media/vp9/settings/vod/" rel="nofollow noreferrer">Google's VP9 Encoding Guide</a>. It's a pretty good reference on which parameters and bitrates you might want to use for different resolutions.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-24T12:49:54.780Z
Answers.Text: VP9 encoding was only added in [Kaby Lake](https://www.anandtech.com/show/10610/intel-announces-7th-gen-kaby-lake-14nm-plus-six-notebook-skus-desktop-coming-in-january/3).
Answers.UserDisplayName: mirh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-30T19:21:17.083Z
Answers.Text: Can I ask you something about your recent edit on the FFmpeg wiki regarding libvpx? Your edit says `-speed 4` in the first pass is actually detrimental, yet it's mentioned in the Google documentation [here](https://developers.google.com/media/vp9/settings/vod/)). But I guess the latter is simply incorrect? (I haven't yet verified running the commands.)
Answers.UserDisplayName: slhck
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-23T13:33:00.243Z
Answers.LastActivityDate: 2018-10-23T13:33:00.243Z
Answers.UserDisplayName: veikk0
Body: <p>I tried to encode mp4 4K with H.264 format to webm format using ffmpeg libvpx, I need to convert them to multi resolution 1080p - 144p. 
  I was run following command :</p>
  
  <pre><code>ffmpeg -i  source-4K.h264.mp4  -c:v libvpx-vp9 -s hd720 -b:v 1500k -keyint_min 150 -g 150 -tile-columns 4 -frame-parallel 1 -an -f webm -dash 1 out-hd720.webm
  </code></pre>
  
  <p>and I found that video from 360p and above are slowly processed, so I am thinking to use nvidia card (P4 card on Google Cloud) to accelerate the process. but I haven't found any articles / resources nor command to do video encoding using libvpx with hardware acceleration. </p>
  
Tags: <ffmpeg><nvidia>
Title: FFMPEG: hardware acceleration for libvpx
UserDisplayName: zkrhm
ThreadText: # FFMPEG: hardware acceleration for libvpx
  
  (Asked by: username_0 on 2018-10-23)
  
  I tried to encode mp4 4K with H.264 format to webm format using ffmpeg libvpx, I need to convert them to multi resolution 1080p - 144p.
  I was run following command :
  
  ```
  ffmpeg -i  source-4K.h264.mp4  -c:v libvpx-vp9 -s hd720 -b:v 1500k -keyint_min 150 -g 150 -tile-columns 4 -frame-parallel 1 -an -f webm -dash 1 out-hd720.webm
  
  ```
  
  and I found that video from 360p and above are slowly processed, so I am thinking to use nvidia card (P4 card on Google Cloud) to accelerate the process. but I haven't found any articles / resources nor command to do video encoding using libvpx with hardware acceleration.
  
  **Tags:** ffmpeg, nvidia
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-23. Score: 4
  
  Libvpx has no hardware encoding or acceleration support of any kind, it's purely a software implementation. There are [some VP9 hardware encoders](https://en.wikipedia.org/wiki/VP9#Hardware_implementations) out there but they're few in number and neither Nvidia or AMD have one. However, if you have an Intel CPU from the Skylake architecture or newer you should be able to use Intel's QuickSync hardware encoder built into their CPUs. I don't have the hardware to test it and don't know which OS you're on, but to use it on Linux I think you'd do something like this: `ffmpeg -vaapi_device /dev/dri/renderD128 -i 16.mov -vf 'format=nv12,hwupload' -c:v vp9_vaapi -g 150 -bf 4 -compression_level 1 -bsf:v vp9_raw_reorder,vp9_superframe -b:v 15M -an 16_vp9.webm`
  
  You may find that the quality leaves much to be desired which is often the case with hardware encoders, most of them are built for speed over quality. So a better approach might be tuning libvpx for faster encoding. For starters you should use `-row-mt 1` to enable row-based multithreading which can speed up encoding quite a bit, especially at higher resolutions and when you have lots of cores/threads available. Next you might want to adjust the encoding speed for HD resolution videos by setting `-cpu-used 2`. This is similar to x264's `-preset` option and it adjusts the speed/efficiency tradeoff. The default in FFmpeg is 1 which is the slowest most people would want to go; 0 basically triples the encoding time.
  
  Depending on how old your version of FFmpeg and libvpx are, you might also want to set the number of encoding threads manually. I'm not sure which version of FFMpeg or libvpx changed this, but in the past you had to set your `-threads` by hand or else FFmpeg would only use a single thread for encoding. Also, the `-frame-parallel` option was removed from libvpx quite some time ago. It's ignored in the libvpx code so there's no detriment to using it, but it offers no benefit either.
  
  I also recommend checking out [Google's VP9 Encoding Guide](https://developers.google.com/media/vp9/settings/vod/). It's a pretty good reference on which parameters and bitrates you might want to use for different resolutions.
  
  > **Comments:**
  > **username_3**: Can I ask you something about your recent edit on the FFmpeg wiki regarding libvpx? Your edit says `-speed 4` in the first pass is actually detrimental, yet it's mentioned in the Google documentation [here](https://developers.google.com/media/vp9/settings/vod/)). But I guess the latter is simply incorrect? (I haven't yet verified running the commands.)  
  > **username_2**: VP9 encoding was only added in [Kaby Lake](https://www.anandtech.com/show/10610/intel-announces-7th-gen-kaby-lake-14nm-plus-six-notebook-skus-desktop-coming-in-january/3).  
  
  ---
  
  