From patchwork Wed Nov 21 15:58:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 11107 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4969744D362 for ; Wed, 21 Nov 2018 17:59:15 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C7ADC689F27; Wed, 21 Nov 2018 17:59:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9BC19689EFA for ; Wed, 21 Nov 2018 17:59:09 +0200 (EET) Received: by mail-wr1-f67.google.com with SMTP id b13so6251506wrx.6 for ; Wed, 21 Nov 2018 07:59:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+WpLextC99CnF0sFn9+9ZdK94zQZh7RpwSw4hD1fIeo=; b=buAPZwCY33J/zybin9Hg9cmdd304r8aoaDnPXR8xCef/E+sn84Tw1z0vXPi4x3tr7r ia1h/PXgfCpVu9+w86uBpqp/68DLmKHCpKxPJvkwiHu+/hLhz6UPL9YwxMbYWj/gdUhF yLUl5vQxuujlIFoiuyh+bucCEz6KAJPlbcRtvHSlHOdpxXRizhXux452hijwpwmvM70y UkmDqKc2YGzYEcXJbLFjjXvkG33blbiCjFz1HR5SmDyk6V6hbpBXFlKK2aa2wecFfMBE X25nAB6ZsSXbcoRnwES4O+7Y4tHYwuKZnbrdbmvtEe0oYWRjNYwNIQCx32f8YeslFwsP PB5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+WpLextC99CnF0sFn9+9ZdK94zQZh7RpwSw4hD1fIeo=; b=UT9BhqqlHyomXWaR3zG4wV3repX36xCa7qhEHLCuG248gsHBR2ofAuggJnFwiEMl5e zEKlKA0OEZVnB58W9QZ1RoNcVI3MpagVSfUR90NvIkV22do+l9NffJav+NfRg26dDywg UbUu+lOHks5RkAS0h46UJDAocp8ZrJGC2NFgSvZdgimNyDe2iuTsJElQwZr+kzcMDcao V7X2mQqyzIJo8BfLh2x0Km5pV94b7Z9QTGWwiuGwwrJ7xx9VgER9shFqHC0IVLpJG+yx WFDV9xadbNwWF/mBDRmQ4u7ZKhmQAJmkbo9rHiqwKwkjqoFfq7Zh5hy09rLqX8DRdeFJ Zy4w== X-Gm-Message-State: AA+aEWY8isWb6m0H+kWZgrevGFLBFDxuiIDqcSAdUxQJ60+dONBuCOni yxyTx6IC8QxK0VYDsN3sJzr6kCPc X-Google-Smtp-Source: AFSGD/V0bvPKcgQh/MAO6XgVRUivokbk0eLZM1FLf6zVfq/QbKECDVw/82ZeiFTc1Ej5E6cCg13KfQ== X-Received: by 2002:adf:9387:: with SMTP id 7-v6mr6264585wrp.269.1542815951508; Wed, 21 Nov 2018 07:59:11 -0800 (PST) Received: from localhost.localdomain ([81.2.170.96]) by smtp.gmail.com with ESMTPSA id 5sm2157493wmw.8.2018.11.21.07.59.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 07:59:09 -0800 (PST) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Wed, 21 Nov 2018 15:58:47 +0000 Message-Id: <20181121155848.201788-3-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181121155848.201788-1-derek.buitenhuis@gmail.com> References: <20181121155848.201788-1-derek.buitenhuis@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] flvdec: Mark the demuxer as allowing discontinuous timestamps 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" 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 --- 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 = {