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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions mpe2aac.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,15 @@ void callback(mpegts_psi_t *psi)
}

/* when aac located successfully */
if (len_udp > 8)
fwrite(payload, 1, len_udp, stdout);
if (len_udp > 8) {
/* get AAC frame length as reported by the ADTS packet itself */
int aac_frame_len = ((payload[3] & 0x3) << 11) | ((payload[4] << 3) | (payload[5] >> 5));

/* Only output AAC frames with matching length in ADTS packet to avoid FFMPEG errors */
if (len_udp == aac_frame_len) {
fwrite(payload, 1, len_udp, stdout);
}
}

}

Expand Down