@@ -6402,12 +6402,25 @@ static int mov_init(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
AVDictionaryEntry *t = global_tcr;
+ AVTimecode tc;
+ uint32_t *tc_sd = (uint32_t *)av_stream_get_side_data(st, AV_PKT_DATA_S12M_TIMECODE,
+ NULL);
+
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
(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++;
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && tc_sd) {
+ char tcbuf[AV_TIMECODE_STR_SIZE];
+ int m = tc_sd[0] & 3;
+ if ( m > 0) {
+ /* use the first timecode if more than one TC */
+ av_timecode_make_smpte_tc_string(tcbuf, tc_sd[1], 0);
+ ret = mov_check_timecode_track(s, &tc, i, tcbuf);
+ if (ret >= 0)
+ mov->nb_meta_tmcd++;
+ }
}
}
@@ -6724,12 +6737,27 @@ static int mov_write_header(AVFormatContext *s)
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
AVTimecode tc;
+ uint32_t *tc_sd = (uint32_t *)av_stream_get_side_data(st, AV_PKT_DATA_S12M_TIMECODE,
+ NULL);
if (!t)
t = av_dict_get(st->metadata, "timecode", NULL, 0);
- if (!t)
- continue;
- if (mov_check_timecode_track(s, &tc, i, t->value) < 0)
+ if (t) {
+ if (mov_check_timecode_track(s, &tc, i, t->value) < 0)
+ continue;
+ } else if (tc_sd) {
+ char tcbuf[AV_TIMECODE_STR_SIZE];
+ int m = tc_sd[0] & 3;
+ if ( m < 1)
+ continue;
+
+ /* use the first timecode if more than one */
+ av_timecode_make_smpte_tc_string(tcbuf, tc_sd[1], 0);
+ ret = mov_check_timecode_track(s, &tc, i, tcbuf);
+ if (ret < 0)
+ continue;
+ } else
continue;
+
if ((ret = mov_create_timecode_track(s, tmcd_track, i, tc)) < 0)
return ret;
tmcd_track++;