diff mbox series

[FFmpeg-devel] libavformat/mov: Expose Quicktime poster_time value as metadata TAG.

Message ID pull.21.ffstaging.FFmpeg.1643844144096.ffmpegagent@gmail.com
State New
Headers show
Series [FFmpeg-devel] libavformat/mov: Expose Quicktime poster_time value as metadata TAG. | expand

Checks

Context Check Description
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

softworkz Feb. 2, 2022, 11:22 p.m. UTC
From: Bryce Chester Newman <bryce.newman@gettyimages.com>

I need the ability to derive the poster time found in the mvhd, so I can
use that value to create a thumbnail from ffmpeg. More details can be
found here
https://www.mail-archive.com/ffmpeg-user@ffmpeg.org/msg30003.html

Signed-off-by: Bryce Chester Newman <bryce.newman@gettyimages.com>
---
    libavformat/mov: Expose Quicktime poster_time value as metadata TAG.
    
    I need the ability to derive the poster time found in the mvhd, so I can
    use that value to create a thumbnail from ffmpeg. More details can be
    found here
    https://www.mail-archive.com/ffmpeg-user@ffmpeg.org/msg30003.html
    
    Signed-off-by: Bryce Chester Newman bryce.newman@gettyimages.com

Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-21%2Fbrycechesternewman%2Fpatch-poster-time-tag-v1
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-21/brycechesternewman/patch-poster-time-tag-v1
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/21

 libavformat/mov.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)


base-commit: 2e82c610553efd69b4d9b6c359423a19c2868255
diff mbox series

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index a80fcc1606..3d36f6563f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1487,6 +1487,7 @@  static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
     int i;
     int64_t creation_time;
+    int32_t poster_time;
     int version = avio_r8(pb); /* version */
     avio_rb24(pb); /* flags */
 
@@ -1525,12 +1526,21 @@  static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     avio_rb32(pb); /* preview time */
     avio_rb32(pb); /* preview duration */
-    avio_rb32(pb); /* poster time */
+    poster_time = avio_rb32(pb); /* poster time */
     avio_rb32(pb); /* selection time */
     avio_rb32(pb); /* selection duration */
     avio_rb32(pb); /* current time */
     avio_rb32(pb); /* next track ID */
 
+    av_log(c->fc, AV_LOG_TRACE, "poster_time = %i, time_scale = %i\n", poster_time, c->time_scale);
+    if(poster_time && c->time_scale && c->time_scale > 0) {
+        char buffer[32];
+        float poster_time_location = (float)poster_time / c->time_scale;
+        snprintf(buffer, sizeof(buffer), "%.2f", poster_time_location);
+        /* This will appear as a TAG in the format section of FFProbe output using -show_format */
+        av_dict_set(&c->fc->metadata, "poster_time", buffer, 0);
+    }
+
     return 0;
 }