[FFmpeg-devel] [PATCH 6/6] avformat/dv: use the stream s12m side data for timecode track if avaiable

lance.lmwang at gmail.com lance.lmwang at gmail.com
Wed Jul 15 02:30:02 EEST 2020


From: Limin Wang <lance.lmwang at gmail.com>

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
 libavformat/dvenc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index b04d604..b5fea8f 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -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);
 }
 
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list