WebRTC Video Codecs performance evaluation
The standard and most popular codecs in WebRTC are VP8 and H.264 but those are not the only options we have. VP9 has been available for a while and some big services are using it and AV1 support has been recently added to Chrome.
When comparing codecs there are interesting considerations like interoperability and licensing but probably the most important factors are how good the codec is in terms of compression and how cheap the codec is in terms of cpu&memory usage.
The compression ratio is usually the first thing we look at and there are many comparisons available for that, but the resource consumption is equally important if we want to be able to use the codecs for real time use cases.
Given that AV1 is available in the Chrome Canary versions I decided to run some tests to get estimation of where we stand in terms of cpu usage for the 4 available codecs in WebRTC ecosystem. The idea of the test is to compare the whole video pipeline with those 4 codecs and not just the codecs in isolation.
The tests were done with a simple web page establishing a connection between 2 PeerConnections (one sending and the other receiving). The test page is here in case you want to run the tests yourself:
The tests with that page were performed changing 3 variables:
- Codec: VP8, VP9, H264, AV1
- Resolution: HD, VGA, QVGA
- Bitrate: 200Kbps, 800Kbps, 2Mbps
QVGA resultsFor QVGA resolution the results were as expected, with VP9 requiring a bit more CPU than VP8 and AV1 requiring almost 2x CPU as VP8. H.264 was the one requiring less CPU usage as it is using hardware acceleration for that.
HD (1280x720) results
Encoding vs Decoding costI did one more test to split the cost between encoding (Sender side) and decoding (Receiver side). That test was performed for VGA at 800 Kbps and the results were the next ones for the four codecs under consideration.
Comparing just the decoding cost with different codecs it looks like AV1 is around 2x more expensive than the others. VP9 is slightly more expensive than VP8 and VP8 slightly more expensive than H264 but without big differences between those three.
ConclusionsHaving new codecs is amazing and there is no doubt AV1 is the future of real-time video communications but it looks like we should wait a bit to be able to use it for general purpose videoconferencing applications. In the mean time we can probably use it for specific use cases like broadcasting, dedicated powerful devices or to encode the low resolution versions of the video streams when using simulcast.
For other use cases VP8 and VP9 look like still the best options unless you don't worry that much about low bitrate cases or you are using high resolutions and battery/cpu consumption is a big concern and you can consider H264.
If you want to replicate the test and share your data I will update these tables/graphs with the average of the measurements. And as usual feedback is more than welcomed either here or in Twitter.
Thx a lot for the early feedback from @murillo, @elminiero, @dan_jenkins, @maniksach.