@@ -396,6 +396,18 @@ static int dv_write_header(AVFormatContext *s)
}
if (tcr && av_timecode_init_from_string(&dvc->tc, rate, tcr->value, s) >= 0)
return 0;
+
+ for (int i = 0; i < s->nb_streams; i++) {
+ uint32_t *sd = (uint32_t *)av_stream_get_side_data(s->streams[i],
+ AV_PKT_DATA_S12M_TIMECODE, NULL);
+ if (sd && sd[0] > 0) {
+ char tcbuf[AV_TIMECODE_STR_SIZE];
+ /* use the first timecode */
+ av_timecode_make_smpte_tc_string(tcbuf, sd[1], 0);
+ return av_timecode_init_from_string(&dvc->tc, rate, tcbuf, s);
+ }
+ }
+
return av_timecode_init(&dvc->tc, rate, 0, 0, s);
}