lavf: deprecate AVFormatContext.timestamp

It's replaced by 'creation_time' metadata tag.
pull/2/head
Anton Khirnov 14 years ago
parent b12c259252
commit 5f847bf61d
  1. 15
      ffmpeg.c
  2. 7
      libavformat/avformat.h
  3. 14
      libavformat/dvenc.c
  4. 18
      libavformat/gxfenc.c
  5. 14
      libavformat/movenc.c
  6. 14
      libavformat/mxfenc.c
  7. 3
      libavformat/version.h

@ -183,7 +183,6 @@ static float mux_max_delay= 0.7;
static int64_t recording_time = INT64_MAX;
static int64_t start_time = 0;
static int64_t recording_timestamp = 0;
static int64_t input_ts_offset = 0;
static int file_overwrite = 0;
static AVDictionary *metadata;
@ -712,9 +711,6 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename)
nopts = 1;
}
if (!nopts)
s->timestamp = av_gettime();
av_close_input_file(ic);
return 0;
}
@ -3109,7 +3105,14 @@ static int opt_start_time(const char *opt, const char *arg)
static int opt_recording_timestamp(const char *opt, const char *arg)
{
recording_timestamp = parse_time_or_die(opt, arg, 0) / 1000000;
char buf[128];
int64_t recording_timestamp = parse_time_or_die(opt, arg, 0) / 1E6;
struct tm time = *gmtime((time_t*)&recording_timestamp);
strftime(buf, sizeof(buf), "creation_time=%FT%T%z", &time);
opt_metadata("metadata", buf);
av_log(NULL, AV_LOG_WARNING, "%s is deprecated, set the 'creation_time' metadata "
"tag instead.\n", opt);
return 0;
}
@ -3823,8 +3826,6 @@ static void opt_output_file(const char *filename)
if (use_subtitle) new_subtitle_stream(oc, nb_output_files);
if (use_data) new_data_stream(oc, nb_output_files);
oc->timestamp = recording_timestamp;
av_dict_copy(&oc->metadata, metadata, 0);
av_dict_free(&metadata);
}

@ -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). */

@ -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))) {

@ -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);

@ -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);

@ -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));

@ -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 */

Loading…
Cancel
Save