[FFmpeg-devel] [PATCH] libavformat: Add poster_time and time_scale to quicktime metadata output

Graham Torn graham.torn at gmail.com
Thu Aug 14 21:24:37 CEST 2014


From: gt-sdi <gtorn at straylightdigital.com>

Extract poster_time and time_scale from quicktime mdhd atom
and add to metadata for output by ffprobe.

Signed-off-by: gt-sdi <gtorn at straylightdigital.com>
---
 libavformat/mov.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 767833e..b49592b 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -850,9 +850,28 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     return 0;
 }
 
+static void mov_metadata_time_scale(AVDictionary **metadata, int time)
+{
+    char buffer[32];
+    if (time) {
+        snprintf(buffer, sizeof(buffer), "%i", time);
+        av_dict_set(metadata, "time_scale", buffer, 0);
+    }
+}
+
+static void mov_metadata_poster_time(AVDictionary **metadata, int64_t time)
+{
+    char buffer[32];
+    if (time) {
+        snprintf(buffer, sizeof(buffer), "%" PRId64, time);
+        av_dict_set(metadata, "poster_time", buffer, 0);
+    }
+}
+
 static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
     int64_t creation_time;
+    int64_t poster_time;
     int version = avio_r8(pb); /* version */
     avio_rb24(pb); /* flags */
 
@@ -864,8 +883,9 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         avio_rb32(pb); /* modification time */
     }
     mov_metadata_creation_time(&c->fc->metadata, creation_time);
-    c->time_scale = avio_rb32(pb); /* time scale */
 
+    c->time_scale = avio_rb32(pb); /* time scale */
+    mov_metadata_time_scale(&c->fc->metadata, c->time_scale);
     av_dlog(c->fc, "time scale = %i\n", c->time_scale);
 
     c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
@@ -883,7 +903,10 @@ 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 */
+    mov_metadata_poster_time(&c->fc->metadata, poster_time);
+
     avio_rb32(pb); /* selection time */
     avio_rb32(pb); /* selection duration */
     avio_rb32(pb); /* current time */
-- 
2.0.4



More information about the ffmpeg-devel mailing list