From e3fb5bc1472c600af628df10e1472a4319781640 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 2 Oct 2012 00:41:40 +0200 Subject: nut: store and read the r_frame_rate With this, when we use a finer timebase than neccessary to store durations the demuxer still knows what the original timebase was. Signed-off-by: Michael Niedermayer --- libavformat/nutdec.c | 6 ++++++ libavformat/nutenc.c | 5 +++++ 2 files changed, 11 insertions(+) (limited to 'libavformat') diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index d6732b2..d9d115d 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -510,6 +510,12 @@ static int decode_info_header(NUTContext *nut) set_disposition_bits(s, str_value, stream_id_plus1 - 1); continue; } + + if (stream_id_plus1 && !strcmp(name, "r_frame_rate")) { + sscanf(str_value, "%d/%d", &st->r_frame_rate.num, &st->r_frame_rate.den); + continue; + } + if (metadata && av_strcasecmp(name, "Uses") && av_strcasecmp(name, "Depends") && av_strcasecmp(name, "Replaces")) av_dict_set(metadata, name, str_value, 0); diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 955a6fb..5133ade 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -485,6 +485,11 @@ static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id){ if (st->disposition & ff_nut_dispositions[i].flag) count += add_info(dyn_bc, "Disposition", ff_nut_dispositions[i].str); } + if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + uint8_t buf[256]; + snprintf(buf, sizeof(buf), "%d/%d", st->codec->time_base.den, st->codec->time_base.num); + count += add_info(dyn_bc, "r_frame_rate", buf); + } dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf); if (count) { -- cgit v1.1