summaryrefslogtreecommitdiff
path: root/libavformat/dvenc.c
diff options
context:
space:
mode:
authorClément Bœsch <clement.boesch@smartjog.com>2012-05-30 10:26:53 +0200
committerClément Bœsch <ubitux@gmail.com>2012-06-04 07:41:22 +0200
commit6b35f1a2a6432cb79f657ea3fadb86b8e12dddcb (patch)
tree372b3d3ee1664494f32d1b518caf54fb9c4dd20b /libavformat/dvenc.c
parent0f0f3bd1e022639eb8e9c02b7b18f37071c21763 (diff)
timecode: move timecode muxer options to metadata.
Some demuxers set a timecode in the format or streams metadata. The muxers now make use of this metadata instead of a duplicated private option. This makes possible transparent copy of the timecode when transmuxing and transcoding. -timecode option for MPEG1/2 codec is also renamed to -gop_timecode. The global ffmpeg -timecode option will set it anyway so no option change visible for the user.
Diffstat (limited to 'libavformat/dvenc.c')
-rw-r--r--libavformat/dvenc.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 506225e8eb..f3056f7892 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -52,7 +52,6 @@ struct DVMuxContext {
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 */
- char *tc_opt_str; /* timecode option string */
AVTimecode tc; /* timecode context */
};
@@ -356,6 +355,7 @@ static int dv_write_header(AVFormatContext *s)
{
AVRational rate;
DVMuxContext *dvc = s->priv_data;
+ AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
if (!dv_init_mux(s)) {
av_log(s, AV_LOG_ERROR, "Can't initialize DV format!\n"
@@ -366,9 +366,16 @@ static int dv_write_header(AVFormatContext *s)
}
rate.num = dvc->sys->ltc_divisor;
rate.den = 1;
- if (dvc->tc_opt_str)
- return av_timecode_init_from_string(&dvc->tc, rate,
- dvc->tc_opt_str, s);
+ if (!tcr) { // no global timecode, look into the streams
+ int i;
+ for (i = 0; i < s->nb_streams; i++) {
+ tcr = av_dict_get(s->streams[i]->metadata, "timecode", NULL, 0);
+ if (tcr)
+ break;
+ }
+ }
+ if (tcr)
+ return av_timecode_init_from_string(&dvc->tc, rate, tcr->value, s);
return av_timecode_init(&dvc->tc, rate, 0, 0, s);
}
@@ -398,16 +405,6 @@ static int dv_write_trailer(struct AVFormatContext *s)
return 0;
}
-static const AVClass class = {
- .class_name = "dv",
- .item_name = av_default_item_name,
- .version = LIBAVUTIL_VERSION_INT,
- .option = (const AVOption[]){
- {AV_TIMECODE_OPTION(DVMuxContext, tc_opt_str, AV_OPT_FLAG_ENCODING_PARAM)},
- {NULL},
- },
-};
-
AVOutputFormat ff_dv_muxer = {
.name = "dv",
.long_name = NULL_IF_CONFIG_SMALL("DV video format"),
@@ -418,5 +415,4 @@ AVOutputFormat ff_dv_muxer = {
.write_header = dv_write_header,
.write_packet = dv_write_packet,
.write_trailer = dv_write_trailer,
- .priv_class = &class,
};