Open moveman opened 2 years ago
@moveman can you please copy your .meta file ? I am not clear on the issue, is it the last frame that is copied twice, or is it simply the AUD nal which is wrongfully added ?
@jcdr428 this is the .meta file:
MUXOPT --no-pcr-on-video-pid --cbr --bitrate=5606.25 --vbv-len=3000 --start-time=62950
V_MPEG4/ISO/AVC, "/mnt/job/77c0fa26-cd8d-4611-919b-171777c52eda/1video.h264"
A_AAC, "/mnt/job/77c0fa26-cd8d-4611-919b-171777c52eda/1_0.aac", timeshift=0ms, , lang=eng
The last frame is not copied twice. AUD nal is wrongly added to the last frame. In addition, this last frame has two PTS instead of one PTS.
The following code in MPEGStreamReader::readPacket() assumed at the end of the H264 stream, there is a NAL unit (such as filler data) after the last picture:
If there are no such filler data NAL unit, it will return NEED_MORE_DATA.
This in turn caused m_codecInfo[minDtsIndex].m_lastAVRez to be changed:
metaDemuxer has already had m_isEOF set to 1 because all bytes of the H264 stream has been read. Having m_lastAVRez set to NEED_MORE_DATA will cause StreamInfo::read() to return DATA_EOF2:
This will cause MetaDemuxer to flush packet METADemuxer::readPacket():
When flushPacket is called, PTS changed:
When PTS changes, PES packet will be flushed in TSMuxer::muxPacket():
Since the last picture has not been muxed yet, another PES will be created. Outcome will be like this: For the last picture, two PES will be created. One contains the NAL units enclosed by the red circle; another contains the NAL units enclosed by the gray circle:![image](https://user-images.githubusercontent.com/13163487/182061069-aa6f9c9e-f6ef-4f26-9e81-a0bfb542fa45.png)
Workaround to this problem seems to be always adding filler data to the end of the H264 stream.