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

h264: Fix AnnexB parser when NALUs end with a 0 byte #159

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

oguzbilgener
Copy link
Contributor

In mediamtx, when using UDP/MPEGTS sources, we were having trouble with WebRTC playback with certain IP cameras such as Wisenet XND-6010.

The playback wasn't starting, due to seemingly missing Picture Parameter Sets. But The Picture Parameter Set was actually there, but mediamtx wasn't able to parse the PPS. The AnnexB parser wasn't able to separate PPS from the SPS, because the SPS NALU was ending with a zero byte. The SPS was ending with a 0 byte, and the NALU separator was 0001.

This is valid according to the AnnexB spec, but the parser assumes a NALU cannot end with a 0 byte due to the zeroCount == 2 || zeroCount == 3 condition. So I made an attempt to rewrite the parser and also correct a test case under "2 or 3 zeros". I also added more test cases.

Using this branch of mediacommon in a mediamtx build, we're actually able to watch a stream from that camera over WebRTC and UDP/MPEGTS.

@aler9 aler9 merged commit f0d3bea into bluenviron:main Dec 16, 2024
6 checks passed
@aler9
Copy link
Member

aler9 commented Dec 16, 2024

merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants