aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2016-02-04 03:28:19 +0100
committerMarton Balint <cus@passwd.hu>2016-02-14 01:51:14 +0100
commite942454daf050047142147f75743d1bb6b98d911 (patch)
tree26198ff620cb32bb4c91361a125b3d14d9f7027e /libavformat/utils.c
parentf834f0cab60f764664a78bad71aec8374e45876e (diff)
downloadffmpeg-e942454daf050047142147f75743d1bb6b98d911.tar.gz
avformat/utils: add ff_parse_creation_time_metadata
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index ef9ea93aaa..cf4124a270 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4751,3 +4751,20 @@ void ff_format_io_close(AVFormatContext *s, AVIOContext **pb)
s->io_close(s, *pb);
*pb = NULL;
}
+
+int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds)
+{
+ AVDictionaryEntry *entry;
+ int64_t parsed_timestamp;
+ int ret;
+ if ((entry = av_dict_get(s->metadata, "creation_time", NULL, 0))) {
+ if ((ret = av_parse_time(&parsed_timestamp, entry->value, 0)) >= 0) {
+ *timestamp = return_seconds ? parsed_timestamp / 1000000 : parsed_timestamp;
+ return 1;
+ } else {
+ av_log(s, AV_LOG_WARNING, "Failed to parse creation_time %s\n", entry->value);
+ return ret;
+ }
+ }
+ return 0;
+}