From patchwork Thu Apr 13 09:44:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41135 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1110869pzb; Thu, 13 Apr 2023 02:45:24 -0700 (PDT) X-Google-Smtp-Source: AKy350ZSIpjsw6x1VJkUbtN2lIClECqYpJONw0blNKFmFayXYPomLZEdwExWIWZX4eY48hiTd01y X-Received: by 2002:a17:906:385a:b0:92f:7c42:8637 with SMTP id w26-20020a170906385a00b0092f7c428637mr2356849ejc.30.1681379124278; Thu, 13 Apr 2023 02:45:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681379124; cv=none; d=google.com; s=arc-20160816; b=GhsX3jeptYA9XV6YmDm9MCdgfPkzIt9SMLnK0OQHX1mCcJ4dS+NsZXyYRKFe6xfggi AKejAQdVkV6XFI9Zgw8tVw8cz3Yv1ND2Jn4PLZddtjGk7Dey2VK2l8wizgIh3Hc7LVSL xPT+JtzQ4jgAxY182HLrom1Ft/DLIb4U0rTlyRkOmqJyup3WQVhWEE/lHUULVllTSVyb WzXeiUjGegSD55sWj3eiOYJ3GAs9a5KX0xf+vJvtN+QOQQ5dJIL4FWhCF7n4c8621Liv eqFSz8/J19D0kJACqCgQjefqqqM22Pm8gGeeEbbBRXX8MS1LfmWkdHtPDyBTsZxK1nja iUSw== 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=XKbfmJS2Rsp6HDUshcsYFilbRwryA8EWgXYXVGgHZ+A=; b=lZJfsGse1KqmoX//RFRgZ83RAA3JWYTW0T70ftdzHnJms1jWAFKs9HSYExBgJFlLv1 PqJZmijqP/qdDd9tTZYWcMD5ipAK56KzszbkI+pX88YF8+N/5FSC9WL3HcH0+JHXKyhl VFf/PXlpnnBeDVsY3N/d0VzKl3yVBUChp6I3bIiLcn6JoR35cFISyW6ZLonp2iHN5Jhw dsYqmF5FxJisThTxh/++XlFYq7uxrBR4pIq3evpKSVaAkIshG7TfMNoKBOGlUt3AZ1Ei 6mRXB3t11t0ZyN9LbwgK6aE0fspgsDcp1cW4ZDqnTsctNDwjtFdsbg7r2hUU1XoHdCef qy8A== 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 n12-20020aa7c68c000000b0050480d8a036si1462247edq.248.2023.04.13.02.45.24; Thu, 13 Apr 2023 02:45:24 -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 F33F968BBAF; Thu, 13 Apr 2023 12:45:12 +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 74C9968BB3C for ; Thu, 13 Apr 2023 12:45:05 +0300 (EEST) X-QQ-mid: bizesmtpipv601t1681379099tix7 Received: from localhost ( [255.254.22.15]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 13 Apr 2023 17:44:58 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: wPivafIDGPN/f1fJzfyWBH+ffsnQxDRuM/EBFLeBnziZahZ0RKJfj1FZVGDLX hF16oaZ+5AKNgwy/qNaGOxsBe/kkliM/KFNg3ZknzDvaZ7vsAuxvkh0AlTKUV/u38XJI8ZW ZP/rB8bT3zFllZoDnp58uN2FJ8VhHpnFofUl7WF0tjm4PoWxiS1uu/8MGOQ1esPlhlf9lq+ bMJClhevY+m9uUcvVgUsYKINYf7ENu9JM/lL3f75e1MeAUGpQVKyEfDQcNDSnhsqXIuQO3q 71dwrIDpEArz9FTG3O26VlGhEDuxA6ACryIk19yR3Qb6c3VOQDWsfDjhrnGywoZ0lP/oD5n I939is+/TGIjuIGvY3cCkDuioZ3MAb0rTX6ngHiJUJezJ7WxwXsF4ExIZnERXp8zyeIQZ/I X-QQ-GoodBg: 0 X-BIZMAIL-ID: 13785986235199391023 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 17:44:36 +0800 Message-Id: <20230413094441.56225-2-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230413094441.56225-1-lq@chinaffmpeg.org> References: <20230413094441.56225-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpipv:chinaffmpeg.org:qybglogicsvr:qybglogicsvr2 Subject: [FFmpeg-devel] [PATCH v8 1/6] 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: SrwYuT0eWbJz Signed-off-by: Steven Liu Tested-by: Neal Gompa Reviewed-by: Neal Gompa Tested-by: Tristan Matthews Reviewed-by: Tristan Matthews --- 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 09:44:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41136 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1110940pzb; Thu, 13 Apr 2023 02:45:35 -0700 (PDT) X-Google-Smtp-Source: AKy350byp505IWdtaKLlOue7CnT0doBawmvoBDYeCKx/J+eLSozNqH4Kgz6en29L7QsbpN9JXk+D X-Received: by 2002:aa7:d3d1:0:b0:4fc:3777:f630 with SMTP id o17-20020aa7d3d1000000b004fc3777f630mr1921226edr.0.1681379135045; Thu, 13 Apr 2023 02:45:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681379135; cv=none; d=google.com; s=arc-20160816; b=UbM2s0OTRAcxYoJu5x+YYVYqKw4l7d1AuMNh2xHNveFX51eycHNERuwrlSGjBbUL5A wFl/KWleAT4qFVSF83P8yvVbyfgqPFucQ/I5XuciYW0Jo3QW2Mbpnt73ltx8Syghvdp9 +l/hjCWoKgDq+hv0NjWDc1yqhiV7vMjg99RAUmuVpSflyVqjZdgTGVDeYuWtfeAMaD8O eEWujuMB9bwi6rYgBQQu7pJEsjaoWrZCHsB5GA5cbvGvJJTqyfyaDNRJM+NpA169JYCN FAsQz0KF8e2CofRuTK5tb1Mto/texFbMiZTLLGK5OPkbJXgEJjXKQDk8AJOKx84dXdb8 7dTw== 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=aZK4ok0sq8GEHi9PHBDt1ag4JezYMSQe2bmPn53Nq+4=; b=gt6ZbzjfB84PnY+IEzR5Kk+XOjo10ZQlrTScDJOUpLBGSFtn5Z4yrUhGSs7J0dMKJS K1jrlgf6eQ4h5LlcAE7LJ7vYORvFR5oMPyrCvnqmGLUuOOd3LxrUWZVBbWfrZKpQ1Eu2 kAG4WSoYxhwlOItN2ep/IbyNeCvIYV9yvskaJ9e/2C/aG22njGaHPhBCODfkhIsMi8h0 Hw8vwZaISO8S+IGp3OFa7LCi1de2CiZV+MBor/zVmTWcdTgfOqREZQkP5RBGe3LGYopu 4W9BhMBwOeUj/PpAk9Z0+qDNGInh/vWlwuMYAmTllVB8Wse2XkmcQQr/VkUkhebHrUps VWxg== 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 h5-20020a17090791c500b0094e6ad58389si1371108ejz.321.2023.04.13.02.45.34; Thu, 13 Apr 2023 02:45:35 -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 31F9468BCA6; Thu, 13 Apr 2023 12:45:16 +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 B1E1268BB3C for ; Thu, 13 Apr 2023 12:45:08 +0300 (EEST) X-QQ-mid: bizesmtpipv601t1681379103tzv8 Received: from localhost ( [255.254.22.15]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 13 Apr 2023 17:45:02 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: RdkzUaxjIrfxAfvkFdLZ/jwl+IHR5QdtL+eg5Alx2bNncY34vwQ1hmjxdlYQt bV+06FIWZkx4cL2UKYftH2ttgBr8hL9Bhmvg1E9qjIV4nE1/ZI8nVP6RMWadKIa9olWL+4t dbC6amzfmG8CpMFKIBqrHlWvjl+WwGuJlSUVtYWf00xIWsCFa39gt4Jr7r4rf0nCduS5mUp qykhWuJB9TKO0o7LgpBaumR1n0uMba96zWcPxBij9rC+IrbppZDEgjsrF5QHh5WWlDTXRuO AraCbLzrOHbviVu9KwiiYW7YoNVASrVttFju5guZnpYXO4MPLiS4GSsUTSIudwcWn87HhVd iAgim3ok1F9YURnVyBeU6KDg/k1hzenpJ2S3KzoALtqlDqq6Nj4ficzhT3i7w== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 17191933923460761719 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 17:44:37 +0800 Message-Id: <20230413094441.56225-3-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230413094441.56225-1-lq@chinaffmpeg.org> References: <20230413094441.56225-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpipv:chinaffmpeg.org:qybglogicsvr:qybglogicsvr2 Subject: [FFmpeg-devel] [PATCH v8 2/6] 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: tbq+fUDz1Hpw Signed-off-by: Steven Liu --- libavformat/flvdec.c | 58 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index d83edff727..6a1e6e7ff0 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,16 +1277,23 @@ 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; goto leave; } - if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4) { + if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4 || + (st->codecpar->codec_id == AV_CODEC_ID_HEVC && type == PacketTypeCodedFrames)) { // sign extension int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000; pts = av_sat_add64(dts, cts); @@ -1267,7 +1309,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 09:44:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41138 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1111102pzb; Thu, 13 Apr 2023 02:45:54 -0700 (PDT) X-Google-Smtp-Source: AKy350a2AoH92+JS0WuK6SW09Nzfdy2xDcLoUOe3saDyAX7H6nLheWqAEA7XSbG426zLZGKGoxbJ X-Received: by 2002:a17:907:608e:b0:94e:baaf:3c30 with SMTP id ht14-20020a170907608e00b0094ebaaf3c30mr425001ejc.14.1681379154366; Thu, 13 Apr 2023 02:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681379154; cv=none; d=google.com; s=arc-20160816; b=018geLhdHxTs+pQRYi7LnTZiVGBgDyZMt7oKrmn6gV2wxKePXquz9qiReNB8qFDTMp rn1bD1a9vEvQn9TAJIin0Y6wVDMWtUJk7/mRgXMmORshzSCNkJ2lBCPODJn2MuYYz5qo K84LKDxLdtcbwecR69vKRaz3GPurx9nJgcXBWxMHsGzkttkloDhvR+I89xO+FEuHtlqQ 51++Wf0D/0Gt1Qj4TnvJsWN0YcL4r9bAF4yM7gnX3uyW3+tMOBW4YpoAnmeywjU39N/v SdIOww6UcBPt8g0qcb0bB5XrTp7f76TezJ4YKrfraL65aaaoUziXAFAspdO5ga++zT7i O9Hw== 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=nWVC1xsmnfKVcDnwNYKopfgAmskXvCzWcP6KPWow1XS4REIs0apbtp5FbvKnUhBBFp z4ITcuA/nCpkIEQ9AIpJoDwuxEhj0lTcxxnSlbsOxkI/cFVJZaikMFbsMqq8lpMgP4Qr IDp0JVpymTAfpdVFz0jlvKjwEhhOhWE8XpKhgettU44jWUHVtWeiNqMJgqPIvgLQm1d1 tWNLwcGxpFKl/9fIvKMjpUuN7nUx0e6pL07KLUu9HzLjiSuZXSF2ts8IxtZNDfMEWR/T wr85yR48WUljxO6WeMiXzY6zlyqvTQ0+CZMIjjTFqatNfrNYNPBxecOO8splPQuA0vmM wz8g== 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 d19-20020aa7ce13000000b004bd1a7dba86si1531892edv.410.2023.04.13.02.45.53; Thu, 13 Apr 2023 02:45:54 -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 4D23668BCFB; Thu, 13 Apr 2023 12:45:20 +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 74C8D68BC29 for ; Thu, 13 Apr 2023 12:45:12 +0300 (EEST) X-QQ-mid: bizesmtpipv602t1681379107tkl4 Received: from localhost ( [255.254.22.15]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 13 Apr 2023 17:45:06 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: 8shb2sp0cl9zvuM2fqQecFUckid1haYCNoNVWd2yAjg8s+k6SliE2Razlw3m/ z27UburAest0J+u4kfcuwc1bQq0TG+S6tAPz6XF1E1QF9U6fLOU2igo8U5+XY2AhLWH/0ua Idib6KR2yGL2TvBp6x1gFZZbXVlFdxB3BwUJFk0av2MbuLmc52CV5IN0U5quuvCe2GX1e6j 9Lu4bGJe+dDVMgbjeOuP3GTsn9/pLED5c2M2HHD98s0ssEQGDz0SD8KG01WoqirHfbFbKC3 VK8jajWq67+3EQYd+jRsuzjffgEm54eHm+EzT7Ki5B0tEC9rJkmuon+OARvYdijUV3R/PVc CsRQz2rvkyvs9fzjOgC0NSHP4Rrvt2Yodcz/396M7tHF0haijP+TS4Qy8DQrA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 12395575435659898709 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 17:44:38 +0800 Message-Id: <20230413094441.56225-4-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230413094441.56225-1-lq@chinaffmpeg.org> References: <20230413094441.56225-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpipv:chinaffmpeg.org:qybglogicsvr:qybglogicsvr2 Subject: [FFmpeg-devel] [PATCH v8 3/6] 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: tuAn5B6GoxCy 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 09:44:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41137 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1111019pzb; Thu, 13 Apr 2023 02:45:45 -0700 (PDT) X-Google-Smtp-Source: AKy350bWyR2n6AvvAKEz4xBYXGSlI+B5K150rkLNdEWg4qS/n/RzgBqs7ugJ/HE/ZApUbk7OeJeO X-Received: by 2002:a17:906:8e8e:b0:93e:5baa:d443 with SMTP id ru14-20020a1709068e8e00b0093e5baad443mr2014348ejc.63.1681379144702; Thu, 13 Apr 2023 02:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681379144; cv=none; d=google.com; s=arc-20160816; b=qnyiTjjddH6a5UnZOZF8vyJc0GjHfJC7PtCUQBbEXJjaAj27uYocXqBB5CcLiH+Uun yWQ5OGpjPgAbD9LdPMLgXl8SZ6z8VZgKiUXwcVz0Af/bX+NK4Xk84loOFEeIEQBow1v0 ymDWmTkH1XH4sWDs9i0HgHaY3tsjOIhMcQtjwTknvvcptUeLNb3t2smNAbYbllhNj3f9 VmRelpVQ25x9xgZzHqYZtTYM7IaSIEoIPgLp8VzYLpD8s+8SRyo/A2G/6F39QnCs9V+Q n88vRDSRkZrspOIDu+wA/2I4C3BiRXeO7zUPialOf85E66AlKqvp/+N4H/nkbktXHfAm BpNg== 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=yJrCxPMfVuyEZymV25aZK3P7/Im0Qjv0K6oDot+7Rd4=; b=xiwnNojerlqnXShnPVi1QHHHuJd6keV2SQIStSyVhLsn6zkKhE50GWKRQM85csLCa8 N+v2FE795mAuSGXhdlO/cCPJ9Iv1eZwM79+IVTTSpnWOSSiA1B5749aPvHVhlmxBCUez XiixRIVPiKhYPn9lFj5ggIu17lBTqW6JfKYCQ9QHpByXOrFbnfXKWL0rMmMpisGj+tY9 rXMksCr7k6+iJQfqETacTS1tiqCZx9bGxPTk6U9tnRnkVgS0rb+GyG8ahJowgSVW+luQ 2vva8TR8q2W6I5YfS2jFQU7cHg2KwARSgMCeXX/smWflbWmpchOhmxTnmtZU9lBDb6YO MBdA== 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 kb19-20020a170907925300b00947c7226bc6si1436040ejb.150.2023.04.13.02.45.44; Thu, 13 Apr 2023 02:45: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 4976068BCC3; Thu, 13 Apr 2023 12:45:19 +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 4326568BCBF for ; Thu, 13 Apr 2023 12:45:15 +0300 (EEST) X-QQ-mid: bizesmtpipv603t1681379110t0do Received: from localhost ( [255.254.22.15]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 13 Apr 2023 17:45:09 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: M0bc4q6Ne4vs1ymRvHq53jn4Fe2GJXJarkB76WhnU0C0hlmZKbn7TsO8YWWcd KHAvCCwLvBZ4CHsPusKJDB2PvqjHhdl12q99fCXaYFU2V7Koh3+cfOq5x2Nitqar16xo8Gh Uv4PogbOUAyM4Am3CD3tsq64XufxsTHBVcpQPDFJifQzGiJq3+DiyzUgOR3cM2UB6ucY5xc g1SOfIVXgMcbzlfDsnYjUvowukSGIoYeB27o6h4Bqu4oN3zIO5+OeHE2CsEXfC3sDksfZsP gThMl70dWinlE/7FReeJP7ia5sB3kbNsOQzehBZ/ExFCW/N/qZJrMaqj1KxGpjPdf2YMWeC cTo1RIcZhT8Vyodk7mKWuLTPHwZK4q5bF0c+mOS+H3SrhP6amE= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 9907064926686496026 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 17:44:39 +0800 Message-Id: <20230413094441.56225-5-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230413094441.56225-1-lq@chinaffmpeg.org> References: <20230413094441.56225-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpipv:chinaffmpeg.org:qybglogicsvr:qybglogicsvr2 Subject: [FFmpeg-devel] [PATCH v8 4/6] 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: nDPkJ7c8vyiY 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 6a1e6e7ff0..98a2231559 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; @@ -1309,7 +1316,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) { From patchwork Thu Apr 13 09:44:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41139 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1111184pzb; Thu, 13 Apr 2023 02:46:04 -0700 (PDT) X-Google-Smtp-Source: AKy350Y5yPXrRvPNjNyDA4XQmyMqOlRZBBk3VnMsEUteYFlT9D4v2vv+fzvULBkzgCvDFOke/+SL X-Received: by 2002:a17:906:8043:b0:94a:959f:6d58 with SMTP id x3-20020a170906804300b0094a959f6d58mr2531414ejw.18.1681379164404; Thu, 13 Apr 2023 02:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681379164; cv=none; d=google.com; s=arc-20160816; b=L9L8Xy8MZSfB77LOLruvQcnLParRqO2qCVoUCPslkMc6V1uozYWkEHzTY1t/tTR6H7 TXFK7T5RU4NASJAw6yafr5sy/nxcSHVLowpGB8F9Ikfb57LYeELs2yti+BwV2/CWRJMl 6IHgrN4WxVpCSnA9ktedAXlMh12TXwh0yGyiGDID5W5XFyPrSU4fuoDFESpW40ReA0/F y2lLVI02dmzZQYqn0iNvyuc/LO/KKDFrvUL8EFjQ9Ic44j95BNul4GxZ/cotAOp2Iuiy flmdKzLQADmsC7oGx+rIdHiD0IBUcDOg7r18f/XdgGzTllPZtk+I2RXtW3ZYtPtptKxw hOHw== 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=p/bq/ozE/dwgJMzxwuD+9Q0720TUJx3MW4rWQw8gSic=; b=QEUQZS8bELnC/Hk4jYAlrVpWfPB/gEoKC9AKj6Ib4/0Roc4rc+1F2sKEqs2Gh50EiU WmsTIzV/fxiDvgJqwQGyFgCKP0FnpKdWx59rtNFMvh/6V3aDouYNkvjabMgUe7wmdeU0 5Cs3wy5dvXcjR3xKy6vK/7Ucnvgw9LFisjZBWHqxbVI9JzZEB2Y4WkiV2iqdWlaz8+u8 9BDRqbyMEi+Ya6nPnIGUdMi6H88JhJDvDplyOTt/N5s1KUGeJjeSVWjbRbsVpUuQILIJ 9IVsrOWNttCkHwxJS5MZj9v1ZbMAynXgP+RRRIPYwg4teKJhQUeKFdXFsv+PkhlNlowP 0dxQ== 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 gi15-20020a1709070c8f00b008e1cbdcd3d1si1613965ejc.97.2023.04.13.02.46.04; Thu, 13 Apr 2023 02:46: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 6B7DB68BD13; Thu, 13 Apr 2023 12:45:22 +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 189C868BD00 for ; Thu, 13 Apr 2023 12:45:19 +0300 (EEST) X-QQ-mid: bizesmtpipv601t1681379114t6of Received: from localhost ( [255.254.22.15]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 13 Apr 2023 17:45:13 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: 83ShfzFP0oDUDTLbHvbhynG9xQ5jp00ywVL3Zi9pYNQSrqthTOXu/f3gbRreQ vWbHgVSN//NWVxhtw+XZKmfQSbG2r7RJgUWycLNBqoc2xrwqZrvui/HI1yXG351lWizvtc4 MY4LTS2V6qIoo8mEZo2tl4kV870UgorMs1E/ta9VDSfbUx8nvxxgbzlHvv9dEsDCEVoN8M0 6kdCoJlsRj8Qw/Gp7OBZZ2B+grZ8nCb+y+HrIMqKMzxEhDQuhOYTDtkMKBzLrnTrYG7jRrw zzdyDRNH2ZuDkiXl/AQ/SdmjNfIDZHDbPr+ZJvSmbNsF22P+P2yTqQ0zsgUVaMq7hUk3SVu EjY8FFud5xJcJHO3AxzbeUM500CbkPkFiASN1acqRbJfDH691JLrsxlktzi9g== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 11568931875665239399 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 17:44:40 +0800 Message-Id: <20230413094441.56225-6-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230413094441.56225-1-lq@chinaffmpeg.org> References: <20230413094441.56225-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpipv:chinaffmpeg.org:qybglogicsvr:qybglogicsvr2 Subject: [FFmpeg-devel] [PATCH v8 5/6] avformat/flvenc: support mux vp9 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: oJmUJI2JSakg Signed-off-by: Steven Liu --- libavformat/flvenc.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 7b43ecaefa..400dd3d573 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -29,6 +29,7 @@ #include "avio.h" #include "avc.h" #include "av1.h" +#include "vpcc.h" #include "hevc.h" #include "avformat.h" #include "flv.h" @@ -50,6 +51,7 @@ static const AVCodecTag flv_video_codec_ids[] = { { 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_VP9, MKBETAG('v', 'p', '0', '9') }, { AV_CODEC_ID_NONE, 0 } }; @@ -497,7 +499,7 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i 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_AV1) { + || par->codec_id == AV_CODEC_ID_AV1 || par->codec_id == AV_CODEC_ID_VP9) { int64_t pos; avio_w8(pb, par->codec_type == AVMEDIA_TYPE_VIDEO ? @@ -543,9 +545,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) { + } else if (par->codec_id == AV_CODEC_ID_AV1 || par->codec_id == AV_CODEC_ID_VP9) { avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeSequenceStart); - avio_write(pb, "av01", 4); + avio_write(pb, par->codec_id == AV_CODEC_ID_AV1 ? "av01" : "vp09", 4); } else { avio_w8(pb, par->codec_tag | FLV_FRAME_KEY); // flags avio_w8(pb, 0); // AVC sequence header @@ -556,6 +558,8 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i 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 if (par->codec_id == AV_CODEC_ID_VP9) + ff_isom_write_vpcc(s, pb, par->extradata, par->extradata_size, par); else ff_isom_write_avcc(pb, par->extradata, par->extradata_size); } @@ -649,7 +653,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_AV1) { + par->codec_id == AV_CODEC_ID_AV1 || + par->codec_id == AV_CODEC_ID_VP9) { 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)); @@ -858,14 +863,15 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) 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 || par->codec_id == AV_CODEC_ID_AV1) + par->codec_id == AV_CODEC_ID_HEVC || par->codec_id == AV_CODEC_ID_AV1 || + par->codec_id == AV_CODEC_ID_VP9) 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_AV1) { + || par->codec_id == AV_CODEC_ID_AV1 || par->codec_id == AV_CODEC_ID_VP9) { 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))) { @@ -886,7 +892,8 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) 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 || par->codec_id == AV_CODEC_ID_AV1) { + par->codec_id == AV_CODEC_ID_HEVC || par->codec_id == AV_CODEC_ID_AV1 || + par->codec_id == AV_CODEC_ID_VP9) { if (pkt->pts == AV_NOPTS_VALUE) { av_log(s, AV_LOG_ERROR, "Packet is missing PTS\n"); return AVERROR(EINVAL); @@ -999,9 +1006,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) { + } else if (par->codec_id == AV_CODEC_ID_AV1 || par->codec_id == AV_CODEC_ID_VP9) { avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeCodedFrames); - avio_write(pb, "av01", 4); + avio_write(pb, par->codec_id == AV_CODEC_ID_AV1 ? "av01" : "vp09", 4); } else { avio_w8(pb, flags); } From patchwork Thu Apr 13 09:44:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41140 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1111281pzb; Thu, 13 Apr 2023 02:46:15 -0700 (PDT) X-Google-Smtp-Source: AKy350bW8nl7sxwd2FRYJTobOcPpV9y+XZjuO/+4CuuHmNatXJo08XvBdGkJWr+w70dfel6m22KX X-Received: by 2002:a17:906:a0c7:b0:94a:89d0:3ee with SMTP id bh7-20020a170906a0c700b0094a89d003eemr2166942ejb.23.1681379175593; Thu, 13 Apr 2023 02:46:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681379175; cv=none; d=google.com; s=arc-20160816; b=hcDyPAmbaHdhKK4hQlK+qfCzSHmUiD57e+GGeM6d4saETsQccm9wAoU/Vwai4QqrrD FXIMUn4HQVRBYpJ9+oKub9nERhZvrOI3eaZtwxEKDBKc4xXL/8+zAY4SbT3MiIrDJS1f P7BHJsG0TXaGUCRcDQOz0CGG3hbWyMGEOC5d+wG8Tb9C6QN2dq7XykwC7POT85Ur6ph7 qvT5f76fhEF0gkeZtZA4SRTmxzqNZbDnVcrSLfaA3KnIZBkSLzO40DWX5Nlfp3U7H5jU kuVaVmINAUHU5vPjfJLf0B39P+Q/7MAAk1OU3BqFYJlxmrOG3U5l3cQ0su8M/9JWvR7f fsTQ== 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=JKU2GCg8MIz+NYvT9yX+LbjxXAX2E8wJ+FoCmlNhztU=; b=pgOzS7uj8dy+h8YKKgtm4Fy6opnbpRbXzYBvISpODH+noUwqmHFtEgsBhemS7H40w5 lzVGDL94tfz0P41QXuwZ95Cne3sdFX/hOM+uPOckoUFPZGm5EAv+Dt+fn818ZGhMVB26 xXrC9KJ0KpDVCVoKPFGORaizH/N+xnMwztUaF9It9AsB0uHPPBZHa4sHW0uoLePuAbmO I1snLd1oqF0XwTDL74HgPT6K5VfwYdRPNlP/+sac3Tgrw0m45OhqZk6NCvaNqWoH/5ke tcrCMhkYPXBEeGdgdemdYlD820BRdpR2KSWgs9BqZsPKNwyb2sDEsagP5neus3P4IxSQ 1cNA== 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 z23-20020aa7d417000000b005021d2480f8si1287504edq.282.2023.04.13.02.46.15; Thu, 13 Apr 2023 02:46:15 -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 69E3A68A7E3; Thu, 13 Apr 2023 12:45:26 +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 D6EEF68BD27 for ; Thu, 13 Apr 2023 12:45:23 +0300 (EEST) X-QQ-mid: bizesmtpipv602t1681379118tuuc Received: from localhost ( [255.254.22.15]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 13 Apr 2023 17:45:17 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: 83ShfzFP0oCClSBZY12KcrsRorwqFWdrbz5794F8b+uOLxBNmXavL58CtQE9F dVRWTQCDA4B7BmNb9jv1PFaYCHv2tN2vmNs4Dydvw94poi1QkkhQ6xcCNtaNhQrjoXMw2w2 fPkbKPFGcGpyRWP6BPhG+dfkOw/0GU1R1F4dsUHvM5G5cPurtG4bh5vPo4ewN//99sXe382 YIgisD3IMkRV45Zni5t9R1jahZau4Wn3FdRjdXAfiClzucHAMnx+GmvwiVryT9aM7bq6ybB M2sXUgHulrNrAs2fFa3zzz3pYPiQvBvx3OvacxRgKL2/JNCXuwZ+rAjRv8HCa+lKBMOqmxg zXLfqJ0/i20p1/cF6l73624uXUW4ZKzsGLSY9pzkqTVd0CExU8= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 2538892541323463087 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 17:44:41 +0800 Message-Id: <20230413094441.56225-7-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230413094441.56225-1-lq@chinaffmpeg.org> References: <20230413094441.56225-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpipv:chinaffmpeg.org:qybglogicsvr:qybglogicsvr2 Subject: [FFmpeg-devel] [PATCH v8 6/6] avformat/flvenc: support demux vp9 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: ihK3six3CjXY Signed-off-by: Steven Liu --- libavformat/flvdec.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 98a2231559..bc93c23166 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -320,6 +320,8 @@ static int flv_same_video_codec(AVFormatContext *s, AVCodecParameters *vpar, int return vpar->codec_id == AV_CODEC_ID_HEVC; case MKBETAG('a', 'v', '0', '1'): return vpar->codec_id == AV_CODEC_ID_AV1; + case MKBETAG('v', 'p', '0', '9'): + return vpar->codec_id == AV_CODEC_ID_VP9; default: break; } @@ -365,6 +367,10 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, par->codec_id = AV_CODEC_ID_AV1; vstreami->need_parsing = AVSTREAM_PARSE_HEADERS; return 4; + case MKBETAG('v', 'p', '0', '9'): + par->codec_id = AV_CODEC_ID_VP9; + vstreami->need_parsing = AVSTREAM_PARSE_HEADERS; + return 4; default: break; } @@ -1285,7 +1291,8 @@ retry_duration: 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_AV1) { + st->codecpar->codec_id == AV_CODEC_ID_AV1 || + st->codecpar->codec_id == AV_CODEC_ID_VP9) { int type = 0; if (flv->exheader) { type = flags & 0x0F; @@ -1317,7 +1324,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_HEVC || - st->codecpar->codec_id == AV_CODEC_ID_AV1)) { + st->codecpar->codec_id == AV_CODEC_ID_AV1 || st->codecpar->codec_id == AV_CODEC_ID_VP9)) { AVDictionaryEntry *t; if (st->codecpar->extradata) {