Why is encoding VP8/9 so slow compared to H.264?
Solution 1
libvpx-vp9
is a much slower encoder than libx264
but the default settings of threads in ffmpeg (0=auto) is not effective for libvpx. Manually setting it gives a speed bump. e.g.
ffmpeg -i in.mp4 -c:v libvpx-vp9 -threads 4 out.mp4
On a 4-core machine, when encoding a 1080-30p H.264 stream, I get a bump from 3.8 fps
to 10 fps
.
Solution 2
VP9 is a more more complex codec providing better compression. Video compression/performance ratio tends to be exponentially. You should expect the VP9 replacement (AV1) to be even slower.
Related videos on Youtube
comfreak
Updated on September 18, 2022Comments
-
comfreak over 1 year
Recently I wanted to try out the Webm codecs VP8 and VP9 but when I ran
ffmpeg
to encode a H.264 MP4 file into one of the other two codecs, I realized that the encoding is (by almost an order of magnitude) slower.A 1080p30 video from H.264 to VP9 at 3 MBit/s is being encoded at around 6-7 fps while the same video encodes at around 40 fps to H.264. I used the
libvpx-vp9
codec inffmpeg
for the VP9 format. I am getting the same results for VP8 and Theora too.Can someone explain to me why VP9 is so much slower? I tried a different machine which gave me similar resullts using Handbrake.
-
Ciro Santilli Путлер Капут 六四事 over 4 years
-
-
slhck almost 7 yearsOne should also mention that there are different speed presets, i.e.,
-preset
forlibx264
and-speed
forlibvpx-vp9
. Seeffmpeg -h full
. These can make quite a difference, but they also affect quality or compression efficiency. -
comfreak almost 7 yearsSo in other words, even though the codec "only" produces a relatively small size improvement, it may be much slower? Are the results I got representative?
-
comfreak almost 7 yearsI tried it on rather old machines but I did use 4 threads since both machines are quad-core. The
-speed
option didn't make a huge difference for me -
slhck almost 7 yearsVP9 can be up to 50% more efficient in terms of quality, @comfreak. I wouldn't call that small. You can't just compare the resulting file size.
-
comfreak almost 7 years@slhck: So you are saying that 3MBit/s can encode more original information than H.264 and therefore a lower bit rate than the source material in H.264 might be an option to speed things up?
-
slhck almost 7 years@comfreak Using a lower bitrate will not automatically increase the speed of the encoding process. I'm just saying that there is a tradeoff between compression efficiency and speed, and many streaming providers for example would rather invest the CPU time to create higher quality streams at lower overall bitrate, to conserve space and bandwidth. Using more efficient codecs (like VP9 or HEVC over H.264) also helps in that regard.
-
slhck almost 7 years@comfreak See also: developers.google.com/media/vp9/the-basics
-
slhck almost 7 yearsBut essentially, if speed is the most important factor for you, you should stick with older codecs (e.g., H.264), less compression-efficient presets, and perhaps also look into GPU-assisted encoding, e.g. with NVENC.