aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2010-03-08 23:59:05 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2010-03-08 23:59:05 +0000
commite17d77bb674879505f9f438e610441e1834fb908 (patch)
tree15c52510f1fd209e1ded4280c257831a0c1d70ec /libavformat
parentf4495cdc00d7ff5d23255fc333de5881151121e7 (diff)
downloadffmpeg-e17d77bb674879505f9f438e610441e1834fb908.tar.gz
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. Originally committed as revision 22354 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mpegtsenc.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 6389ee50bc..64e6fddcf0 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -783,11 +783,22 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
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;