summaryrefslogtreecommitdiff
path: root/libavformat/flvdec.c
diff options
context:
space:
mode:
authorSteven Liu <lq@chinaffmpeg.org>2016-11-26 08:56:18 +0800
committerSteven Liu <lq@chinaffmpeg.org>2016-11-26 08:56:18 +0800
commit7c5478a2035e4c0b6fcf3c597c745669ccb698e0 (patch)
tree04deb7de10b6b63a491dd1686ecc06991d16d1aa /libavformat/flvdec.c
parentee24c8ad011272ffd1a6daaf3f0128ace8663c18 (diff)
avformat/flvdec: move set bit_rate from parse AMF OBJECT to
create_stream before patch: Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x714 [SAR 1:1 DAR 640:357], 25 fps, 25 tbr, 1k tbn, 50 tbc after patch: Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x714 [SAR 1:1 DAR 640:357], 2576 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc Signed-off-by: Steven Liu <lq@chinaffmpeg.org> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/flvdec.c')
-rw-r--r--libavformat/flvdec.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 18645b042e..bf67fe4418 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -64,6 +64,8 @@ typedef struct FLVContext {
int last_keyframe_stream_index;
int keyframe_count;
+ int64_t video_bit_rate;
+ int64_t audio_bit_rate;
int64_t *keyframe_times;
int64_t *keyframe_filepositions;
int missing_streams;
@@ -142,8 +144,10 @@ static AVStream *create_stream(AVFormatContext *s, int codec_type)
&& s->streams[1]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE))
s->ctx_flags &= ~AVFMTCTX_NOHEADER;
if (codec_type == AVMEDIA_TYPE_AUDIO)
+ st->codecpar->bit_rate = flv->audio_bit_rate;
flv->missing_streams &= ~FLV_HEADER_FLAG_HASAUDIO;
if (codec_type == AVMEDIA_TYPE_VIDEO) {
+ st->codecpar->bit_rate = flv->video_bit_rate;
flv->missing_streams &= ~FLV_HEADER_FLAG_HASVIDEO;
st->avg_frame_rate = flv->framerate;
}
@@ -547,12 +551,12 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
amf_type == AMF_DATA_TYPE_BOOL) {
if (!strcmp(key, "duration"))
s->duration = num_val * AV_TIME_BASE;
- else if (!strcmp(key, "videodatarate") && vpar &&
+ else if (!strcmp(key, "videodatarate") &&
0 <= (int)(num_val * 1024.0))
- vpar->bit_rate = num_val * 1024.0;
- else if (!strcmp(key, "audiodatarate") && apar &&
+ flv->video_bit_rate = num_val * 1024.0;
+ else if (!strcmp(key, "audiodatarate") &&
0 <= (int)(num_val * 1024.0))
- apar->bit_rate = num_val * 1024.0;
+ flv->audio_bit_rate = num_val * 1024.0;
else if (!strcmp(key, "datastream")) {
AVStream *st = create_stream(s, AVMEDIA_TYPE_SUBTITLE);
if (!st)