diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-07-07 11:25:03 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2011-07-12 15:30:10 +0200 |
commit | 5f847bf61dca1fd1a2f65a2f56c9a99d1cb716ab (patch) | |
tree | c6efb65d184923aa8b5e2eaa87336a59bdec4a1f /libavformat | |
parent | b12c2592525c3d8e12265a3d923a945d6f699a5b (diff) | |
download | ffmpeg-5f847bf61dca1fd1a2f65a2f56c9a99d1cb716ab.tar.gz |
lavf: deprecate AVFormatContext.timestamp
It's replaced by 'creation_time' metadata tag.
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/avformat.h | 7 | ||||
-rw-r--r-- | libavformat/dvenc.c | 14 | ||||
-rw-r--r-- | libavformat/gxfenc.c | 18 | ||||
-rw-r--r-- | libavformat/movenc.c | 14 | ||||
-rw-r--r-- | libavformat/mxfenc.c | 14 | ||||
-rw-r--r-- | libavformat/version.h | 3 |
6 files changed, 63 insertions, 7 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 6e861de262..38bb86592e 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -674,7 +674,12 @@ typedef struct AVFormatContext { AVStream **streams; char filename[1024]; /**< input or output filename */ /* stream info */ - int64_t timestamp; +#if FF_API_TIMESTAMP + /** + * @deprecated use 'creation_time' metadata tag instead + */ + attribute_deprecated int64_t timestamp; +#endif int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */ /* private data for pts handling (do not modify directly). */ diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index 504e3ee26f..1e59bd9cc7 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -43,7 +43,7 @@ struct DVMuxContext { AVStream *ast[2]; /* stereo audio streams */ AVFifoBuffer *audio_data[2]; /* FIFO for storing excessive amounts of PCM */ int frames; /* current frame number */ - time_t start_time; /* recording start time */ + int64_t start_time; /* recording start time */ int has_audio; /* frame under contruction has audio */ int has_video; /* frame under contruction has video */ uint8_t frame_buf[DV_MAX_FRAME_SIZE]; /* frame under contruction */ @@ -290,6 +290,7 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) { DVMuxContext *c = s->priv_data; AVStream *vst = NULL; + AVDictionaryEntry *t; int i; /* we support at most 1 video and 2 audio streams */ @@ -337,7 +338,16 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) c->frames = 0; c->has_audio = 0; c->has_video = 0; - c->start_time = (time_t)s->timestamp; +#if FF_API_TIMESTAMP + if (s->timestamp) + c->start_time = s->timestamp; + else +#endif + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { + struct tm time = {0}; + strptime(t->value, "%Y - %m - %dT%T", &time); + c->start_time = mktime(&time); + } for (i=0; i < c->n_ast; i++) { if (c->ast[i] && !(c->audio_data[i]=av_fifo_alloc(100*AVCODEC_MAX_AUDIO_FRAME_SIZE))) { diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 5a3ff39ab2..2d4136ab86 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -394,6 +394,20 @@ static int gxf_write_umf_material_description(AVFormatContext *s) GXFContext *gxf = s->priv_data; AVIOContext *pb = s->pb; int timecode_base = gxf->time_base.den == 60000 ? 60 : 50; + int64_t timestamp = 0; + AVDictionaryEntry *t; + +#if FF_API_TIMESTAMP + if (s->timestamp) + timestamp = s->timestamp; + else +#endif + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { + struct tm time = {0}; + strptime(t->value, "%Y - %m - %dT%T", &time); + timestamp = mktime(&time); + } + // XXX drop frame uint32_t timecode = @@ -409,8 +423,8 @@ static int gxf_write_umf_material_description(AVFormatContext *s) avio_wl32(pb, gxf->nb_fields); /* mark out */ avio_wl32(pb, 0); /* timecode mark in */ avio_wl32(pb, timecode); /* timecode mark out */ - avio_wl64(pb, s->timestamp); /* modification time */ - avio_wl64(pb, s->timestamp); /* creation time */ + avio_wl64(pb, timestamp); /* modification time */ + avio_wl64(pb, timestamp); /* creation time */ avio_wl16(pb, 0); /* reserved */ avio_wl16(pb, 0); /* reserved */ avio_wl16(pb, gxf->audio_tracks); diff --git a/libavformat/movenc.c b/libavformat/movenc.c index ae6f603e86..78e5db7444 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2129,6 +2129,7 @@ static int mov_write_header(AVFormatContext *s) { AVIOContext *pb = s->pb; MOVMuxContext *mov = s->priv_data; + AVDictionaryEntry *t; int i, hint_track = 0; if (!s->pb->seekable) { @@ -2259,7 +2260,18 @@ static int mov_write_header(AVFormatContext *s) } mov_write_mdat_tag(pb, mov); - mov->time = s->timestamp + 0x7C25B080; //1970 based -> 1904 based + +#if FF_API_TIMESTAMP + if (s->timestamp) + mov->time = s->timestamp; + else +#endif + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { + struct tm time = {0}; + strptime(t->value, "%Y - %m - %dT%T", &time); + mov->time = mktime(&time); + } + mov->time += 0x7C25B080; //1970 based -> 1904 based if (mov->chapter_track) mov_create_chapter_track(s, mov->chapter_track); diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 16fa0dadd1..d7cc5c1c67 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1407,6 +1407,8 @@ static int mxf_write_header(AVFormatContext *s) int i; uint8_t present[FF_ARRAY_ELEMS(mxf_essence_container_uls)] = {0}; const int *samples_per_frame = NULL; + AVDictionaryEntry *t; + int64_t timestamp = 0; if (!s->nb_streams) return -1; @@ -1512,8 +1514,18 @@ static int mxf_write_header(AVFormatContext *s) sc->order = AV_RB32(sc->track_essence_element_key+12); } +#if FF_API_TIMESTAMP if (s->timestamp) - mxf->timestamp = mxf_parse_timestamp(s->timestamp); + timestamp = s->timestamp; + else +#endif + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) { + struct tm time = {0}; + strptime(t->value, "%Y - %m - %dT%T", &time); + timestamp = mktime(&time); + } + if (timestamp) + mxf->timestamp = mxf_parse_timestamp(timestamp); mxf->duration = -1; mxf->timecode_track = av_mallocz(sizeof(*mxf->timecode_track)); diff --git a/libavformat/version.h b/libavformat/version.h index 18331fc7d1..cae0339f62 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -83,5 +83,8 @@ #ifndef FF_API_LOOP_OUTPUT #define FF_API_LOOP_OUTPUT (LIBAVFORMAT_VERSION_MAJOR < 54) #endif +#ifndef FF_API_TIMESTAMP +#define FF_API_TIMESTAMP (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif #endif /* AVFORMAT_VERSION_H */ |