[FFmpeg-devel] [PATCH] mov_read_mvhd: Expose Quicktime poster_time value as metadata TAG.

Bryce Newman bryce.newman at gettyimages.com
Tue Dec 14 01:24:16 EET 2021


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 at gettyimages.com<mailto:bryce.newman at gettyimages.com>>
---
libavformat/mov.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 9ebfa0bcc7..67aaeba72a 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1484,6 +1484,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 */

@@ -1522,12 +1523,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;
}

--
2.34.1
    
    

Bryce Chester Newman | Principal Developer
 
p: +12069255045 | 



-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0.png
Type: image/png
Size: 2684 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20211213/67043c71/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1.png
Type: image/png
Size: 2260 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20211213/67043c71/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2.png
Type: image/png
Size: 2256 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20211213/67043c71/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 3.png
Type: image/png
Size: 7110 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20211213/67043c71/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4.jpg
Type: image/jpeg
Size: 9066 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20211213/67043c71/attachment.jpg>


More information about the ffmpeg-devel mailing list