[FFmpeg-cvslog] r22354 - trunk/libavformat/mpegtsenc.c
bcoudurier
subversion
Tue Mar 9 00:59:05 CET 2010
Author: bcoudurier
Date: Tue Mar 9 00:59:05 2010
New Revision: 22354
Log:
In mpegts muxer, search for h264 aud nal, it might not be the first nal.
Improve ther error message when bitstream is malformated and tell user to use
the bitstream filter.
Modified:
trunk/libavformat/mpegtsenc.c
Modified: trunk/libavformat/mpegtsenc.c
==============================================================================
--- trunk/libavformat/mpegtsenc.c Tue Mar 9 00:51:53 2010 (r22353)
+++ trunk/libavformat/mpegtsenc.c Tue Mar 9 00:59:05 2010 (r22354)
@@ -783,11 +783,22 @@ static int mpegts_write_packet(AVFormatC
ts_st->first_pts_check = 0;
if (st->codec->codec_id == CODEC_ID_H264) {
+ const uint8_t *p = buf, *buf_end = p+size;
+ uint32_t state = -1;
+
if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) {
- av_log(s, AV_LOG_ERROR, "h264 bitstream malformated\n");
+ av_log(s, AV_LOG_ERROR, "h264 bitstream malformated, "
+ "no startcode found, use -vbsf h264_mp4toannexb\n");
return -1;
}
- if (pkt->data[4] != 0x09) { // AUD NAL
+
+ do {
+ p = ff_find_start_code(p, buf_end, &state);
+ //av_log(s, AV_LOG_INFO, "nal %d\n", state & 0x1f);
+ } while (p < buf_end && (state & 0x1f) != 9 &&
+ (state & 0x1f) != 5 && (state & 0x1f) != 1);
+
+ if ((state & 0x1f) != 9) { // AUD NAL
data = av_malloc(pkt->size+6);
if (!data)
return -1;
More information about the ffmpeg-cvslog
mailing list