From patchwork Thu May 31 04:40:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 9173 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp90088jad; Wed, 30 May 2018 21:41:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIzS1myeM8HJDQ8lMy7rDklSGmTXvLPhUNVtNWlLn1GUhkfXZo4CWp81KVbGlcF2Tx2Os3e X-Received: by 2002:a1c:b884:: with SMTP id i126-v6mr2954167wmf.30.1527741705867; Wed, 30 May 2018 21:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527741705; cv=none; d=google.com; s=arc-20160816; b=JAcBNidQ8yVh3yfEB/BE+nzt8icrJl9g1GwzCc9Itrm4yOLKoy7U7HMoKX1peCbige soU3voS4tYhJw2/wYUzdI9GZL113k0TE2NGN4kalECnpCjyE+kOIxr0jvPB4YzeKA5wA D60dRXWUn1PXvge5Sla1cL+wUwHVIrpajukMFmXSDJUE6hTyERxLCD90k9awl+a3U5R/ +2axv4hevSB6mwQLNf93aByH6JjqgVqD2mqzlM+ymV1nIaRQzqnQhH4edGm2vhlbz+y0 kALj+fPcwrAz8q1Rg1o+XrbyRg1bxq/+8GLqDV7c86d93tLfaGvDl94YMslyOxYZZZN2 2r+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:message-id:date:to:from :delivered-to:arc-authentication-results; bh=HNxzwfInMucQ6WGEe3qyL8u/CUFrh4XzgjTgZ+qU7Us=; b=fxbkx4TooVwG0Bvihmujtz3HeLuBxxgGxBOlYbApfEypCfUps3zsblIi4hCehj+1Uz CFk1CT4I734wVEMEkEc/h6JO8gNR9TO7ny1XNSq71+mUcW9k6b4Y8HEL60G1kX3gsDyB KxkAAabNXVo4WSMdBZhE20FUqQHs/GpCtMw/BdRMNBor6TEKMbUcqfPXfP3tGALu7jsB f9cxgzWQKgkjvNwxSwBG1Q23B6t4saRf5ZgMwLeYvcXcnRqslG91mW0AIZvOn6BsoEGP w6+rfI11dfyWQ0n9hrDBpS5mN63nAsH+rb7Gjlsi1QIoBHX3H4DoKggEciO1MOzBw2mt mHew== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 35-v6si31611011wrn.274.2018.05.30.21.41.45; Wed, 30 May 2018 21:41:45 -0700 (PDT) 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 A141A68A46A; Thu, 31 May 2018 07:40:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbg179.qq.com (SMTPBG179.QQ.COM [119.147.194.222]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6EC1768A458 for ; Thu, 31 May 2018 07:40:45 +0300 (EEST) X-QQ-mid: bizesmtp11t1527741650tvbuyibf Received: from localhost (unknown [47.90.47.25]) by esmtp6.qq.com (ESMTP) with id ; Thu, 31 May 2018 12:40:49 +0800 (CST) X-QQ-SSF: 01100000002000F0FLF0B00A0000000 X-QQ-FEAT: 1FVjgQNnvLRpb6rfRjAIbU1wecvGO3jh4TG7pflsUNvVgoUfJbTC0ppf7YlAQ UrErViYcT7t9nSjRjTnEry7luB5PnPl804KRPMy/5tBXRLiEFeyVjYT5m4xuDTzTdUFSvth c432586gymMr7yXca84qOBlrZ/YsQmSfhOs0i8OpWeRi6ZtDxqzL2Ydehr5lDaWsyz5LxtA 0ArruxPsb8tafJPq5ZJmeCiHcpdYREn/z8Btb/s3BFwMB5ATAF3xZqgWkIfKNlbIDQJSuDH gG/XeOQQlT90RUgBA2hLrCDxWpT9cnkxF1Maoxb/aA37PE X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 31 May 2018 12:40:41 +0800 Message-Id: <20180531044042.1198-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.10.1.382.ga23ca1b.dirty X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign1 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/flvdec: add flv_ignore_prevtag option into flvdec 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 Cc: Steven Liu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" dump the problem flv to problem_flv.flv. liuqideMacBook-Pro:xxx liuqi$ dd if=~/Movies/Test/1.flv of=problem_flv.flv count=81920 bs=1 81920+0 records in 81920+0 records out 81920 bytes transferred in 0.767041 secs (106800 bytes/sec) before this patch: liuqideMacBook-Pro:xxx liuqi$ ./ffplay problem_flv.flv ffplay version N-91141-gc24d247e2c Copyright (c) 2003-2018 the FFmpeg developers built with Apple LLVM version 9.1.0 (clang-902.0.39.1) configuration: --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libspeex --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-version3 --cc='ccache gcc' --enable-nonfree --enable-videotoolbox --enable-opengl --enable-libxml2 --enable-libsrt libavutil 56. 18.102 / 56. 18.102 libavcodec 58. 19.102 / 58. 19.102 libavformat 58. 16.100 / 58. 16.100 libavdevice 58. 4.100 / 58. 4.100 libavfilter 7. 24.100 / 7. 24.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 [flv @ 0x7fcfe5821e00] Packet mismatch 355 352 352 problem_flv.flv: could not find codec parameters after this patch: liuqideMacBook-Pro:xxx liuqi$ ./ffplay -flv_ignore_prevtag 1 problem_flv.flv ffplay version N-91141-gc24d247e2c Copyright (c) 2003-2018 the FFmpeg developers built with Apple LLVM version 9.1.0 (clang-902.0.39.1) configuration: --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libspeex --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-version3 --cc='ccache gcc' --enable-nonfree --enable-videotoolbox --enable-opengl --enable-libxml2 --enable-libsrt libavutil 56. 18.102 / 56. 18.102 libavcodec 58. 19.102 / 58. 19.102 libavformat 58. 16.100 / 58. 16.100 libavdevice 58. 4.100 / 58. 4.100 libavfilter 7. 24.100 / 7. 24.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 Input #0, flv, from 'problem_flv.flv': Metadata: fileSize : 102128061 audiochannels : 2 encoder : obs-output module (libobs version 0.10.1) Duration: 00:05:09.60, start: 0.000000, bitrate: 2 kb/s Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp, 131 kb/s Stream #0:1: Video: h264 (High), yuv420p(tv, bt709, progressive), 960x600, 2560 kb/s, 30 fps, 30 tbr, 1k tbn, 60 tbc [h264 @ 0x7fdf64122a00] Invalid NAL unit size (10375 > 1656).=0/0 [h264 @ 0x7fdf64122a00] Error splitting the input into NAL units. 2.14 A-V: -0.013 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0 Signed-off-by: Steven Liu --- doc/demuxers.texi | 3 +++ libavformat/flvdec.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/doc/demuxers.texi b/doc/demuxers.texi index 072918be28..5007e6339f 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -269,6 +269,9 @@ ffmpeg -f live_flv -i rtmp:///anything/key .... @table @option @item -flv_metadata @var{bool} Allocate the streams according to the onMetaData array content. + +@item -flv_ignore_prevtag @var{bool} +Ignore the size of previous tag value. @end table @section gif diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 34c3e08bad..861cf7c020 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -44,6 +44,7 @@ typedef struct FLVContext { const AVClass *class; ///< Class for private options. int trust_metadata; ///< configure streams according onMetaData + int trust_datasize; ///< trust data size of FLVTag int wrong_dts; ///< wrong dts due to negative cts uint8_t *new_extradata[FLV_STREAM_TYPE_NB]; int new_extradata_size[FLV_STREAM_TYPE_NB]; @@ -1252,6 +1253,7 @@ retry_duration: leave: last = avio_rb32(s->pb); + if (!flv->trust_datasize) { if (last != orig_size + 11 && last != orig_size + 10 && !avio_feof(s->pb) && (last != orig_size || !last) && last != flv->sum_flv_tag_size && @@ -1264,6 +1266,7 @@ leave: goto retry; } } + } return ret; } @@ -1279,6 +1282,7 @@ static int flv_read_seek(AVFormatContext *s, int stream_index, #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { { "flv_metadata", "Allocate streams according to the onMetaData array", OFFSET(trust_metadata), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD }, + { "flv_ignore_prevtag", "Ignore the Size of previous tag", OFFSET(trust_datasize), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD }, { "missing_streams", "", OFFSET(missing_streams), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 0xFF, VD | AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY }, { NULL } };