From: Limin Wang <lance.lmw...@gmail.com> Please test with below command: ./ffmpeg -export_side_data s12m_tc -i ../fate-suite/h264/crew_cif_timecode-2.h264 out.mp4
Signed-off-by: Limin Wang <lance.lmw...@gmail.com> --- libavformat/movenc.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 7db2e28..ca2c8a1 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -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++; -- 1.8.3.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".