From: Limin Wang <lance.lmw...@gmail.com>

Signed-off-by: Limin Wang <lance.lmw...@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

_______________________________________________
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".

Reply via email to