Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AV1Payloader is not compatible with av1-rtp-spec #190

Closed
AutumnSun1996 opened this issue Jun 14, 2022 · 3 comments · Fixed by pion/webrtc#2515
Closed

AV1Payloader is not compatible with av1-rtp-spec #190

AutumnSun1996 opened this issue Jun 14, 2022 · 3 comments · Fixed by pion/webrtc#2515
Labels
bug Something isn't working

Comments

@AutumnSun1996
Copy link

Your environment.

  • Version: v1.7.13
  • Other Information:
    The av1-rtp-spec has a lot of limitations, which is not handled by current implement of AV1Payloader.Payload
    func (p *AV1Payloader) Payload(mtu uint16, payload []byte) (payloads [][]byte) {

av1-rtp-spec
It requires obu element size in payload when W=0, and has limits for temporal_id and spatial_id in same packet, etc.
Current implement will results in invalid packet.

What did you do?

Trying to build a play-from-disk-ivf demo, which supports vp8, vp9 and av1 in ivf container.

What did you expect?

All codecs plays in browser.
Or, show error in some means when input data is invalid.
(The AV1Payloader.Payload do not return a error, but at least some log message to tell me somethin goes wrong here.)

What happened?

Browser failed to decode the AV1 packets, and no error message from pion.
(See discussion here https://gophers.slack.com/archives/CAK2124AG/p1654875989280929)

After some investigation I found that the reason is the rtp packets are incompatible with av1-rtp-spec.
In my implement I just put the frame date into WriteSample, which uses AV1Payloader.Payload to packetize it for rtp.
Since there is no check or transform for input data, the result is invalid and it's hard to find the reason.

@AutumnSun1996
Copy link
Author

AutumnSun1996 commented Jun 14, 2022

It seems the AV1Payloader.Payload will work if I always input a single obu, which is not what I get from IVFReader.
It will to be easier to handle one obu a time, I guess that's why current implement use this approach.
In this case, so some document or example should be good too.

I still thinks it will be better to change the AV1Payloader.Payload, so it will handle multiple obus too.
I'll try to implement it, here is my thoughts:
First, split the frame data into separate obus.
If there are several obus with hasSizeFlag=1, just do the split and remove size inside obu data.
And if there is a obu with hasSizeFlag=0, then treat all remaining data as obu data, so it is compatible with current behavior.
Then, re-organize the obus according to the av1-rtp-spec.

Any more suggestions here?

@aler9
Copy link
Member

aler9 commented May 22, 2023

The reason why AV1 packets packetized with this library can't be decoded by the browsers is that the N bit of the AV1 aggregation header is always set to zero, while it should be set to 1 in case of a first packet of a coded video sequence.

I have a working encoder here:
https://github.com/bluenviron/gortsplib/blob/main/pkg/formats/rtpav1/encoder.go

and i'd like to contribute it entirely to pion/rtp but i can't do it until this library is frozen.

@aler9 aler9 added the bug Something isn't working label May 22, 2023
Sean-Der added a commit to pion/webrtc that referenced this issue Jul 20, 2023
Sean-Der added a commit to pion/webrtc that referenced this issue Jul 20, 2023
Sean-Der added a commit to pion/webrtc that referenced this issue Jul 20, 2023
Sean-Der added a commit to pion/webrtc that referenced this issue Jul 20, 2023
@Sean-Der
Copy link
Member

Sorry this took so long @AutumnSun1996 !

Pion's play-from-disk and save-to-disk-av1 now work together.

ourwarmhouse added a commit to ourwarmhouse/Smart-Contract---Go that referenced this issue May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants