livepeer / go-livepeer

Official Go implementation of the Livepeer protocol
http://livepeer.org
MIT License
539 stars 169 forks source link

Add AV1 Decoding/Encoding Support #2780

Open eliteprox opened 1 year ago

eliteprox commented 1 year ago

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

  1. Upgrade livepeer ffmpeg to the latest 6.0 release
  2. Add an AV1 decoder to the ffmpeg build script, adding support to ingest AV1 encoded streams to go-livepeer.
  3. Add an AV1 encoder to the ffmpeg build script, add encoder profile formats as needed to LPMS and go-livepeer.
  4. Develop a sample -transcodingOptions config file to demonstrate output of AV1 encoded video.

Describe alternatives you've considered Here are some data points that may help with further scope analysis:

Additional context

stronk-dev commented 1 year ago

I did some preliminary (untested) work in the md/Intel_AV1 branch (6343f373395ec7a6ac32919d299be3efbc1472e0 42b4f4920aef34de7b927b0c0996b6c7c4b403a8)

This is now already a few months old, so will be tough to rebase but might be a good starting point

LPMS will indeed require more changes and these can be modeled after NetInt support: https://github.com/livepeer/lpms/commit/8b5dca93fe03556da66a3456d522304daf315f7f https://github.com/livepeer/lpms/pull/279/files

eliteprox commented 1 year ago

Thanks for sharing those links! It looks like https://github.com/livepeer/go-livepeer/commit/42b4f4920aef34de7b927b0c0996b6c7c4b403a8 covered almost everything outside of lpms. I am familiar with how to modify lpms and debug it as part of livepeer, so I can help out here.

Any idea what would be the cheapest nvidia hardware with av1 support? I don't think I have any AV1 supported hardware

stronk-dev commented 1 year ago

From a convo between me, Alex and Ivan back then:

- For testing, just add replace github.com/livepeer/lpms => ../lpms to go-livepeer's go.mod, to use your local lpms dir.
- AV1 encoding is supported by Nvidia starting from 30xx series, that's pretty modern hardware. I think it makes sense to go step by step, starting with CPU decoding support. For that, I'd add libaom compilation step and --enable-libaom to go-livepeer's install_ffmpeg.sh. After that, it boils down pretty much to adding corresponding constants to capabilities.go, and no changes to lpms at all. Adding hardware transcoding would involve changes to lpms, to pass correct Nvidia codec name. It's best to keep PRs small and easily reviewable.
I thought 30xx series added AV1 decoder, and 40xx series have AV1 encoder (released couple weeks ago)
Seems to be the case, only Ada lovelace family supports AV1 nvenc && Ampere for nvdec 

So yeah we'd need one of those outrageously expensive 40xx cards... I was thinking of getting the NVIDIA RTX 4000 SFF when it becomes available in my area. If/when I get I can give you access but would still be way out. However, the Intel cards with AV1 support are cheap (I have one at the office and papa bear has one too) so maybe we can start with Intel support here (I think they are in the latest FFMPEG release?)

Pon-node commented 1 year ago

@stronk-dev @eliteprox if you need stupidly expensive 40xx series card for testing let me know, I can set up a server for you to play around.

papabear99 commented 1 year ago

Would love to see Intel QSV support! From a few tests I've seen their encoders are high quality and fast, with the inexpensive A380 (currently $119 @ Newegg) beating the 3090 in both H.264 and H.265 and as mentioned support AV1 encoding.

cyberj0g commented 1 year ago

Great proposal! The implementation would be fairly trivial and can follow this, except for Ffmpeg 6.0 migration. We had some issues with newer version of Ffmpeg, while integrating Netint support, probably related to slight changes in the API.