diff mbox

[FFmpeg-devel] dashdec: Make use of frame rate specified in Representation

Message ID DB3PR0202MB3452F0B36B5C4D683443243BECEB0@DB3PR0202MB3452.eurprd02.prod.outlook.com
State New
Headers show

Commit Message

sfan5 Jan. 15, 2018, 3:58 p.m. UTC
Hi,

attached patch fixes an annoyance when playing DASH videos from e.g. 
YouTube:

"mov,mp4,m4a,3gp,3g2,mj2: Stream #0: not enough frames to estimate rate; 
consider increasing probesize"

Comments

sfan5 Jan. 20, 2018, 11:49 a.m. UTC | #1
bump

On 15.01.2018 at 16:58 Stefan _ wrote:
> Hi,

>

> attached patch fixes an annoyance when playing DASH videos from e.g.

> YouTube:

>

> "mov,mp4,m4a,3gp,3g2,mj2: Stream #0: not enough frames to estimate rate;

> consider increasing probesize"
Liu Steven Jan. 20, 2018, 3:56 p.m. UTC | #2
> 在 2018年1月15日,下午11:58,Stefan _ <sfan5@live.de> 写道:
> 
> Hi,
> 
> attached patch fixes an annoyance when playing DASH videos from e.g. 
> YouTube:
> 
> "mov,mp4,m4a,3gp,3g2,mj2: Stream #0: not enough frames to estimate rate; 
> consider increasing probesize"
> 
> <0001-dashdec-Make-use-of-frame-rate-specified-in-Represen.patch>
> _______________________________________________

will apply
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Liu Steven Jan. 21, 2018, 6:01 a.m. UTC | #3
> 在 2018年1月20日,下午11:56,Steven Liu <lq@chinaffmpeg.org> 写道:
> 
> 
> 
>> 在 2018年1月15日,下午11:58,Stefan _ <sfan5@live.de> 写道:
>> 
>> Hi,
>> 
>> attached patch fixes an annoyance when playing DASH videos from e.g. 
>> YouTube:
>> 
>> "mov,mp4,m4a,3gp,3g2,mj2: Stream #0: not enough frames to estimate rate; 
>> consider increasing probesize"
>> 
>> <0001-dashdec-Make-use-of-frame-rate-specified-in-Represen.patch>
>> _______________________________________________
> 
> will apply
pushed

Thanks

Steven
diff mbox

Patch

From e0210059fb420ef2e6c6b0d89c7e733b99f78ee5 Mon Sep 17 00:00:00 2001
From: sfan5 <sfan5@live.de>
Date: Mon, 15 Jan 2018 16:48:29 +0100
Subject: [PATCH] dashdec: Make use of frame rate specified in Representation

If the manifest provides this, setting r_frame_rate
avoids warnings regarding frame rate estimation.
---
 libavformat/dashdec.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 2492f1d26..a080bf358 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -86,6 +86,7 @@  struct representation {
     enum AVMediaType type;
     char id[20];
     int bandwidth;
+    AVRational framerate;
     AVStream *assoc_stream; /* demuxer stream associated with this representation */
 
     int n_fragments;
@@ -674,6 +675,7 @@  static int parse_manifest_representation(AVFormatContext *s, const char *url,
     xmlNodePtr representation_node = node;
     char *rep_id_val = xmlGetProp(representation_node, "id");
     char *rep_bandwidth_val = xmlGetProp(representation_node, "bandwidth");
+    char *rep_framerate_val = xmlGetProp(representation_node, "frameRate");
     enum AVMediaType type = AVMEDIA_TYPE_UNKNOWN;
 
     // try get information from representation
@@ -843,6 +845,13 @@  static int parse_manifest_representation(AVFormatContext *s, const char *url,
                 rep->fragment_timescale = 1;
             rep->bandwidth = rep_bandwidth_val ? atoi(rep_bandwidth_val) : 0;
             strncpy(rep->id, rep_id_val ? rep_id_val : "", sizeof(rep->id));
+            rep->framerate = av_make_q(0, 0);
+            if (type == AVMEDIA_TYPE_VIDEO && rep_framerate_val) {
+                ret = av_parse_video_rate(&rep->framerate, rep_framerate_val);
+                if (ret < 0)
+                    av_log(s, AV_LOG_VERBOSE, "Ignoring invalid frame rate '%s'\n", rep_framerate_val);
+            }
+
             if (type == AVMEDIA_TYPE_VIDEO) {
                 rep->rep_idx = video_rep_idx;
                 dynarray_add(&c->videos, &c->n_videos, rep);
@@ -861,6 +870,8 @@  end:
         xmlFree(rep_id_val);
     if (rep_bandwidth_val)
         xmlFree(rep_bandwidth_val);
+    if (rep_framerate_val)
+        xmlFree(rep_framerate_val);
 
     return ret;
 }
@@ -1571,7 +1582,7 @@  static int reopen_demux_for_component(AVFormatContext *s, struct representation
     AVInputFormat *in_fmt = NULL;
     AVDictionary  *in_fmt_opts = NULL;
     uint8_t *avio_ctx_buffer  = NULL;
-    int ret = 0;
+    int ret = 0, i;
 
     if (pls->ctx) {
         close_demux_for_component(pls);
@@ -1618,6 +1629,13 @@  static int reopen_demux_for_component(AVFormatContext *s, struct representation
     if (ret < 0)
         goto fail;
     if (pls->n_fragments) {
+#if FF_API_R_FRAME_RATE
+        if (pls->framerate.den) {
+            for (i = 0; i < pls->ctx->nb_streams; i++)
+                pls->ctx->streams[i]->r_frame_rate = pls->framerate;
+        }
+#endif
+
         ret = avformat_find_stream_info(pls->ctx, NULL);
         if (ret < 0)
             goto fail;
-- 
2.15.1