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

Check ADTS frame len and UDP frame len match to stop invalid data output #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mrwish7
Copy link
Contributor

@mrwish7 mrwish7 commented Apr 9, 2021

Some packets with the correct header (0xFF 0xF9/0xFF 0xF1) aren't actually valid AAC ADTS frames in some streams (e.g. Hispasat 30W 12518H). We can filter these by checking that the UDP packet length for the payload (minus headers) matches the packet length as reported in the ADTS frames itself.

The invalid ADTS frames have super long length values (e.g. 7831 bytes), which doesn't match the spec (max frame length 768 bytes), so these seem safe to drop. I don't know what these invalid frames are and what purpose they serve, but I've tested this fix with the Hispasat streams and the output AAC data is glitch-free and plays perfectly.

Fixes #36

@mrwish7
Copy link
Contributor Author

mrwish7 commented Apr 9, 2021

Just to add - the reported length of these invalid ADTS frames is always way longer than the actual remaining length of the UDP packet (which matches the ADTS frame length otherwise for valid audio packets) so that is why matching the lengths in this way works to successfully filter the stream.

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.

mpe2aac: ADTS frame length validation
2 participants