diff mbox

[FFmpeg-devel] lavf/mov: strip com.apple.quicktime prefix in meta; parse creation date

Message ID 20160910010711.68472-1-rodger.combs@gmail.com
State Withdrawn, archived
Headers show

Commit Message

Rodger Combs Sept. 10, 2016, 1:07 a.m. UTC
---
 libavformat/mov.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 54530e3..103927b 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -42,6 +42,7 @@ 
 #include "libavutil/aes_ctr.h"
 #include "libavutil/sha.h"
 #include "libavutil/timecode.h"
+#include "libavutil/parseutils.h"
 #include "libavcodec/ac3tab.h"
 #include "libavcodec/mpegaudiodecheader.h"
 #include "avformat.h"
@@ -476,6 +477,28 @@  retry:
                 return ret;
             }
             str[str_size] = 0;
+            if (!strcmp(key, "com.apple.quicktime.creationdate")) {
+                struct tm *ptm, tmbuf;
+                int64_t timeval;
+                if (av_parse_time(&timeval, str, 0) >= 0) {
+                    time_t timet = timeval / 1000000;
+                    if (ptm = gmtime_r(&timet, &tmbuf)) {
+                        if (str_size < 29) {
+                            av_free(str);
+                            str = av_malloc(29);
+                            if (!str)
+                                return AVERROR(ENOMEM);
+                        }
+                        strftime(str, str_size, "%Y-%m-%dT%H:%M:%S", ptm);
+                        av_strlcatf(str, str_size, ".%06dZ", (int)(timeval % 1000000));
+                        key = "creation_time";
+                    }
+                }
+            } else if (!strcmp(key, "com.apple.quicktime.location.ISO6709")) {
+                key = "location";
+            } else if (!strncmp(key, "com.apple.quicktime.", 20)) {
+                key += 20;
+            }
         }
         c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
         av_dict_set(&c->fc->metadata, key, str, 0);