[FFmpeg-devel] [PATCH 2/3] flvdec: Mark the demuxer as allowing discontinuous timestamps

Derek Buitenhuis derek.buitenhuis at gmail.com
Wed Nov 21 17:58:47 EET 2018


Any FLV file, not necessarily valid, but in extremely common use for live
or archived live purposes, may output discontinuous timestamps. As it currently
is, only files produced by NGINX's RTMP module will be marked as supporting
discontinuous timestamps, which is obviously untrue, and the fix was only
ever put in place for a single bug report / file. The FLV demuxer, however
will happily ingest any FLV, and output discontinuous timestamps, regardless
of whether this "live" demuxer is used, making the current set of flags untrue.

Add the flag to the main demuxer, as this is how it *actually* works. Lying to
downstream API users about a demuxer's behavior is not OK.

Also set AVFMT_NOBINSEARCH, as this should be true given discontinuous timetsamps.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
---
 libavformat/flvdec.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 4b9f46902b..032e466bab 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -74,7 +74,7 @@ typedef struct FLVContext {
     AVRational framerate;
 } FLVContext;
 
-static int probe(AVProbeData *p, int live)
+static int flv_probe(AVProbeData *p)
 {
     const uint8_t *d = p->buf;
     unsigned offset = AV_RB32(d + 5);
@@ -85,22 +85,15 @@ static int probe(AVProbeData *p, int live)
         d[3] < 5 && d[5] == 0 &&
         offset + 100 < p->buf_size &&
         offset > 8) {
-        int is_live = !memcmp(d + offset + 40, "NGINX RTMP", 10);
 
-        if (live == is_live)
-            return AVPROBE_SCORE_MAX;
+        return AVPROBE_SCORE_MAX;
     }
     return 0;
 }
 
-static int flv_probe(AVProbeData *p)
-{
-    return probe(p, 0);
-}
-
 static int live_flv_probe(AVProbeData *p)
 {
-    return probe(p, 1);
+    return 0;
 }
 
 static void add_keyframes_index(AVFormatContext *s)
@@ -1321,6 +1314,7 @@ AVInputFormat ff_flv_demuxer = {
     .read_close     = flv_read_close,
     .extensions     = "flv",
     .priv_class     = &flv_class,
+    .flags          = AVFMT_TS_DISCONT | AVFMT_NOBINSEARCH,
 };
 
 static const AVClass live_flv_class = {
-- 
2.19.1



More information about the ffmpeg-devel mailing list