mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-27 21:40:34 +00:00
avformat: fix decoded creation_time timestamps
Use proper ISO 8601 timestamps which also signal that they are in UTC. This changes the format of creation_time and modification_date metadata values from 2016-06-01 22:30:00 to 2016-01-01T22:30:00.000000Z Fixes ticket #5673. Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
parent
fecf5ae9aa
commit
13b90ff2c1
@ -1691,13 +1691,8 @@ static int matroska_aac_sri(int samplerate)
|
||||
|
||||
static void matroska_metadata_creation_time(AVDictionary **metadata, int64_t date_utc)
|
||||
{
|
||||
char buffer[32];
|
||||
/* Convert to seconds and adjust by number of seconds between 2001-01-01 and Epoch */
|
||||
time_t creation_time = date_utc / 1000000000 + 978307200;
|
||||
struct tm tmpbuf, *ptm = gmtime_r(&creation_time, &tmpbuf);
|
||||
if (!ptm) return;
|
||||
if (strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ptm))
|
||||
av_dict_set(metadata, "creation_time", buffer, 0);
|
||||
avpriv_dict_set_timestamp(metadata, "creation_time", date_utc / 1000 + 978307200000000LL);
|
||||
}
|
||||
|
||||
static int matroska_parse_flac(AVFormatContext *s,
|
||||
|
@ -1156,17 +1156,10 @@ static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
|
||||
static void mov_metadata_creation_time(AVDictionary **metadata, int64_t time)
|
||||
{
|
||||
char buffer[32];
|
||||
if (time) {
|
||||
struct tm *ptm, tmbuf;
|
||||
time_t timet;
|
||||
if(time >= 2082844800)
|
||||
time -= 2082844800; /* seconds between 1904-01-01 and Epoch */
|
||||
timet = time;
|
||||
ptm = gmtime_r(&timet, &tmbuf);
|
||||
if (!ptm) return;
|
||||
if (strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ptm))
|
||||
av_dict_set(metadata, "creation_time", buffer, 0);
|
||||
avpriv_dict_set_timestamp(metadata, "creation_time", time * 1000000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "libavcodec/bytestream.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/parseutils.h"
|
||||
#include "libavutil/timecode.h"
|
||||
#include "avformat.h"
|
||||
#include "internal.h"
|
||||
@ -2159,7 +2160,7 @@ fail_and_free:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mxf_timestamp_to_str(uint64_t timestamp, char **str)
|
||||
static int64_t mxf_timestamp_to_int64(uint64_t timestamp)
|
||||
{
|
||||
struct tm time = { 0 };
|
||||
time.tm_year = (timestamp >> 48) - 1900;
|
||||
@ -2178,13 +2179,7 @@ static int mxf_timestamp_to_str(uint64_t timestamp, char **str)
|
||||
time.tm_min = av_clip(time.tm_min, 0, 59);
|
||||
time.tm_sec = av_clip(time.tm_sec, 0, 59);
|
||||
|
||||
*str = av_mallocz(32);
|
||||
if (!*str)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!strftime(*str, 32, "%Y-%m-%d %H:%M:%S", &time))
|
||||
(*str)[0] = '\0';
|
||||
|
||||
return 0;
|
||||
return (int64_t)av_timegm(&time) * 1000000;
|
||||
}
|
||||
|
||||
#define SET_STR_METADATA(pb, name, str) do { \
|
||||
@ -2202,9 +2197,8 @@ static int mxf_timestamp_to_str(uint64_t timestamp, char **str)
|
||||
|
||||
#define SET_TS_METADATA(pb, name, var, str) do { \
|
||||
var = avio_rb64(pb); \
|
||||
if ((ret = mxf_timestamp_to_str(var, &str)) < 0) \
|
||||
if ((ret = avpriv_dict_set_timestamp(&s->metadata, name, mxf_timestamp_to_int64(var)) < 0)) \
|
||||
return ret; \
|
||||
av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
|
||||
} while (0)
|
||||
|
||||
static int mxf_read_identification_metadata(void *arg, AVIOContext *pb, int tag, int size, UID _uid, int64_t klv_offset)
|
||||
|
@ -33,7 +33,7 @@
|
||||
// Also please add any ticket numbers that you believe might be affected here
|
||||
#define LIBAVFORMAT_VERSION_MAJOR 57
|
||||
#define LIBAVFORMAT_VERSION_MINOR 48
|
||||
#define LIBAVFORMAT_VERSION_MICRO 100
|
||||
#define LIBAVFORMAT_VERSION_MICRO 101
|
||||
|
||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||
LIBAVFORMAT_VERSION_MINOR, \
|
||||
|
Loading…
Reference in New Issue
Block a user