[FFmpeg-devel] avformat/flvdec: move set bit_rate from parse AMF OBJECT to create_stream

Submitted by Steven Liu on Nov. 25, 2016, 9:18 a.m.

Details

Message ID 20161125091843.30594-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Steven Liu Nov. 25, 2016, 9:18 a.m.
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>
---
 libavformat/flvdec.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

Comments

Michael Niedermayer Nov. 25, 2016, 6:49 p.m.
On Fri, Nov 25, 2016 at 05:18:43PM +0800, Steven Liu wrote:
> 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>
> ---
>  libavformat/flvdec.c | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)

probably ok

[...]
Steven Liu Nov. 26, 2016, 1:20 a.m.
2016-11-26 2:49 GMT+08:00 Michael Niedermayer <michael@niedermayer.cc>:

> On Fri, Nov 25, 2016 at 05:18:43PM +0800, Steven Liu wrote:
> > 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>
> > ---
> >  libavformat/flvdec.c | 19 ++++++++++++-------
> >  1 file changed, 12 insertions(+), 7 deletions(-)
>
> probably ok
>
> pushed, Thanks!

> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> The real ebay dictionary, page 1
> "Used only once"    - "Some unspecified defect prevented a second use"
> "In good condition" - "Can be repaird by experienced expert"
> "As is" - "You wouldnt want it even if you were payed for it, if you knew
> ..."
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>

Patch hide | download patch | download mbox

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 3812994..a04280d 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;
@@ -140,11 +142,14 @@  static AVStream *create_stream(AVFormatContext *s, int codec_type)
                            && s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE
                            && s->streams[1]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE))
         s->ctx_flags &= ~AVFMTCTX_NOHEADER;
-    if (codec_type == AVMEDIA_TYPE_AUDIO)
+    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)
+    }
+    if (codec_type == AVMEDIA_TYPE_VIDEO) {
+        st->codecpar->bit_rate = flv->video_bit_rate;
         flv->missing_streams &= ~FLV_HEADER_FLAG_HASVIDEO;
-
+    }
 
     avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
     flv->last_keyframe_stream_index = s->nb_streams - 1;
@@ -534,12 +539,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)