From patchwork Fri May 12 03:58:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41590 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp5097141pzb; Thu, 11 May 2023 20:59:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6vIGmKIV4O87XqOwjE4rbp5qUZRKuSGbYelbLZ7L81AKifNp8sHB6QTyWph2uBvHxjCa6y X-Received: by 2002:a17:907:2d0e:b0:967:13a3:d82c with SMTP id gs14-20020a1709072d0e00b0096713a3d82cmr15364725ejc.26.1683863977801; Thu, 11 May 2023 20:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683863977; cv=none; d=google.com; s=arc-20160816; b=NaJSRi7oSOI6mTwUP8odM7MZJJozQb04Bh9yu/PgOTyaq2HHx7OTZfWcnC9v3ippAE +Mb4v11kNo2IKhi67TM4KDspQ4yiNwAuLdD3YJP0thakV/E4FeqiclBTKLvSUrz7BkcH BJdoedfcs3gCnl+8Mcqpz8WcYw1mYSUeX5uchHJAl9kXNmf7g6+qsZphnNgDUBJh5b0X nH2C/Z9uK5s77Sq3wdUBRPGI1H1q1Zy7igKTiabvyIDZMa6saige7GCvr11aIJxpgjqR 4Ej2ny5J6350u/HE+x1zFHqZdRibJZBRgCQnF3Q+cs+9fmCtXK1AQo3Gp5oOK17msXkM kw9w== 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=Qg7uugO6uqQCX67+SdNELVYF39/WDPRDFt1+H7toQ+s=; b=Zw2xkp+oHM/9Prmt6yuxSWcp3WWrckOcymV03J0i3TFTl5fiVTjGAo/8rVOD6ciht2 e+FEUWgnePFkUyoFDlR9gNoMiywtzjk7grChvwJrw8Hwkz+ujJOgq4xeT6c9dmbO5Jpo pEKaNijSKfrN/ST68TdMLXoCG298v4rabyZS9OBfFDEfrRVa0ousYTCbcJ3DAAh0IgIY P8FkBnrqYHR2phB7QQnVlFBz3/hSuBNPPmMyUmu8A9HitOVhjHHqXZadXGEiVg28tWnb 3YnuZrj9T9kehilgpfBD3TqanxmJNf6HotndXYRVcK+gkU5iRcocDDU4cK1nBcSKxiGg gwwQ== 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 g1-20020a1709064e4100b0094f3a2fa2cfsi6095047ejw.146.2023.05.11.20.59.37; Thu, 11 May 2023 20:59:37 -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 6792D68C16E; Fri, 12 May 2023 06:59:34 +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 BF0E368C15C for ; Fri, 12 May 2023 06:59:26 +0300 (EEST) X-QQ-mid: bizesmtp90t1683863960tcueyfl2 Received: from localhost ( [103.102.203.204]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 12 May 2023 11:59:19 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: bYR630AeiPhyCgMAOSoTcgaUE3LeFPSyKOoqCeMGdFKDYwI4mavl2nbkL/iN/ 0lxSmP47e52QqVOboM2xwL/btXtWhIiPx25v2G7ruJna7tOH0YsrPQxc1ryRnybCZpB55yl TVijbfnd/5g6eH98c3YRqaSkXi9nXKNYCh0zvBZikmO7o0easkwmpwZDQcPYtNPP2SnGrAw jjU7owdOkaTDqohm0IizfVM+XhLKK5Qs6PnUPRd3Fsdryv3PvStsw2nBu/U69qJUq6ESZ7j 0/qwf65NPBVn2KdhWj5jQ3vH3eDQmBs0/BjZKHZN1sHAMGaYLgCoVkDc03TKmAXiwwolq4r RdFDkWPpKrlwHrBm+gdeu0UwgNGbUif3AiHRLWLiHoKVHtAA1LHP2OkIHERgw== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 5568791223798019172 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Fri, 12 May 2023 11:58:56 +0800 Message-Id: <20230512035901.22731-2-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230512035901.22731-1-lq@chinaffmpeg.org> References: <20230512035901.22731-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Subject: [FFmpeg-devel] [PATCH v9 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: KcE5CRP9xup2 Signed-off-by: Steven Liu --- libavformat/Makefile | 2 +- libavformat/flv.h | 15 +++++++++++++++ libavformat/flvenc.c | 38 +++++++++++++++++++++++++++++--------- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index f8ad7c6a11..1ef3d15467 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -214,7 +214,7 @@ OBJS-$(CONFIG_FLAC_MUXER) += flacenc.o flacenc_header.o \ OBJS-$(CONFIG_FLIC_DEMUXER) += flic.o OBJS-$(CONFIG_FLV_DEMUXER) += flvdec.o OBJS-$(CONFIG_LIVE_FLV_DEMUXER) += flvdec.o -OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o +OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o hevc.o OBJS-$(CONFIG_FOURXM_DEMUXER) += 4xm.o OBJS-$(CONFIG_FRAMECRC_MUXER) += framecrcenc.o framehash.o OBJS-$(CONFIG_FRAMEHASH_MUXER) += hashenc.o framehash.o 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 721f062811..35e198fa15 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 } }; @@ -489,7 +491,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 ? @@ -532,10 +534,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); @@ -832,13 +843,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))) { @@ -858,7 +869,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); @@ -903,6 +914,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) { @@ -964,7 +979,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 Fri May 12 03:58:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41591 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp5097205pzb; Thu, 11 May 2023 20:59:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4+zwNVqpQW/Yrwisjvl1qhutOCVzBpM+vesMM4iE1knheB4T4p3as/sJZ53FU4lXt81Q5h X-Received: by 2002:a17:907:1c05:b0:930:f953:9608 with SMTP id nc5-20020a1709071c0500b00930f9539608mr25214544ejc.0.1683863986166; Thu, 11 May 2023 20:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683863986; cv=none; d=google.com; s=arc-20160816; b=J0I27tvJHqhxw1tdxURTdRemSHNfypShwGQnzfS/z9a+qsQCD65OcQWIpnQJ+KfCi7 0IZQMlqkHHpBGipetN3xOdjGY8DjExFH45/gjQZH0Nj2f4YI6hH/H16cJC6JouusWmcR pLquBk7Ex/q9B0GT+oroElraAh8SSVyhQ+xqGktjrvTuNnd2cb1nZ4Uw2d+CTyykF1WF LtJ6mm3cEoi7XsR8dh6VsPwz1K6UCBtRQE0NS8+GaQ7WR5Xfug1HNkDu6Vy3vNva0MAi xhcDeQdbMJfbebA4gp1FKEmrsDgFTkhCOMuv7vnWok+R21xSKzrJN4Ay4+IXbXMoTMC5 scGQ== 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=fI3wcxWn9G6Ir8wXwMdNpSMRZrLE3caQ3I0TuNFHFT+75KZDrVHLVRvNUN0g73STL7 4UMFZCSTnPZc6FUe6+Q3bN/XwhoQZsw9ubAOqvENudJmkh6uBtlaO5BkFaR8qcAaS5oy +M3yDzCkWpYPwkKjTdVWKFFesUpXHrfQcFCo+korEA6w/OZoZFPHoWY7VEokNCalVjYu kZhJQpNw8L2MVh4gMQ/AVYKabWwu638n+nfjVDgwg4QrLo9sMxIau9S/mULkRXi67sa+ GK9rCuEP1DNHp4FDe+MW+Zk97IuFlP/V28ij/U/xkLpU+ypixYgIFcCEd57Mj5EYjMZZ vsDw== 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 br24-20020a170906d15800b00965ab02c96fsi7057561ejb.894.2023.05.11.20.59.45; Thu, 11 May 2023 20:59:46 -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 56D3C68C176; Fri, 12 May 2023 06:59:37 +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 399AA68C163 for ; Fri, 12 May 2023 06:59:29 +0300 (EEST) X-QQ-mid: bizesmtp90t1683863964tcoqsrxd Received: from localhost ( [103.102.203.204]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 12 May 2023 11:59:23 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: RFp2QSjOiS7CRNeKo+vK6o7V/zCOSkPSiYIImpiSc7nF9FInx6/xYupnvfEo2 b86gEWd9N2PTvHu7zdZ8tHBnz5y0crhaMTmVIQUQJ7nJatCGth/8QwfAhFF5xzm/DipqjrE cgHK1qjslgK3Xvqz4MVZBfeGUrWopJx5P7csctsi+GN/CzuEYd4mn6iESjn9GcLOJG8ba5x Dtcjflu6ipZiiEJr8bAsb2NRklYnHUYu/jaJ19T1LP4tOtnTcQC2hhCZuHtguCrkzlTUn+7 Anh2YndSZp33cuJllUPD0Hcqrjpuvm2WxORM22Ej9+TMubaJvzJuTXNmEJXSL9mRRkpzjNi vzTArGPDMRoO+lY7thFZLDlbIvY29ImUR74X0BmX0+zir6uOfYbag5A68onQQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 16310214271832428492 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Fri, 12 May 2023 11:58:57 +0800 Message-Id: <20230512035901.22731-3-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230512035901.22731-1-lq@chinaffmpeg.org> References: <20230512035901.22731-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Subject: [FFmpeg-devel] [PATCH v9 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: NPAWeHEBv8Rk 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 Fri May 12 03:58:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41592 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp5097272pzb; Thu, 11 May 2023 20:59:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WKy+jJczktN1/WawHl6LOkMPkKrVb4d+2mSExRAIrnzEPsuKnBYtXD0K59dkn6flEFbud X-Received: by 2002:aa7:c44e:0:b0:50b:d819:4fd2 with SMTP id n14-20020aa7c44e000000b0050bd8194fd2mr16571792edr.17.1683863994736; Thu, 11 May 2023 20:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683863994; cv=none; d=google.com; s=arc-20160816; b=gGRLT08XoLR/NHCCEIYeOwCWNzcqXar5JgqHjFJ2yVDPNxPD4H8fRz32wWDoQIWgRo A0xB9Zov86+n7xqYBiTvkxbBBFkWXzjXmqbm2n55gZYWP1g0TOWKtZIVyZvV5AisVr49 fRLj450s6Ag+ApN+YTOxYcC2203DdZP/IqFSaK6ITn6ahyB2t0qWTGR/B2E1pQBXUpUB iyadbEpsbZ42TtxxeoZnqYjrHt/ysZ2WuioZMeMXiEerb8K4h6WfhwZiDuK9mnLIcy6h yvfP/evmzuJ/TdBT/m+PJPAvfJBaFbPoo0GXgS7rKSlMBFs+G45cHJKgVVGrizqoqQbZ yyKA== 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=0O0kUGD5r8lgXEiC2RUfiZ1ccVRPd03lWds0dqdVEq0=; b=LadN+LLj1dwbzXsegjIeBO15rIggYzVgWkjYZq194zUvRtCiHvcGrKUo2IxQ1qLjeA EwYcXrQMzsE53e0+Kwpz0pl+JLo8MNCJ7aNh4nUEvrt+hpoKh+EQAspPm0wbxfuw7KG8 kKeJt+Z2Y3RNnQBh1XjqsHoHcgwOopANsZCp5+NH77inG/srhd9NuKibItO0K4ooZEIi GfuF3m1BdmYRZcTKtltLlxWyvwb6EuGLxjqHHRw054pnLJxbXDEDTPV+xkBhZTXPbqRL lhwmplDqtTs2M9LNvLl3nb7L/B0zzGgdK6O9gc5ktHi5dQSeFEJp86O6RFKgnWUlBPsj BeOw== 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 v23-20020a056402185700b0050bfc1ca190si5739459edy.673.2023.05.11.20.59.54; Thu, 11 May 2023 20:59: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 62F8B68C14D; Fri, 12 May 2023 06:59: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.154.221.58]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1D82468C14D for ; Fri, 12 May 2023 06:59:34 +0300 (EEST) X-QQ-mid: bizesmtp70t1683863969tamejhnw Received: from localhost ( [103.102.203.204]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 12 May 2023 11:59:27 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: 4lisvO5/zj9CIzvcI1pTOvPDGnXwm7r9FiV28UHZMfbIkbP2RRm+acnMhtaw8 HhL5iR6/Yr/sB9kBFRjgSCojBJRXncsctppv/7FWZmEw9jZU6jcy4dibzC7blM1iMALlRNI u+d2qKb3yoCickaW1Ia3EUYiEKFW0z3ZUrruBmSJ5nWDHoXQf3nZfL9r0GhNngv8ERtY6ti aIuEjQOdJN/zm3prRu6H4HyvHxlfzeV+9XeZ68dRWG7TdO/6AMy5SETuapeTrudgPLO1lMJ KR29sCbJi2/uPEqVAJyI60Nwm6jL4wvYlMc/YBVX5gkzkIy9+llobiX9iWWlSSU/ZagQ56q lrZSlEQX7XjCTf30D/BpGubEZKJ3SkZVWURQWC9UtsdVg2oYO4= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4094020439121217283 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Fri, 12 May 2023 11:58:58 +0800 Message-Id: <20230512035901.22731-4-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230512035901.22731-1-lq@chinaffmpeg.org> References: <20230512035901.22731-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Subject: [FFmpeg-devel] [PATCH v9 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: W5QtOVY0pOei Signed-off-by: Steven Liu --- libavformat/Makefile | 2 +- libavformat/flvenc.c | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index 1ef3d15467..c868e1626c 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -214,7 +214,7 @@ OBJS-$(CONFIG_FLAC_MUXER) += flacenc.o flacenc_header.o \ OBJS-$(CONFIG_FLIC_DEMUXER) += flic.o OBJS-$(CONFIG_FLV_DEMUXER) += flvdec.o OBJS-$(CONFIG_LIVE_FLV_DEMUXER) += flvdec.o -OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o hevc.o +OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o hevc.o av1.o OBJS-$(CONFIG_FOURXM_DEMUXER) += 4xm.o OBJS-$(CONFIG_FRAMECRC_MUXER) += framecrcenc.o framehash.o OBJS-$(CONFIG_FRAMEHASH_MUXER) += hashenc.o framehash.o diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 35e198fa15..c1784b332d 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 } }; @@ -491,7 +493,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 ? @@ -537,6 +540,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 @@ -545,6 +551,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); } @@ -843,13 +851,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))) { @@ -869,7 +879,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); @@ -982,6 +993,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 Fri May 12 03:58:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41593 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp5097307pzb; Thu, 11 May 2023 21:00:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ubpLcVxcZB3NNYK2qe6liRZRpSEb20AJB7yOzkp/otYNYzf+MvrEEvWEhPQp5aCDmpGZV X-Received: by 2002:aa7:ca46:0:b0:50d:8991:d1b9 with SMTP id j6-20020aa7ca46000000b0050d8991d1b9mr17752416edt.8.1683864003189; Thu, 11 May 2023 21:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683864003; cv=none; d=google.com; s=arc-20160816; b=UR3rfKXsbqYGUg6bCruH+NTKWqtI+PpggIM36sowuqN2gJ5DpoGEWdZxY90P4hSaLC MMzCNMvKPTzQb/bU8cSn4ehaoObkyylqP33U9B13+UwpnjTz6/cj3yPMVDz3rm685Lse /zjJjniiUgtAXCEywyOMklfRfplhLYIukoB901ilD4y/a9pcrj/g0rc8+p9+bLIdO+xu tKzSqT5hzDssdfjvtHAxzUV3Uqm2NZiMpBr2gqOLJhlbk42JxW3A+FLKKN2bjZHM3uZ1 MUQWOMaHHpJAuJGqAkR/WIehEs5/X5/4hgUP6D+4z2EEGk2qBFn5fhVZai2tFWADg5he gzRw== 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=JqqeZD3BpLnv7LcANpNbkPicf1mFNzlCEKYbRNmMwy/3Yg3XuUK5xS3tjY1NY5HmTo lxwMOK7SSRMeFHS2j1J+jCtRdHty3LOWFB3+ES/rvkHdpAf7qWE+zOpzTEYnWO4FaTad K/fq94BdeoMidZTz+MPEP8I5L4K3BuWHkDxKyevLRv7T/G6OuaumBYBkVFXbVVLzuxV8 x2E6tTUfNPMsEgl78YVl9pmii/r/l92VOyL7m6r8N8gwy16v25Sxfei1rUoPNZDnsGlG 6hBRm7GoCGfBOPUbZE7TAWtIKLoF0T2tJJWFW9h+3FIju7XefNk1DUdEqntIP4N7gAiA Ofhw== 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 ba29-20020a0564021add00b00504ae1b658dsi5613257edb.490.2023.05.11.21.00.02; Thu, 11 May 2023 21:00:03 -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 A012268C19C; Fri, 12 May 2023 06:59:48 +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 56AAF68C199 for ; Fri, 12 May 2023 06:59:41 +0300 (EEST) X-QQ-mid: bizesmtp71t1683863975tu6mh6wh Received: from localhost ( [103.102.203.204]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 12 May 2023 11:59:33 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: 7jw2iSiCazoEvWKWDupEN9pe2Gy7Q1qP1vcMLMRfoUe7r+a7D1o0DYrwnvpPg Mi9fL2oGY/WWw+k6CW/3Fp0sTMFHORDqYeLZcMQcvGZoX55e8EoWXRa1RbV45JgVqobvjLI UTVJ8MnVF1ehaEmO1ETLiK73bas6SfKL71h5uldHqvLQyQQKK+rIVCSTTITfHp5y0qfyH/3 etk8KoWDG+igGfT+03AVXnTvXYchEZz5g4EmgqCYFyD7MaC8+OSkm5Htyxj3viHoFuB9HCL ROnwOhtS5FvtAqDVemiE0kDJM03abPYzgyGJZ0h+6D8MUXX1Kf8I16C/MGVdP8NvU261S6Q CegK8r5Dcv8l2HyjLBVBeL09DlhiTasEjvDQHfD X-QQ-GoodBg: 0 X-BIZMAIL-ID: 1692691690689332665 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Fri, 12 May 2023 11:58:59 +0800 Message-Id: <20230512035901.22731-5-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230512035901.22731-1-lq@chinaffmpeg.org> References: <20230512035901.22731-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Subject: [FFmpeg-devel] [PATCH v9 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: sqS9fVVpoXMS 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 Fri May 12 03:59:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41594 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp5097386pzb; Thu, 11 May 2023 21:00:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7LBZzQt8yBwKehhxLAIAqhoUfk4HDGkDPOcXfD4x6Nl1UIuRjVOaS+jC9NxkZ3LnRF9GDz X-Received: by 2002:a17:907:728d:b0:96a:5bdd:7557 with SMTP id dt13-20020a170907728d00b0096a5bdd7557mr4517085ejc.70.1683864011547; Thu, 11 May 2023 21:00:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683864011; cv=none; d=google.com; s=arc-20160816; b=KRPUMVLmY2XRV0CqXOwxNlSiSDdxHvBGxSMDSB2I9DvHsabgaCPQBruBhVX1u3Yn3k fZTikvg0VEiYIer4Wa39+KrcNbw8Sw/xDKymIqhkYcEnogM99ZwZHYkd1TxU1mHskeof AaCT690enyjcaIz3Qsn6Y5d8QUVn9M1PJPaDv8wgKmaqXQk5gQ3RIgMNHAWGaAi/u6Ez tnG7898Gg4W58BT2aipZhGDLkpcEojizlhNUuvXUDICvnRL8g8TdtR+Oat3FHRm9y20f nO6vZSBLcVlN+j89Zcn9VNcMamBQigmsjzZn140aEUey6VG/qzd/vYyno8+JTpTL/tEb YZvA== 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=b1Sp5oqZAMwakI7a3Zvw4MdnKPyomZo8cXqDnyJamjg=; b=H/kHd38yyf0k3SIqhQCue3GsJVhcusJQfI0amPCOvPoOJTW3vd8HV6rmx2nSLcTMPu sc7WbA4ZXVQEsNbkHLOw6PWo9nLHaE17Hht/fmvTgp2baamUX+MUjUSDSqzRj1qpCW07 yttphrdzKWdLCO6uc6wdobCuRnyxn0dV6tYYVYZ+6J2EjqimowO0fLElZ6QACw/UpDPl mIzHGmdrSLebimF8G5/eQc1Q4D7BEl85FBNgmxelXsDNjlWSAMdtDLbkb8rCtDVE8wjK eHgwouAPb+ZYXEcM7gESms1GFRzVQpnd9r1rSCGC3al3ah4+CjMc3ElNu70yvot/ZjCL gntw== 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 n24-20020aa7d058000000b0050bf58b1f99si4727204edo.587.2023.05.11.21.00.11; Thu, 11 May 2023 21:00:11 -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 23FE568C1A6; Fri, 12 May 2023 06:59:52 +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 DEE0468C180 for ; Fri, 12 May 2023 06:59:46 +0300 (EEST) X-QQ-mid: bizesmtp76t1683863981tuj557jd Received: from localhost ( [103.102.203.204]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 12 May 2023 11:59:39 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: zT6n3Y95oi2crBROMop/6RJiK1eBM6z24efmuJaaCx3o2hRj/O9tAS9YJ/rcB MorC9io+e45PAeT67Nla9wDk7skR+SpGmdHi3vABZ7LQTuoNzSTF5sImVHqSLlHa+uhhv2j Ul+MQqZUL9ZXOW8vhE1orrvWrn/lrTjA0vY6egwBeSRb9Zh/BMuTbMFGR++voL5BwqVCnW9 uLKMpr5UIPLJfEMMnGQpRFqdDU4R1wQcmyvKsh1um+eO++IK0k8zA/GYWpzI+2ywDCx5GM0 eNW7QDfVXqAbjXFrSZCWpnvnjgxtpyEuIkQnHhem/8iWPmFvyIVntqC4SBPUt4C20Mp1I/g YAcLkF2oNJ32MCtLnA91j9cm0sgSo8BrdlYsWyFS0bOuj/4Sko= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 3224015177392742705 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Fri, 12 May 2023 11:59:00 +0800 Message-Id: <20230512035901.22731-6-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230512035901.22731-1-lq@chinaffmpeg.org> References: <20230512035901.22731-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Subject: [FFmpeg-devel] [PATCH v9 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: FsJlXZXDPBNG Signed-off-by: Steven Liu --- libavformat/Makefile | 2 +- libavformat/flvenc.c | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index c868e1626c..16cfe107ea 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -214,7 +214,7 @@ OBJS-$(CONFIG_FLAC_MUXER) += flacenc.o flacenc_header.o \ OBJS-$(CONFIG_FLIC_DEMUXER) += flic.o OBJS-$(CONFIG_FLV_DEMUXER) += flvdec.o OBJS-$(CONFIG_LIVE_FLV_DEMUXER) += flvdec.o -OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o hevc.o av1.o +OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o hevc.o av1.o vpcc.o OBJS-$(CONFIG_FOURXM_DEMUXER) += 4xm.o OBJS-$(CONFIG_FRAMECRC_MUXER) += framecrcenc.o framehash.o OBJS-$(CONFIG_FRAMEHASH_MUXER) += hashenc.o framehash.o diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index c1784b332d..475dd0bf44 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 } }; @@ -494,7 +496,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 ? @@ -540,9 +542,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 @@ -553,6 +555,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); } @@ -852,14 +856,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))) { @@ -880,7 +885,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); @@ -993,9 +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) { + } 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 Fri May 12 03:59:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 41595 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp5097453pzb; Thu, 11 May 2023 21:00:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5+DPGMwXx2lsFnqsnTkT9Xl/SjMFm2S57Y9AbV+ma6DVHxdVJ7tFbKTV2kUguWm8o7QxRx X-Received: by 2002:a17:907:3686:b0:94a:56ec:7f12 with SMTP id bi6-20020a170907368600b0094a56ec7f12mr22405333ejc.30.1683864020979; Thu, 11 May 2023 21:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683864020; cv=none; d=google.com; s=arc-20160816; b=IFw2vPF5rORQzxlMXZKobSAI2eVTp4I6hMEvUCM17HJfzvzoBqsGHxQVFExZlRYWrx LzlYz+NbouQFfyew04h6nrjG+hA6rVT4xnmuT5zOeliHvKTANT6afNAuZW1v98KzkMEG zcQ9ovN7+hLLYD5e/HhALZZ8VabvDnOgGbnM5UsrVJVcq+378AAKlhch38oON2hCBi5y LOK1Xxk5L+nrTEeQckXQP6sDOePDArz55qbGlUn0/oPzaW9yiI+WEMWA80qCfOFhgl9Z zNGe531PHxj2puLKGuFmqWyovRjmXLwftUXAOZSmiHUg+IwqYbSNNbCkVsd7sGLwSy3f FFGA== 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=NakM8ce+HacANsQHThdgaKpQuGUEnFBfLPZ3X5ryRnZSqVxWgLN7OYK3ptx9USqgpG /nZVGl4ChtMgfiroZbZU2bJneh8qV7tY94mnLJcIKSO1vNJ9mrBh9pVHkdBsyUEUAaUs /kHpyukXCGs7BNFkF0/VV+9Xd0UizKea5k1xWeD4y9wzitt+k44JuoPt+1nQnDtE8e/f 8Cxtk0y189BhNg5Sz2Hp7HzY5iEHebjKjfBcOezONzmxoXdWRm2EZmINKnrWrKi4TgzT Y6EcH0MVXGmNIS6s6ISH6vEJ7InArVHTVp1iSUDijpEE8p3UbeA0Tv+fCSWIc7Df1dHo ztBg== 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 vh11-20020a170907d38b00b0094edce87118si7938301ejc.1042.2023.05.11.21.00.20; Thu, 11 May 2023 21:00:20 -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 4B2F468C1B0; Fri, 12 May 2023 06:59:54 +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 E554D68C1A1 for ; Fri, 12 May 2023 06:59:51 +0300 (EEST) X-QQ-mid: bizesmtp62t1683863986t1ad3wfo Received: from localhost ( [103.102.203.204]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 12 May 2023 11:59:44 +0800 (CST) X-QQ-SSF: 01100000000000Z0Z000000A0000000 X-QQ-FEAT: v2TBAhtyi5HvYXmZKwpusWfSkwBwQDEy1NSybO51ZTByKDgED58rvVRnoUeNI mhDcjsT48XmLwWlK4TIib70j0/u/zmiyTqiLOmiJZUXmqi9KVo+0Fy00RmSF1sQu+i15Onw uZ6YPm0I8dx1KNCrxsOlRKVOUn6TuL+ZmiauMXUzyXWzqWBWmQwEpsBzqrKclgHg0TSFHRW FgGyzP0UU8cDy4lZyxH5QsjQ2SZaJhsxi2u7wb9rP1o3fBv6S2gG456hbpqxEBQYyQO+tXX +xixobR6UStRJy30w2bS/ajOHtGqwrwDPpCfKyUM0R26uYGLJ5QO/MC2AJWL8WARPmKJg0R G4daqCFRwmcCl4uGxMaLBWzEMMiELadnVKAH33c5M2DG5mYMmE= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 9651354155845394256 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Fri, 12 May 2023 11:59:01 +0800 Message-Id: <20230512035901.22731-7-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230512035901.22731-1-lq@chinaffmpeg.org> References: <20230512035901.22731-1-lq@chinaffmpeg.org> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Subject: [FFmpeg-devel] [PATCH v9 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: uh17yvvT9FLQ 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) {