eti-tools
eti-tools copied to clipboard
Check ADTS frame len and UDP frame len match to stop invalid data output
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
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.