diff mbox series

[FFmpeg-devel,3/4] avcodec/h264_slice: add timecode metadata

Message ID 1593700407-32390-3-git-send-email-lance.lmwang@gmail.com
State Accepted
Commit 10c7745ae9bcd74e1be76acd58583510bc1d93d7
Headers show
Series [FFmpeg-devel,1/4] avcodec/hevcdec: add timecode metadata | expand

Checks

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

Commit Message

Lance Wang July 2, 2020, 2:33 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Please test with below command:
./ffplay -vf drawtext="fontfile=/Library/Fonts/Arial.ttf:text=\\'%{metadata\\:timecode}\\'" \
                       ../fate-suite/h264/crew_cif_timecode-2.h264

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

Patch

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 725390e..c7b2764 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1306,6 +1306,7 @@  static int h264_export_frame_props(H264Context *h)
 
     if (h->sei.picture_timing.timecode_cnt > 0) {
         uint32_t *tc_sd;
+        char tcbuf[AV_TIMECODE_STR_SIZE];
 
         AVFrameSideData *tcside = av_frame_new_side_data(out,
                                                          AV_FRAME_DATA_S12M_TIMECODE,
@@ -1324,6 +1325,8 @@  static int h264_export_frame_props(H264Context *h)
             int   ff = h->sei.picture_timing.timecode[i].frame;
 
             tc_sd[i + 1] = av_timecode_get_smpte(h->avctx->framerate, drop, hh, mm, ss, ff);
+            av_timecode_make_smpte_tc_string(tcbuf, tc_sd[i + 1], 0);
+            av_dict_set(&out->metadata, "timecode", tcbuf, 0);
         }
         h->sei.picture_timing.timecode_cnt = 0;
     }