[FFmpeg-devel] lavf/llvdec: Set avg_frame_rate for video streams

Submitted by Steven Liu on Nov. 24, 2016, 11:31 a.m.

Details

Message ID CADxeRwnU8+q358_qV++F4=1RADYo9MxWGtwv_umMx5v+ZVAGLg@mail.gmail.com
State New
Headers show

Commit Message

Steven Liu Nov. 24, 2016, 11:31 a.m.
2016-11-24 18:53 GMT+08:00 Carl Eugen Hoyos <cehoyos@ag.or.at>:

> Hi!
>
> Attached patch sets average framerate from the flv metadata.
>
> Please comment, Carl Eugen
>
> From 20ea87fe9969a56d0630372705c9ce974c60939e Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos@ag.or.at>
Date: Thu, 24 Nov 2016 11:50:51 +0100
Subject: [PATCH] lavf/flvdec: Set avg_frame_rate for video streams.

---
 libavformat/flvdec.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

     avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
@@ -545,6 +548,10 @@ static int amf_parse_object(AVFormatContext *s,
AVStream *astream,
                     if (!st)
                         return AVERROR(ENOMEM);
                     st->codecpar->codec_id = AV_CODEC_ID_TEXT;
+                } else if (!strcmp(key, "framerate")) {
+                    flv->framerate = av_d2q(num_val, 1000);
+                    if (vstream)
+                        vstream->avg_frame_rate = flv->framerate;
                 } else if (flv->trust_metadata) {
                     if (!strcmp(key, "videocodecid") && vpar) {
                         flv_set_video_codec(s, vstream, num_val, 0);
--

1.7.10.4


LGTM,

Thanks

> _______________________________________________
> 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..46c9618 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -67,6 +67,7 @@  typedef struct FLVContext {
     int64_t *keyframe_times;
     int64_t *keyframe_filepositions;
     int missing_streams;
+    AVRational framerate;
 } FLVContext;

 static int probe(AVProbeData *p, int live)
@@ -142,8 +143,10 @@  static AVStream *create_stream(AVFormatContext
*s, int codec_type)
         s->ctx_flags &= ~AVFMTCTX_NOHEADER;
     if (codec_type == AVMEDIA_TYPE_AUDIO)
         flv->missing_streams &= ~FLV_HEADER_FLAG_HASAUDIO;
-    if (codec_type == AVMEDIA_TYPE_VIDEO)
+    if (codec_type == AVMEDIA_TYPE_VIDEO) {
         flv->missing_streams &= ~FLV_HEADER_FLAG_HASVIDEO;
+        st->avg_frame_rate = flv->framerate;
+    }