diff mbox series

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

Message ID 1594769402-22526-6-git-send-email-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/6] avcodec: add AV_CODEC_EXPORT_DATA_S12M_TC flag to export S12M timecode
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Limin Wang July 14, 2020, 11:30 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

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

Patch

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);
 }