From patchwork Thu Apr 13 06:29:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41128 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1013522pzb; Wed, 12 Apr 2023 23:29:45 -0700 (PDT) X-Google-Smtp-Source: AKy350are0S5W2mQAwy1CXQsfNwPpvpIBilv0ACgc3jjqJldwUni2NpdBjCrtJdZvr/TzcslF/TD X-Received: by 2002:a50:fc05:0:b0:4fb:5089:6e01 with SMTP id i5-20020a50fc05000000b004fb50896e01mr1674779edr.6.1681367384929; Wed, 12 Apr 2023 23:29:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681367384; cv=none; d=google.com; s=arc-20160816; b=i4fl5cZt/LSStIpiRbvCAMzwiOrQLqEqe4CXVNPLnjitSX/yEOvP+QwubqE/WVPL2C Cuf+/1uXYSn4csp+YAvYx1VcDrLTdWVzo3Pf8m/Xy+nBjR2kodTNvDkrxYzru8s5cCa1 FyfB8TZzY51/V63la3cH3EQ21fa5n97eBRHIdL2fRSpGC3WeLM6Ri8w5EWBfPTRNQQDQ UCLfOXTXhHPevii00aEk7O4rTjibar0aPTnCYis0qxFinrLHd/LabmkEs6Zr024I35nm Uco0uS+OzDu7r03kLpI8nAtV4/QyeVZTqufrndG4jiX3nc5m0k71aM7dvur7AwssiF5Q B0ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:mime-version:references :in-reply-to:message-id:date:to:from:delivered-to; bh=5BzhDJUZaaWmJGk3BNGFpLIfmpzQsDICDzsyp8jcXHA=; b=BkT/PrpNrXkuW++Hf/0+UMwpulIOQmlr6MiCFOU/aGnqzKl4YwmqLI8cltKN2ExRt1 FEZS3jg7/dJWYGT0HwlxT9s6OXPFgV+xROzg0m5VJUkN9pwBpMYVTB5GKxCXAAqij9Om 7U9J7YWSmruy1FDUymmwYY0pPQszXPEHL1CTuZuXGSyAowBoIHZasOD2foEqz02Gubb6 QPTQX1zjWwh/qUxCFfF10fg5kllRUa8uufNZfHnsJIih5jwnQhGU5PU8Zt17PU1lJxe/ bbVs5Nxw2XaUNWctOh168asq+ftE+z4GQ229hL1mceAjaLy5k85fa7Hpdbqiy1KsRM7C dBrA== 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 m26-20020a056402051a00b00505047719d8si968645edv.311.2023.04.12.23.29.44; Wed, 12 Apr 2023 23:29:44 -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 D604568BAE7; Thu, 13 Apr 2023 09:29:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5915D68093C for ; Thu, 13 Apr 2023 09:29:31 +0300 (EEST) X-QQ-mid: bizesmtpipv602t1681367365tjf4 Received: from localhost ( [255.62.16.15]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 13 Apr 2023 14:29:24 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: cbY9MYqwEzTqKkAcFldiTXxnh2V/gnfDiOmPszuY4wm2mZygR3fIr7F3WqKsq Efp9WOiFQ89FP7Ym0OE6wF5h6VeldPH4oajJ0890B+REMb/HV06a95Co9MSfUiW6udVSI2B ufCJxUef66cdWix8vdqihFmU4hKLoWjCkCGnzw7HqD2VwcCR1ImR1+FmY+f67kFOsKY2OB5 wOESxAc3S7yVZr2DD5BriGq1xpPJZVgo0YdxVjSoQNsX8aOdvHGhmDLQL2nBKOiQdOt7m+3 8T/i4Kl9yNuKt7QSkaa8e7iPNgewloL2gPguyotkVBH5cWdmvbdxDw5e805MzLYVrV0ta8c UKlK84BGvw/PzK4bF+/nbhYayF4jnWF7waM1zGF X-QQ-GoodBg: 0 X-BIZMAIL-ID: 12616925261531859821 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 14:29:16 +0800 Message-Id: <20230413062919.3501-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <1f4144d9-484e-43e1-958c-99b24e931907@app.fastmail.com> References: <1f4144d9-484e-43e1-958c-99b24e931907@app.fastmail.com> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpipv:chinaffmpeg.org:qybglogicsvr:qybglogicsvr2 Subject: [FFmpeg-devel] [PATCH v7 1/4] avformat/flvenc: Add support for HEVC over flv in muxer X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: mB0UGvSWbT8N Implements HEVC according to Enhanced FLV spec found at https://github.com/veovera/enhanced-rtmp And it has beed supported by OBS, Simple Realtime Server, mpegts.js. And the enhanced FLV documentation contributors include Jean-Baptiste Kempf (FFmpeg, VideoLAN). So this should be support by ffmpeg too. Signed-off-by: Steven Liu --- libavformat/flv.h | 15 +++++++++++++++ libavformat/flvenc.c | 41 +++++++++++++++++++++++++++++++---------- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/libavformat/flv.h b/libavformat/flv.h index 3571b90279..91e0a4140c 100644 --- a/libavformat/flv.h +++ b/libavformat/flv.h @@ -35,6 +35,12 @@ #define FLV_VIDEO_FRAMETYPE_OFFSET 4 +/* Extended VideoTagHeader + * defined in reference link: + * https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf + * */ +#define FLV_IS_EX_HEADER 0x80 + /* bitmasks to isolate specific values */ #define FLV_AUDIO_CHANNEL_MASK 0x01 #define FLV_AUDIO_SAMPLESIZE_MASK 0x02 @@ -112,6 +118,15 @@ enum { FLV_CODECID_MPEG4 = 9, }; +enum { + PacketTypeSequenceStart = 0, + PacketTypeCodedFrames = 1, + PacketTypeSequenceEnd = 2, + PacketTypeCodedFramesX = 3, + PacketTypeMetadata = 4, + PacketTypeMPEG2TSSequenceStart = 5, +}; + enum { FLV_FRAME_KEY = 1 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< key frame (for AVC, a seekable frame) FLV_FRAME_INTER = 2 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< inter frame (for AVC, a non-seekable frame) diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index fbf7eabaf8..57a26245ff 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -28,6 +28,7 @@ #include "libavcodec/mpeg4audio.h" #include "avio.h" #include "avc.h" +#include "hevc.h" #include "avformat.h" #include "flv.h" #include "internal.h" @@ -46,6 +47,7 @@ static const AVCodecTag flv_video_codec_ids[] = { { AV_CODEC_ID_VP6, FLV_CODECID_VP6 }, { AV_CODEC_ID_VP6A, FLV_CODECID_VP6A }, { AV_CODEC_ID_H264, FLV_CODECID_H264 }, + { AV_CODEC_ID_HEVC, MKBETAG('h', 'v', 'c', '1') }, { AV_CODEC_ID_NONE, 0 } }; @@ -492,7 +494,7 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i FLVContext *flv = s->priv_data; if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264 - || par->codec_id == AV_CODEC_ID_MPEG4) { + || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) { int64_t pos; avio_w8(pb, par->codec_type == AVMEDIA_TYPE_VIDEO ? @@ -535,10 +537,19 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i } avio_write(pb, par->extradata, par->extradata_size); } else { - avio_w8(pb, par->codec_tag | FLV_FRAME_KEY); // flags - avio_w8(pb, 0); // AVC sequence header - avio_wb24(pb, 0); // composition time - ff_isom_write_avcc(pb, par->extradata, par->extradata_size); + if (par->codec_id == AV_CODEC_ID_HEVC) { + avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeSequenceStart); // ExVideoTagHeader mode with PacketTypeSequenceStart + avio_write(pb, "hvc1", 4); + } else { + avio_w8(pb, par->codec_tag | FLV_FRAME_KEY); // flags + avio_w8(pb, 0); // AVC sequence header + avio_wb24(pb, 0); // composition time + } + + if (par->codec_id == AV_CODEC_ID_HEVC) + ff_isom_write_hvcc(pb, par->extradata, par->extradata_size, 0); + else + ff_isom_write_avcc(pb, par->extradata, par->extradata_size); } data_size = avio_tell(pb) - pos; avio_seek(pb, -data_size - 10, SEEK_CUR); @@ -628,7 +639,8 @@ static int flv_init(struct AVFormatContext *s) return unsupported_codec(s, "Video", par->codec_id); if (par->codec_id == AV_CODEC_ID_MPEG4 || - par->codec_id == AV_CODEC_ID_H263) { + par->codec_id == AV_CODEC_ID_H263 || + par->codec_id == AV_CODEC_ID_HEVC) { int error = s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL; av_log(s, error ? AV_LOG_ERROR : AV_LOG_WARNING, "Codec %s is not supported in the official FLV specification,\n", avcodec_get_name(par->codec_id)); @@ -836,13 +848,13 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A || par->codec_id == AV_CODEC_ID_VP6 || par->codec_id == AV_CODEC_ID_AAC) flags_size = 2; - else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4) + else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) flags_size = 5; else flags_size = 1; if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264 - || par->codec_id == AV_CODEC_ID_MPEG4) { + || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) { size_t side_size; uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size); if (side && side_size > 0 && (side_size != par->extradata_size || memcmp(side, par->extradata, side_size))) { @@ -862,7 +874,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) "Packets are not in the proper order with respect to DTS\n"); return AVERROR(EINVAL); } - if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4) { + if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) { if (pkt->pts == AV_NOPTS_VALUE) { av_log(s, AV_LOG_ERROR, "Packet is missing PTS\n"); return AVERROR(EINVAL); @@ -907,6 +919,10 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) if (par->extradata_size > 0 && *(uint8_t*)par->extradata != 1) if ((ret = ff_avc_parse_nal_units_buf(pkt->data, &data, &size)) < 0) return ret; + } else if (par->codec_id == AV_CODEC_ID_HEVC) { + if (par->extradata_size > 0 && *(uint8_t*)par->extradata != 1) + if ((ret = ff_hevc_annexb2mp4_buf(pkt->data, &data, &size, 0, NULL)) < 0) + return ret; } else if (par->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) { if (!s->streams[pkt->stream_index]->nb_frames) { @@ -968,7 +984,12 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) avio_wb32(pb, data_size + 11); } else { av_assert1(flags>=0); - avio_w8(pb,flags); + if (par->codec_id == AV_CODEC_ID_HEVC) { + avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeCodedFramesX); // ExVideoTagHeader mode with PacketTypeCodedFramesX + avio_write(pb, "hvc1", 4); + } else { + avio_w8(pb, flags); + } if (par->codec_id == AV_CODEC_ID_VP6) avio_w8(pb,0); if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A) { From patchwork Thu Apr 13 06:29:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41129 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1013602pzb; Wed, 12 Apr 2023 23:29:56 -0700 (PDT) X-Google-Smtp-Source: AKy350YtebyyegHNjClH7tGV/wUFqeaX6dXQud8G41jM99jrN4HrGbi6hzZmBOwOL7QHLklxOfQd X-Received: by 2002:aa7:c155:0:b0:501:d43e:d1dd with SMTP id r21-20020aa7c155000000b00501d43ed1ddmr1103490edp.33.1681367396438; Wed, 12 Apr 2023 23:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681367396; cv=none; d=google.com; s=arc-20160816; b=FgpqJpjO/JEL4QGFppR6XQpkCSJ2DaI6g2MPOHenpyiUNB8GJQECjzlAOBresVBbhW BtK2NbrmrtKXI9OMBzZIAkWl/WFpEOCk3Z2K5h8BAcKGGvcPHrbaPefxfOLXERKJIvk9 O66fwrC+2RhL4gAWSuQlKPcR++I+5X3tTvnhoNo2L1IzXFbgStSoG5ioVB0Ky02GLLJJ mqUrz5ArqPueYrO5wOtoSMUz/RsEaCk16miPtL8tdy//EydJAut9I85rKqb973ROzML5 ntdkVXJREm1pxceS58iVU0tpIt9lg4Ujg78f2qc7jBn94igMxHtJ4OD7MA7esaSArFZD Fytg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:mime-version:references :in-reply-to:message-id:date:to:from:delivered-to; bh=JZ9eGtCvS2/rOUvkHu4eW4gHBBIRdv4UWafehVpw7hg=; b=tvVrYpnGLxQRrdqDlAp50ShJp6Fgvi0oQ1HArG9dQGHG7V6DxWAQdk+1d+Mn9gNuxM CsqczS4W2EjRozcFuR3sEAz+DokymtcBOV1UCZUBLJIVJb6xPo3UhwmCKH+5bIOFaRBg mfpSQ65k5aslRk9degf9qK5hcd66Nrgt/TaWPGoePUck84o0eD5qvmoovfMBysh+BPQ9 Y+xE3tckiyobqTVYCI6wWme5RYdBD3Nl4nvqtIy79jtFSaPiHntZB5rCilYedjIPmy2B sKeEuwKrmFCdjFmXIUfLPBV8SzjI2o/YPiGvbdQPVR2VVsHUJSXoDL6PB0tGB23fCvuh 65Ug== 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 r19-20020aa7c153000000b0050508fc766csi1045288edp.125.2023.04.12.23.29.56; Wed, 12 Apr 2023 23:29:56 -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 0976568BB5E; Thu, 13 Apr 2023 09:29:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.67.158]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 53A1D689C13 for ; Thu, 13 Apr 2023 09:29:34 +0300 (EEST) X-QQ-mid: bizesmtpipv602t1681367369twq6 Received: from localhost ( [255.62.16.15]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 13 Apr 2023 14:29:28 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: b+hmI1kBZ28KI4RtA9tVkXs8XTfWa2jTL47thPhXbaCPDferYGG2PoNaZXPKC UZ31h9VFt+FssjW2vlu4xV5JO899BLMW9tJ9TEpnKeODFnlwyaJw5XxPGFSc3xzkDYAr30N HcTZGI7vFpfSi6pjhyiEVAJsmrn6mvhNPCg1IIMFVs2OFSV0dWvRUBbgLx8LYzQozBSG3ri vEoMP1RbMODu4G/p/Vm7LaZZQxR4T+L1eOKtphvzwHiumPu+uQ7aR02+eaiNqBWQcLmody3 yWjs18LTngATcy5gGkY5fy9FEy+RSn8vkVRjroJdJtyEBAGxpWyuy06wyEDH3MSZP+8vna4 o5P/UffvSO7VfqMgHCKEP66w5KjNFzu9S4m6zHBzXL5RmzivhM= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 2915969228331836286 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 14:29:17 +0800 Message-Id: <20230413062919.3501-2-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230413062919.3501-1-lq@chinaffmpeg.org> References: <1f4144d9-484e-43e1-958c-99b24e931907@app.fastmail.com> <20230413062919.3501-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpipv:chinaffmpeg.org:qybglogicsvr:qybglogicsvr2 Subject: [FFmpeg-devel] [PATCH v7 2/4] avformat/flvdec: support demux hevc in enhanced flv X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /ulkHximMImc Signed-off-by: Steven Liu --- libavformat/flvdec.c | 55 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index d83edff727..0b6218f65b 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -79,6 +79,8 @@ typedef struct FLVContext { int64_t last_ts; int64_t time_offset; int64_t time_pos; + + uint8_t exheader; } FLVContext; /* AMF date type */ @@ -302,13 +304,25 @@ static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, } } -static int flv_same_video_codec(AVCodecParameters *vpar, int flags) +static int flv_same_video_codec(AVFormatContext *s, AVCodecParameters *vpar, int flags) { int flv_codecid = flags & FLV_VIDEO_CODECID_MASK; + FLVContext *flv = s->priv_data; if (!vpar->codec_id && !vpar->codec_tag) return 1; + if (flv->exheader) { + uint8_t *codec_id_str = (uint8_t *)s->pb->buf_ptr; + uint32_t codec_id = codec_id_str[3] | codec_id_str[2] << 8 | codec_id_str[1] << 16 | codec_id_str[0] << 24; + switch(codec_id) { + case MKBETAG('h', 'v', 'c', '1'): + return vpar->codec_id == AV_CODEC_ID_HEVC; + default: + break; + } + } + switch (flv_codecid) { case FLV_CODECID_H263: return vpar->codec_id == AV_CODEC_ID_FLV1; @@ -331,9 +345,24 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_codecid, int read) { FFStream *const vstreami = ffstream(vstream); + FLVContext *flv = s->priv_data; int ret = 0; AVCodecParameters *par = vstream->codecpar; enum AVCodecID old_codec_id = vstream->codecpar->codec_id; + flv_codecid &= FLV_VIDEO_CODECID_MASK; + + if (flv->exheader) { + uint32_t codec_id = avio_rb32(s->pb); + + switch(codec_id) { + case MKBETAG('h', 'v', 'c', '1'): + par->codec_id = AV_CODEC_ID_HEVC; + vstreami->need_parsing = AVSTREAM_PARSE_HEADERS; + return 4; + default: + break; + } + } switch (flv_codecid) { case FLV_CODECID_H263: par->codec_id = AV_CODEC_ID_FLV1; @@ -796,6 +825,7 @@ static int flv_read_header(AVFormatContext *s) s->start_time = 0; flv->sum_flv_tag_size = 0; flv->last_keyframe_stream_index = -1; + flv->exheader = 0; return 0; } @@ -1071,6 +1101,11 @@ retry: } else if (type == FLV_TAG_TYPE_VIDEO) { stream_type = FLV_STREAM_TYPE_VIDEO; flags = avio_r8(s->pb); + /* + * Reference Enhancing FLV 2023-03-v1.0.0-B.8 + * https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf + * */ + flv->exheader = (flags >> 7) & 1; size--; if ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_VIDEO_INFO_CMD) goto skip; @@ -1129,7 +1164,7 @@ skip: break; } else if (stream_type == FLV_STREAM_TYPE_VIDEO) { if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && - (s->video_codec_id || flv_same_video_codec(st->codecpar, flags))) + (s->video_codec_id || flv_same_video_codec(s, st->codecpar, flags))) break; } else if (stream_type == FLV_STREAM_TYPE_SUBTITLE) { if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) @@ -1230,7 +1265,7 @@ retry_duration: avcodec_parameters_free(&par); } } else if (stream_type == FLV_STREAM_TYPE_VIDEO) { - int ret = flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK, 1); + int ret = flv_set_video_codec(s, st, flags, 1); if (ret < 0) return ret; size -= ret; @@ -1242,9 +1277,15 @@ retry_duration: if (st->codecpar->codec_id == AV_CODEC_ID_AAC || st->codecpar->codec_id == AV_CODEC_ID_H264 || - st->codecpar->codec_id == AV_CODEC_ID_MPEG4) { - int type = avio_r8(s->pb); - size--; + st->codecpar->codec_id == AV_CODEC_ID_MPEG4 || + st->codecpar->codec_id == AV_CODEC_ID_HEVC) { + int type = 0; + if (flv->exheader) { + type = flags & 0x0F; + } else { + type = avio_r8(s->pb); + size--; + } if (size < 0) { ret = AVERROR_INVALIDDATA; @@ -1267,7 +1308,7 @@ retry_duration: } } if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC || - st->codecpar->codec_id == AV_CODEC_ID_H264)) { + st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_HEVC)) { AVDictionaryEntry *t; if (st->codecpar->extradata) { From patchwork Thu Apr 13 06:29:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41130 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1013664pzb; Wed, 12 Apr 2023 23:30:05 -0700 (PDT) X-Google-Smtp-Source: AKy350aPhVGH1O+U5LgGoF86MDiLlSCJeMGWc4AxFlmVOtKgbxoLBCDOM6/fVZHauJLvev33nGk7 X-Received: by 2002:a17:906:a185:b0:94d:cebe:691 with SMTP id s5-20020a170906a18500b0094dcebe0691mr1369167ejy.69.1681367404956; Wed, 12 Apr 2023 23:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681367404; cv=none; d=google.com; s=arc-20160816; b=OD0vBBx6tcvWftPsT+EkQC7dvypnG2KDPxYGL46fh8885PCefuPW3NBbEfn7d2Ros8 aFaKDTYbGJ66lJXwlavK4LJie40Xw4FVKyx0vGkBNxPOKundo2uOUwqzN4IAglDbswU4 4KpSpYPQL/iRAclNaAOlq+L4Omi5xo/vpzNYTEue4xYyXb56B6ILbqraM+IiNieTV6Jw 7JdScs6H/r5Ibiu+ST/8qGjQmJd7InDpuShsS+RWP5PW6Eu+Fq7EJmR5PImtfO4CpVFK N9PoE1oTAuMHXJSC0pvZHd20dgRBIn700aGiGdB2sCIgjj8K7bFqRmEpdeDSt9RNwkWF AL+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:mime-version:references :in-reply-to:message-id:date:to:from:delivered-to; bh=8tb7rA4fPKlhapAzB+dI3FqOJWG1q+qMH7MV6qDi70U=; b=HMWCpTwtuMXWiOSJvweX1TvPVHvQDS6Kh9enERPcltl5o1A2T+LpRdNJl3TDZw5N8e 0ASzGkJYvoRcfWiztn3kV2KM4HQs9W8bWkjJfzbjfdNwy34DlO8VmCnj/Y8uB7tL4Lmy KIIuijMgCi/mfcIkoKXJ0X8/yUp8cwcsdakz88rfHMA7GQxMhYx3+6RIO6yXtZSyJZ9Y XLkXiwGNIeKC6azWg11RE1saIZgesq5JeudDKCW43ZiRBu20PFcJLpeeuU827YXcg4u5 I0ODSytX6lX5kwtMOzBLva8+Roq8iWMR0xoMkMNbm8yvPUQIMzRj0bPuKS5O4TzZ/jM3 5H+g== 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 fe24-20020a1709072a5800b0094e4c2fbb2bsi1089104ejc.656.2023.04.12.23.30.04; Wed, 12 Apr 2023 23:30:04 -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 2E44B68BBE3; Thu, 13 Apr 2023 09:29:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.67.158]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 946B068BAEC for ; Thu, 13 Apr 2023 09:29:38 +0300 (EEST) X-QQ-mid: bizesmtpipv603t1681367373tpl2 Received: from localhost ( [255.62.16.15]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 13 Apr 2023 14:29:32 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: G46xFj+wOV+Pt1dQZ7GmbHd6Gy5X+ltzEr/2ah4tJEwmMe/ogNQjGTkdwJrdS 5gfwv5uZ3rJMRSLLhe2tGJHzPe0kFe9KLKchsqSlFsMJ2LtaUp7PjtSpHsx8DuBIOmOepJb NZbCK5oqIUYJ31C7jDpQ5TfH+r4BsUPqYg0QEZtmJGXI8YfV/4RANgbyi/6ropM3IKdfO4P gm8h908SwHicSsubnbyFjP6uQLpbEpHS8+OEAihn0o5pQdoto/eNIQJvF5+Ula5yY9v7kmY 4cSFulcR2mGjPgnuklvGbCoz5aPmT7v/Wt3v24UQ/1CjP/+79hKN53srARZ/ipq9r8bC/tI zYQtahc3PyMc5Y0HJ8YLlsxKZ9MzO55i+Eni1xaVR/ApdLlN3Q= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 6505279366245678992 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 14:29:18 +0800 Message-Id: <20230413062919.3501-3-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230413062919.3501-1-lq@chinaffmpeg.org> References: <1f4144d9-484e-43e1-958c-99b24e931907@app.fastmail.com> <20230413062919.3501-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpipv:chinaffmpeg.org:qybglogicsvr:qybglogicsvr2 Subject: [FFmpeg-devel] [PATCH v7 3/4] avformat/flvenc: support mux av1 in enhanced flv X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: PEIThAL645MH Signed-off-by: Steven Liu --- libavformat/flvenc.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 57a26245ff..7b43ecaefa 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -28,6 +28,7 @@ #include "libavcodec/mpeg4audio.h" #include "avio.h" #include "avc.h" +#include "av1.h" #include "hevc.h" #include "avformat.h" #include "flv.h" @@ -48,6 +49,7 @@ static const AVCodecTag flv_video_codec_ids[] = { { AV_CODEC_ID_VP6A, FLV_CODECID_VP6A }, { AV_CODEC_ID_H264, FLV_CODECID_H264 }, { AV_CODEC_ID_HEVC, MKBETAG('h', 'v', 'c', '1') }, + { AV_CODEC_ID_AV1, MKBETAG('a', 'v', '0', '1') }, { AV_CODEC_ID_NONE, 0 } }; @@ -494,7 +496,8 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i FLVContext *flv = s->priv_data; if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264 - || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) { + || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC + || par->codec_id == AV_CODEC_ID_AV1) { int64_t pos; avio_w8(pb, par->codec_type == AVMEDIA_TYPE_VIDEO ? @@ -540,6 +543,9 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i if (par->codec_id == AV_CODEC_ID_HEVC) { avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeSequenceStart); // ExVideoTagHeader mode with PacketTypeSequenceStart avio_write(pb, "hvc1", 4); + } else if (par->codec_id == AV_CODEC_ID_AV1) { + avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeSequenceStart); + avio_write(pb, "av01", 4); } else { avio_w8(pb, par->codec_tag | FLV_FRAME_KEY); // flags avio_w8(pb, 0); // AVC sequence header @@ -548,6 +554,8 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i if (par->codec_id == AV_CODEC_ID_HEVC) ff_isom_write_hvcc(pb, par->extradata, par->extradata_size, 0); + else if (par->codec_id == AV_CODEC_ID_AV1) + ff_isom_write_av1c(pb, par->extradata, par->extradata_size, 1); else ff_isom_write_avcc(pb, par->extradata, par->extradata_size); } @@ -640,7 +648,8 @@ static int flv_init(struct AVFormatContext *s) if (par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_H263 || - par->codec_id == AV_CODEC_ID_HEVC) { + par->codec_id == AV_CODEC_ID_HEVC || + par->codec_id == AV_CODEC_ID_AV1) { int error = s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL; av_log(s, error ? AV_LOG_ERROR : AV_LOG_WARNING, "Codec %s is not supported in the official FLV specification,\n", avcodec_get_name(par->codec_id)); @@ -848,13 +857,15 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A || par->codec_id == AV_CODEC_ID_VP6 || par->codec_id == AV_CODEC_ID_AAC) flags_size = 2; - else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) + else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || + par->codec_id == AV_CODEC_ID_HEVC || par->codec_id == AV_CODEC_ID_AV1) flags_size = 5; else flags_size = 1; if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264 - || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) { + || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC + || par->codec_id == AV_CODEC_ID_AV1) { size_t side_size; uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size); if (side && side_size > 0 && (side_size != par->extradata_size || memcmp(side, par->extradata, side_size))) { @@ -874,7 +885,8 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) "Packets are not in the proper order with respect to DTS\n"); return AVERROR(EINVAL); } - if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) { + if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || + par->codec_id == AV_CODEC_ID_HEVC || par->codec_id == AV_CODEC_ID_AV1) { if (pkt->pts == AV_NOPTS_VALUE) { av_log(s, AV_LOG_ERROR, "Packet is missing PTS\n"); return AVERROR(EINVAL); @@ -987,6 +999,9 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) if (par->codec_id == AV_CODEC_ID_HEVC) { avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeCodedFramesX); // ExVideoTagHeader mode with PacketTypeCodedFramesX avio_write(pb, "hvc1", 4); + } else if (par->codec_id == AV_CODEC_ID_AV1) { + avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeCodedFrames); + avio_write(pb, "av01", 4); } else { avio_w8(pb, flags); } From patchwork Thu Apr 13 06:29:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41131 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1013765pzb; Wed, 12 Apr 2023 23:30:14 -0700 (PDT) X-Google-Smtp-Source: AKy350YSY175G+vcEsJtEaSGBIMpeFgnVd70sNEQz5SKzwouRDfLbqQqyXztOVODLAl0FS2rTYMt X-Received: by 2002:a17:906:ae96:b0:94a:ac4b:e11b with SMTP id md22-20020a170906ae9600b0094aac4be11bmr1471241ejb.39.1681367414396; Wed, 12 Apr 2023 23:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681367414; cv=none; d=google.com; s=arc-20160816; b=m+z8HF3QREQ9h872cNMEfbJNrSmoqEfIOgw6j0UG8TISWK/Qso2cCt4Dee8HB5rVcY pmnH1zjMHPMImx7NYtbqOMDtBhEIcjqZGenINP5a9ABeTunwEgH3emiJ/Z6giPaKgLfW WewOmHXLG6+BaUA1V+wncNvV+Gn/6ZbU8HkH8Ttlt+dPyFZgxyH3ulSdimCApuNv0dsD iSK2GgMWMn0/sLO7FDNldTVykB/GrVFSQvc8rQJmr+P78nDj61ylE2Gab4lb5Ry9xzTE 8iiUuQyPJrigQWbmKowsSCYgoXyuN4d8h+W6lgM9ovgRHXZXX+u2A0y/grtn7YxZEFNb QqZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:mime-version:references :in-reply-to:message-id:date:to:from:delivered-to; bh=ZAfJjZ5q6QyzEL61BpLk1ov+KW9fCkNasBCpZ7PdWB0=; b=x11CDm3FcHZQQjCzOgKlAJ6y6FadUwKZkWogPqDyB5OfwVzmpYgUDV7o474qFkcUN+ mSRc32b4TN537Q+6tLrprnlH0OK+RgUyuyu+2WhblqKnOg6KQKyh+zBjB4DMOLNAohJj BZueYaeX70obP8CaEczykPOA2BMbt43sViDjIWNE1IizBjWY7EEEcf0RtWn5QhXSbcc0 7+AzDLF4ucxX/fCJ59VpyXyiBKE4Bc5zQg4jhB+8YTLrCI8IJ9KuzBQlHIRo9syR4nu5 hplFw/H2tw8A52+yVMhkSZKWK1n45iO98QthYf6IOOqz/tj9k35jGAFI/8ANo6+jI8OI ZIxg== 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 fu37-20020a170907b02500b0094c67d4acdcsi985104ejc.372.2023.04.12.23.30.13; Wed, 12 Apr 2023 23:30:14 -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 5589468BC13; Thu, 13 Apr 2023 09:29:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.67.158]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D6FDB68BAEC for ; Thu, 13 Apr 2023 09:29:42 +0300 (EEST) X-QQ-mid: bizesmtpipv601t1681367377t6oh Received: from localhost ( [255.62.16.15]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 13 Apr 2023 14:29:36 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: LG+NUo/f6sGUhnLBxMQUMhhw4Y8cyKkHsOkVbNpaJPQ/2J3P/9IFpIZXYon5y MLykv9wrIqpFv3HTav6mwhFwLsjYL0foiS+p1RD7n3M3Qngruk5N/g0JPbpBEUQq4rXNUQ9 a4KII5Px0BU25mhnCMqfLy3ANFchUyFWrErcU+wOYgZqpb/w0vOR/iOHG+/h4j2eYSpa/Ig C2nQ7XAvHHRgEzx2qZeoYR/6yUbIjWCJm3LFcDhAvMqEBxkvHJ/warptAbYWS2XstN2HkoJ im/gXz/ZKA5kguipUTzL/F/HBTUJwnyEOXkL0swYawaBXeHujNy3M/hm7dKdikPh8Itmm8+ HAZyBrch0WPl0zj+T+W8gC75v/L2gXRRDIZUdoLHHwuCJPPg9g= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 16757861296107735029 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 14:29:19 +0800 Message-Id: <20230413062919.3501-4-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230413062919.3501-1-lq@chinaffmpeg.org> References: <1f4144d9-484e-43e1-958c-99b24e931907@app.fastmail.com> <20230413062919.3501-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpipv:chinaffmpeg.org:qybglogicsvr:qybglogicsvr2 Subject: [FFmpeg-devel] [PATCH v7 4/4] avformat/flvdec: support demux av1 in enhanced flv X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: rxlMQV/L3Ssz Signed-off-by: Steven Liu --- libavformat/flvdec.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 0b6218f65b..e68a6c5215 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -318,6 +318,8 @@ static int flv_same_video_codec(AVFormatContext *s, AVCodecParameters *vpar, int switch(codec_id) { case MKBETAG('h', 'v', 'c', '1'): return vpar->codec_id == AV_CODEC_ID_HEVC; + case MKBETAG('a', 'v', '0', '1'): + return vpar->codec_id == AV_CODEC_ID_AV1; default: break; } @@ -359,6 +361,10 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, par->codec_id = AV_CODEC_ID_HEVC; vstreami->need_parsing = AVSTREAM_PARSE_HEADERS; return 4; + case MKBETAG('a', 'v', '0', '1'): + par->codec_id = AV_CODEC_ID_AV1; + vstreami->need_parsing = AVSTREAM_PARSE_HEADERS; + return 4; default: break; } @@ -1278,7 +1284,8 @@ retry_duration: if (st->codecpar->codec_id == AV_CODEC_ID_AAC || st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4 || - st->codecpar->codec_id == AV_CODEC_ID_HEVC) { + st->codecpar->codec_id == AV_CODEC_ID_HEVC || + st->codecpar->codec_id == AV_CODEC_ID_AV1) { int type = 0; if (flv->exheader) { type = flags & 0x0F; @@ -1308,7 +1315,8 @@ retry_duration: } } if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC || - st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_HEVC)) { + st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_HEVC || + st->codecpar->codec_id == AV_CODEC_ID_AV1)) { AVDictionaryEntry *t; if (st->codecpar->extradata) {