From patchwork Thu Nov 24 10:53:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 1547 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp119763vsb; Thu, 24 Nov 2016 02:53:15 -0800 (PST) X-Received: by 10.28.91.143 with SMTP id p137mr1843288wmb.51.1479984795717; Thu, 24 Nov 2016 02:53:15 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f84si7481162wmi.127.2016.11.24.02.53.15; Thu, 24 Nov 2016 02:53:15 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CDF5B689A73; Thu, 24 Nov 2016 12:53:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe01-2.mx.upcmail.net (vie01a-dmta-pe01-2.mx.upcmail.net [62.179.121.155]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CDEED6891D4 for ; Thu, 24 Nov 2016 12:53:01 +0200 (EET) Received: from [172.31.216.44] (helo=vie01a-pemc-psmtp-pe02) by vie01a-dmta-pe01.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1c9reL-0008F1-AD for ffmpeg-devel@ffmpeg.org; Thu, 24 Nov 2016 11:53:05 +0100 Received: from [192.168.1.3] ([80.110.111.6]) by vie01a-pemc-psmtp-pe02 with SMTP @ mailcloud.upcmail.net id Bmt41u00c08KqZs01mt5cv; Thu, 24 Nov 2016 11:53:05 +0100 X-SourceIP: 80.110.111.6 From: Carl Eugen Hoyos To: FFmpeg development discussions and patches Date: Thu, 24 Nov 2016 11:53:04 +0100 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Message-Id: <201611241153.04051.cehoyos@ag.or.at> Subject: [FFmpeg-devel] [PATCH]lavf/llvdec: Set avg_frame_rate for video streams X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 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(-) 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; + } 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);