diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2016-04-29 04:39:40 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-06-06 01:30:48 +0200 |
commit | 5a8b41b4a76fc6586ff6afff78e5f0aa7b25068a (patch) | |
tree | 1e28983fa88fb5e072eb34389e8b5e668b87f8cb | |
parent | abc957e896beb3ce33c5691b9b3701993a381852 (diff) | |
download | ffmpeg-5a8b41b4a76fc6586ff6afff78e5f0aa7b25068a.tar.gz |
avformat/movenc: Skip unsupported video tracks in timecode generation
Fixes Ticket5414
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/movenc.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index cb3a70a842..2f00091b63 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -4939,21 +4939,25 @@ static int mov_create_chapter_track(AVFormatContext *s, int tracknum) return 0; } -static int mov_create_timecode_track(AVFormatContext *s, int index, int src_index, const char *tcstr) + +static int mov_check_timecode_track(AVFormatContext *s, AVTimecode *tc, int src_index, const char *tcstr) +{ + int ret; + + /* compute the frame number */ + ret = av_timecode_init_from_string(tc, find_fps(s, s->streams[src_index]), tcstr, s); + return ret; +} + +static int mov_create_timecode_track(AVFormatContext *s, int index, int src_index, AVTimecode tc) { int ret; MOVMuxContext *mov = s->priv_data; MOVTrack *track = &mov->tracks[index]; AVStream *src_st = s->streams[src_index]; - AVTimecode tc; AVPacket pkt = {.stream_index = index, .flags = AV_PKT_FLAG_KEY, .size = 4}; AVRational rate = find_fps(s, src_st); - /* compute the frame number */ - ret = av_timecode_init_from_string(&tc, rate, tcstr, s); - if (ret < 0) - return ret; - /* tmcd track based on video stream */ track->mode = mov->mode; track->tag = MKTAG('t','m','c','d'); @@ -5242,9 +5246,14 @@ static int mov_write_header(AVFormatContext *s) /* +1 tmcd track for each video stream with a timecode */ for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; + t = global_tcr; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && - (global_tcr || av_dict_get(st->metadata, "timecode", NULL, 0))) - mov->nb_meta_tmcd++; + (t || (t=av_dict_get(st->metadata, "timecode", NULL, 0)))) { + AVTimecode tc; + ret = mov_check_timecode_track(s, &tc, i, t->value); + if (ret >= 0) + mov->nb_meta_tmcd++; + } } /* check if there is already a tmcd track to remux */ @@ -5509,11 +5518,14 @@ static int mov_write_header(AVFormatContext *s) t = global_tcr; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { + AVTimecode tc; if (!t) t = av_dict_get(st->metadata, "timecode", NULL, 0); if (!t) continue; - if ((ret = mov_create_timecode_track(s, tmcd_track, i, t->value)) < 0) + if (mov_check_timecode_track(s, &tc, i, t->value) < 0) + continue; + if ((ret = mov_create_timecode_track(s, tmcd_track, i, tc)) < 0) goto error; tmcd_track++; } |