aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2010-11-21 19:02:52 +0000
committerAurelien Jacobs <aurel@gnuage.org>2010-11-21 19:02:52 +0000
commit7df2214328d2b450877294e1fd1c4bf5bd8c022c (patch)
tree602ab42911934dc8e6d374f072130bb44fba546f /libavformat
parent933875a0f59f71ed46a7948c86dab59ff5cbdcfd (diff)
downloadffmpeg-7df2214328d2b450877294e1fd1c4bf5bd8c022c.tar.gz
movdec: export creation_date as metadata
Originally committed as revision 25786 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mov.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index fcf7d94daf..cdaf6d36ba 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -663,6 +663,16 @@ static int mov_read_moof(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return mov_read_default(c, pb, atom);
}
+static void mov_metadata_creation_time(AVMetadata **metadata, time_t time)
+{
+ char buffer[32];
+ if (time) {
+ time -= 2082844800; /* seconds between 1904-01-01 and Epoch */
+ strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", gmtime(&time));
+ av_metadata_set2(metadata, "creation_time", buffer, 0);
+ }
+}
+
static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st;
@@ -670,6 +680,7 @@ static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
int version;
char language[4] = {0};
unsigned lang;
+ time_t creation_time;
if (c->fc->nb_streams < 1)
return 0;
@@ -682,12 +693,13 @@ static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
get_be24(pb); /* flags */
if (version == 1) {
- get_be64(pb);
+ creation_time = get_be64(pb);
get_be64(pb);
} else {
- get_be32(pb); /* creation time */
+ creation_time = get_be32(pb);
get_be32(pb); /* modification time */
}
+ mov_metadata_creation_time(&st->metadata, creation_time);
sc->time_scale = get_be32(pb);
st->duration = (version == 1) ? get_be64(pb) : get_be32(pb); /* duration */
@@ -702,16 +714,18 @@ static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
static int mov_read_mvhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
+ time_t creation_time;
int version = get_byte(pb); /* version */
get_be24(pb); /* flags */
if (version == 1) {
- get_be64(pb);
+ creation_time = get_be64(pb);
get_be64(pb);
} else {
- get_be32(pb); /* creation time */
+ creation_time = get_be32(pb);
get_be32(pb); /* modification time */
}
+ mov_metadata_creation_time(&c->fc->metadata, creation_time);
c->time_scale = get_be32(pb); /* time scale */
dprintf(c->fc, "time scale = %i\n", c->time_scale);