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

aac2mp4 / Ap4AdtsParser.FindFrame lost the latest frame. #31

Closed
alexbuisson opened this issue Oct 8, 2015 · 2 comments
Closed

aac2mp4 / Ap4AdtsParser.FindFrame lost the latest frame. #31

alexbuisson opened this issue Oct 8, 2015 · 2 comments

Comments

@alexbuisson
Copy link

Hi,
I use a simple AAC file of 1085 frames, if I use FFMPEG to Mux that track into a MP4 file and extract again the AAC with ffmpeg, I retrieve an AAC file of 1085 frame (same as the input).

But with the Bento4 App aac2mp4 I get only 1084 frames.

After some investigation I found that in AP4_AdtsParser::FindFrame at the end we run that test:

} else if (available < adts_header.m_FrameLength || (m_Bits.m_Flags & AP4_BITSTREAM_FLAG_EOS) == 0) {
    // not enough for a frame, or not at the end (in which case we'll want to peek at the next header)
    return AP4_ERROR_NOT_ENOUGH_DATA;
}

In my case adts_header.m_FrameLength is equal to 'available'. The frame is really small (14 bytes) but as the m_Bits.m_Flags is always 0 (0 & 1 == 0 TRUE) the current implementation return AP4_ERROR_NOT_ENOUGH_DATA

I don't see all the implications of a change where in the if statement || become && or where (m_Bits.m_Flags & AP4_BITSTREAM_FLAG_EOS) == 0 become (m_Bits.m_Flags & AP4_BITSTREAM_FLAG_EOS) == 1

but at least I can say that by just changing that if statement I'm able to use aac2mp4 without losing a frame :)

@barbibulle
Copy link
Contributor

Hi Alex,

thanks for the bug report.
The issue isn't in the AP4_AdtsParser class, but in the app that calls it
(aac2mp4.cpp).
The caller forgets to set the 'EOS' flag when it has reached the end of the
stream, so the parser still expects more data to come.
I have fixed this and pushed to GitHub. Precompiled binaries will be
updated soon, but if you want to try the fix before then, you can compile
from the source distribution.

On Thu, Oct 8, 2015 at 7:30 AM, Alex Buisson notifications@github.com
wrote:

Hi,
I use a simple AAC file of 1085 frames, if I use FFMPEG to Mux that track
into a MP4 file and extract again the AAC with ffmpeg, I retrieve an AAC
file of 1085 frame (same as the input).

But with the Bento4 App aac2mp4 I get only 1084 frames.

After some investigation I found that in AP4_AdtsParser::FindFrame at the
end we run that test:

} else if (available < adts_header.m_FrameLength || (m_Bits.m_Flags & AP4_BITSTREAM_FLAG_EOS) == 0) {
// not enough for a frame, or not at the end (in which case we'll want to peek at the next header)
return AP4_ERROR_NOT_ENOUGH_DATA;
}

In my case adts_header.m_FrameLength is equal to 'available'. The frame
is really small (14 bytes) but as the m_Bits.m_Flags is always 0 (0 & 1
== 0 TRUE) the current implementation return AP4_ERROR_NOT_ENOUGH_DATA

I don't see all the implications of a change where in the if statement ||
become && or where (m_Bits.m_Flags & AP4_BITSTREAM_FLAG_EOS) == 0 become (m_Bits.m_Flags
& AP4_BITSTREAM_FLAG_EOS) == 1

but at least I can say that by just changing that if statement I'm able to
use aac2mp4 without losing a frame :)


Reply to this email directly or view it on GitHub
#31.

@alexbuisson
Copy link
Author

Cool, thank for your help !

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

No branches or pull requests

2 participants