Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v8 0/6] Suppor hevc av1 and vp9 codec in enhanced flv
@ 2023-04-13  9:44 Steven Liu
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 1/6] avformat/flvenc: Add support for HEVC over flv in muxer Steven Liu
                   ` (5 more replies)
  0 siblings, 6 replies; 72+ messages in thread
From: Steven Liu @ 2023-04-13  9:44 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Implements hevc,av1 and vp9 according to enhanced flv spec found at
https://github.com/veovera/enhanced-rtmp

And it has supported by OBS, Simple Realtime Server, mpegts.js.
you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
The enhanced flv documentation contributors include
Jean-Baptiste Kempf (FFmpeg, VideoLAN).
So this should be support by ffmpeg too.

v8:
    support vp9 codec according to enhanced flv
    support PacketTypeCodedFrames type for hevc in flv

Steven Liu (6):
  avformat/flvenc: Add support for HEVC over flv in muxer
  avformat/flvdec: support demux hevc in enhanced flv
  avformat/flvenc: support mux av1 in enhanced flv
  avformat/flvdec: support demux av1 in enhanced flv
  avformat/flvenc: support mux vp9 in enhanced flv
  avformat/flvenc: support demux vp9 in enhanced flv

 libavformat/flv.h    | 15 +++++++++
 libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
 libavformat/flvenc.c | 63 ++++++++++++++++++++++++++++++++------
 3 files changed, 133 insertions(+), 18 deletions(-)

-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v8 1/6] avformat/flvenc: Add support for HEVC over flv in muxer
  2023-04-13  9:44 [FFmpeg-devel] [PATCH v8 0/6] Suppor hevc av1 and vp9 codec in enhanced flv Steven Liu
@ 2023-04-13  9:44 ` Steven Liu
  2023-05-11 17:58   ` Andreas Rheinhardt
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 2/6] avformat/flvdec: support demux hevc in enhanced flv Steven Liu
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-04-13  9:44 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v8 2/6] avformat/flvdec: support demux hevc in enhanced flv
  2023-04-13  9:44 [FFmpeg-devel] [PATCH v8 0/6] Suppor hevc av1 and vp9 codec in enhanced flv Steven Liu
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 1/6] avformat/flvenc: Add support for HEVC over flv in muxer Steven Liu
@ 2023-04-13  9:44 ` Steven Liu
  2023-07-26 23:27   ` Michael Niedermayer
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 " Steven Liu
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-04-13  9:44 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-04-13  9:44 [FFmpeg-devel] [PATCH v8 0/6] Suppor hevc av1 and vp9 codec in enhanced flv Steven Liu
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 1/6] avformat/flvenc: Add support for HEVC over flv in muxer Steven Liu
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 2/6] avformat/flvdec: support demux hevc in enhanced flv Steven Liu
@ 2023-04-13  9:44 ` Steven Liu
  2023-05-08 23:07   ` Neal Gompa
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 4/6] avformat/flvdec: support demux " Steven Liu
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-04-13  9:44 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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);
         }
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v8 4/6] avformat/flvdec: support demux av1 in enhanced flv
  2023-04-13  9:44 [FFmpeg-devel] [PATCH v8 0/6] Suppor hevc av1 and vp9 codec in enhanced flv Steven Liu
                   ` (2 preceding siblings ...)
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 " Steven Liu
@ 2023-04-13  9:44 ` Steven Liu
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 5/6] avformat/flvenc: support mux vp9 " Steven Liu
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 6/6] avformat/flvenc: support demux " Steven Liu
  5 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-04-13  9:44 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v8 5/6] avformat/flvenc: support mux vp9 in enhanced flv
  2023-04-13  9:44 [FFmpeg-devel] [PATCH v8 0/6] Suppor hevc av1 and vp9 codec in enhanced flv Steven Liu
                   ` (3 preceding siblings ...)
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 4/6] avformat/flvdec: support demux " Steven Liu
@ 2023-04-13  9:44 ` Steven Liu
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 6/6] avformat/flvenc: support demux " Steven Liu
  5 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-04-13  9:44 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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);
         }
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v8 6/6] avformat/flvenc: support demux vp9 in enhanced flv
  2023-04-13  9:44 [FFmpeg-devel] [PATCH v8 0/6] Suppor hevc av1 and vp9 codec in enhanced flv Steven Liu
                   ` (4 preceding siblings ...)
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 5/6] avformat/flvenc: support mux vp9 " Steven Liu
@ 2023-04-13  9:44 ` Steven Liu
  5 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-04-13  9:44 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 " Steven Liu
@ 2023-05-08 23:07   ` Neal Gompa
  2023-05-09  1:55     ` Steven Liu
  0 siblings, 1 reply; 72+ messages in thread
From: Neal Gompa @ 2023-05-08 23:07 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Steven Liu

On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
>
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  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);
>          }
> --
> 2.40.0
>

I tested this by applying the patches on top of ffmpeg 6.0 and it
doesn't seem to work:

  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
[libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
  Metadata:
    ENCODER         : Lavf60.3.100
  Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
  Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
fps, 30 tbr, 1k tbn
    Metadata:
      DURATION        : 00:02:00.533000000
  Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
    Metadata:
      title           : Track1
      DURATION        : 00:02:00.533000000
[flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
specification,
[flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
[out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
parameters ?): Invalid argument
[aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
    Last message repeated 1 times




-- 
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-08 23:07   ` Neal Gompa
@ 2023-05-09  1:55     ` Steven Liu
  2023-05-09  2:41       ` Neal Gompa
  0 siblings, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-05-09  1:55 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Steven Liu

Neal Gompa <ngompa13@gmail.com> 于2023年5月9日周二 07:08写道:
>
> On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> >
> > Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > ---
> >  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);
> >          }
> > --
> > 2.40.0
> >
>
> I tested this by applying the patches on top of ffmpeg 6.0 and it
> doesn't seem to work:
>
>   libavutil      58.  2.100 / 58.  2.100
>   libavcodec     60.  3.100 / 60.  3.100
>   libavformat    60.  3.100 / 60.  3.100
>   libavdevice    60.  1.100 / 60.  1.100
>   libavfilter     9.  3.100 /  9.  3.100
>   libswscale      7.  1.100 /  7.  1.100
>   libswresample   4. 10.100 /  4. 10.100
>   libpostproc    57.  1.100 / 57.  1.100
> [libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
> Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
>   Metadata:
>     ENCODER         : Lavf60.3.100
>   Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
>   Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
> fps, 30 tbr, 1k tbn
>     Metadata:
>       DURATION        : 00:02:00.533000000
>   Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
>     Metadata:
>       title           : Track1
>       DURATION        : 00:02:00.533000000
> [flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
> specification,
> [flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
Pay attention this warning message.

> [out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
> parameters ?): Invalid argument
> [aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
> Stream mapping:
>   Stream #0:0 -> #0:0 (copy)
>   Stream #0:1 -> #0:1 (copy)
>     Last message repeated 1 times
>
>
>
>
> --
> 真実はいつも一つ!/ Always, there's only one truth!
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-09  1:55     ` Steven Liu
@ 2023-05-09  2:41       ` Neal Gompa
  2023-05-09  4:14         ` Gyan Doshi
  0 siblings, 1 reply; 72+ messages in thread
From: Neal Gompa @ 2023-05-09  2:41 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Steven Liu

On Mon, May 8, 2023 at 9:55 PM Steven Liu <lingjiujianke@gmail.com> wrote:
>
> Neal Gompa <ngompa13@gmail.com> 于2023年5月9日周二 07:08写道:
> >
> > On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> > >
> > > Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > > ---
> > >  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);
> > >          }
> > > --
> > > 2.40.0
> > >
> >
> > I tested this by applying the patches on top of ffmpeg 6.0 and it
> > doesn't seem to work:
> >
> >   libavutil      58.  2.100 / 58.  2.100
> >   libavcodec     60.  3.100 / 60.  3.100
> >   libavformat    60.  3.100 / 60.  3.100
> >   libavdevice    60.  1.100 / 60.  1.100
> >   libavfilter     9.  3.100 /  9.  3.100
> >   libswscale      7.  1.100 /  7.  1.100
> >   libswresample   4. 10.100 /  4. 10.100
> >   libpostproc    57.  1.100 / 57.  1.100
> > [libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
> > Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
> >   Metadata:
> >     ENCODER         : Lavf60.3.100
> >   Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
> >   Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
> > fps, 30 tbr, 1k tbn
> >     Metadata:
> >       DURATION        : 00:02:00.533000000
> >   Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
> >     Metadata:
> >       title           : Track1
> >       DURATION        : 00:02:00.533000000
> > [flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
> > specification,
> > [flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
> Pay attention this warning message.
>
> > [out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
> > parameters ?): Invalid argument
> > [aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
> > Stream mapping:
> >   Stream #0:0 -> #0:0 (copy)
> >   Stream #0:1 -> #0:1 (copy)
> >     Last message repeated 1 times

Well, this is my command:

$ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"

What should I be doing instead?





--
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-09  2:41       ` Neal Gompa
@ 2023-05-09  4:14         ` Gyan Doshi
  2023-05-09 10:35           ` Neal Gompa
  0 siblings, 1 reply; 72+ messages in thread
From: Gyan Doshi @ 2023-05-09  4:14 UTC (permalink / raw)
  To: ffmpeg-devel



On 2023-05-09 08:11 am, Neal Gompa wrote:
> On Mon, May 8, 2023 at 9:55 PM Steven Liu <lingjiujianke@gmail.com> wrote:
>> Neal Gompa <ngompa13@gmail.com> 于2023年5月9日周二 07:08写道:
>>> On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
>>>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
>>>> ---
>>>>   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);
>>>>           }
>>>> --
>>>> 2.40.0
>>>>
>>> I tested this by applying the patches on top of ffmpeg 6.0 and it
>>> doesn't seem to work:
>>>
>>>    libavutil      58.  2.100 / 58.  2.100
>>>    libavcodec     60.  3.100 / 60.  3.100
>>>    libavformat    60.  3.100 / 60.  3.100
>>>    libavdevice    60.  1.100 / 60.  1.100
>>>    libavfilter     9.  3.100 /  9.  3.100
>>>    libswscale      7.  1.100 /  7.  1.100
>>>    libswresample   4. 10.100 /  4. 10.100
>>>    libpostproc    57.  1.100 / 57.  1.100
>>> [libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
>>> Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
>>>    Metadata:
>>>      ENCODER         : Lavf60.3.100
>>>    Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
>>>    Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
>>> fps, 30 tbr, 1k tbn
>>>      Metadata:
>>>        DURATION        : 00:02:00.533000000
>>>    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
>>>      Metadata:
>>>        title           : Track1
>>>        DURATION        : 00:02:00.533000000
>>> [flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
>>> specification,
>>> [flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
>> Pay attention this warning message.
>>
>>> [out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
>>> parameters ?): Invalid argument
>>> [aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
>>> Stream mapping:
>>>    Stream #0:0 -> #0:0 (copy)
>>>    Stream #0:1 -> #0:1 (copy)
>>>      Last message repeated 1 times
> Well, this is my command:
>
> $ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"
>
> What should I be doing instead?

   ffmpeg -i "input.mkv" -vcodec copy -acodec copy -strict -1 "output.flv"

Regards,
Gyan

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-09  4:14         ` Gyan Doshi
@ 2023-05-09 10:35           ` Neal Gompa
  2023-05-09 10:48             ` Gyan Doshi
  0 siblings, 1 reply; 72+ messages in thread
From: Neal Gompa @ 2023-05-09 10:35 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Tue, May 9, 2023 at 12:14 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
>
>
>
> On 2023-05-09 08:11 am, Neal Gompa wrote:
> > On Mon, May 8, 2023 at 9:55 PM Steven Liu <lingjiujianke@gmail.com> wrote:
> >> Neal Gompa <ngompa13@gmail.com> 于2023年5月9日周二 07:08写道:
> >>> On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> >>>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> >>>> ---
> >>>>   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);
> >>>>           }
> >>>> --
> >>>> 2.40.0
> >>>>
> >>> I tested this by applying the patches on top of ffmpeg 6.0 and it
> >>> doesn't seem to work:
> >>>
> >>>    libavutil      58.  2.100 / 58.  2.100
> >>>    libavcodec     60.  3.100 / 60.  3.100
> >>>    libavformat    60.  3.100 / 60.  3.100
> >>>    libavdevice    60.  1.100 / 60.  1.100
> >>>    libavfilter     9.  3.100 /  9.  3.100
> >>>    libswscale      7.  1.100 /  7.  1.100
> >>>    libswresample   4. 10.100 /  4. 10.100
> >>>    libpostproc    57.  1.100 / 57.  1.100
> >>> [libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
> >>> Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
> >>>    Metadata:
> >>>      ENCODER         : Lavf60.3.100
> >>>    Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
> >>>    Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
> >>> fps, 30 tbr, 1k tbn
> >>>      Metadata:
> >>>        DURATION        : 00:02:00.533000000
> >>>    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
> >>>      Metadata:
> >>>        title           : Track1
> >>>        DURATION        : 00:02:00.533000000
> >>> [flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
> >>> specification,
> >>> [flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
> >> Pay attention this warning message.
> >>
> >>> [out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
> >>> parameters ?): Invalid argument
> >>> [aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
> >>> Stream mapping:
> >>>    Stream #0:0 -> #0:0 (copy)
> >>>    Stream #0:1 -> #0:1 (copy)
> >>>      Last message repeated 1 times
> > Well, this is my command:
> >
> > $ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"
> >
> > What should I be doing instead?
>
>    ffmpeg -i "input.mkv" -vcodec copy -acodec copy -strict -1 "output.flv"
>

That defeats the point of this patch. This patch adds proper support
for AV1 to the FLV code, so it should not need that.



-- 
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-09 10:35           ` Neal Gompa
@ 2023-05-09 10:48             ` Gyan Doshi
  2023-05-10 11:05               ` Neal Gompa
  0 siblings, 1 reply; 72+ messages in thread
From: Gyan Doshi @ 2023-05-09 10:48 UTC (permalink / raw)
  To: ffmpeg-devel



On 2023-05-09 04:05 pm, Neal Gompa wrote:
> On Tue, May 9, 2023 at 12:14 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
>>
>>
>> On 2023-05-09 08:11 am, Neal Gompa wrote:
>>> On Mon, May 8, 2023 at 9:55 PM Steven Liu <lingjiujianke@gmail.com> wrote:
>>>> Neal Gompa <ngompa13@gmail.com> 于2023年5月9日周二 07:08写道:
>>>>> On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
>>>>>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
>>>>>> ---
>>>>>>    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);
>>>>>>            }
>>>>>> --
>>>>>> 2.40.0
>>>>>>
>>>>> I tested this by applying the patches on top of ffmpeg 6.0 and it
>>>>> doesn't seem to work:
>>>>>
>>>>>     libavutil      58.  2.100 / 58.  2.100
>>>>>     libavcodec     60.  3.100 / 60.  3.100
>>>>>     libavformat    60.  3.100 / 60.  3.100
>>>>>     libavdevice    60.  1.100 / 60.  1.100
>>>>>     libavfilter     9.  3.100 /  9.  3.100
>>>>>     libswscale      7.  1.100 /  7.  1.100
>>>>>     libswresample   4. 10.100 /  4. 10.100
>>>>>     libpostproc    57.  1.100 / 57.  1.100
>>>>> [libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
>>>>> Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
>>>>>     Metadata:
>>>>>       ENCODER         : Lavf60.3.100
>>>>>     Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
>>>>>     Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
>>>>> fps, 30 tbr, 1k tbn
>>>>>       Metadata:
>>>>>         DURATION        : 00:02:00.533000000
>>>>>     Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
>>>>>       Metadata:
>>>>>         title           : Track1
>>>>>         DURATION        : 00:02:00.533000000
>>>>> [flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
>>>>> specification,
>>>>> [flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
>>>> Pay attention this warning message.
>>>>
>>>>> [out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
>>>>> parameters ?): Invalid argument
>>>>> [aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
>>>>> Stream mapping:
>>>>>     Stream #0:0 -> #0:0 (copy)
>>>>>     Stream #0:1 -> #0:1 (copy)
>>>>>       Last message repeated 1 times
>>> Well, this is my command:
>>>
>>> $ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"
>>>
>>> What should I be doing instead?
>>     ffmpeg -i "input.mkv" -vcodec copy -acodec copy -strict -1 "output.flv"
>>
> That defeats the point of this patch. This patch adds proper support
> for AV1 to the FLV code, so it should not need that.

This patch does not add HEVC or AV1 support to the FLV *specification*, 
hence the guard.

Regards,
Gyan

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-09 10:48             ` Gyan Doshi
@ 2023-05-10 11:05               ` Neal Gompa
  2023-05-10 11:13                 ` Steven Liu
  0 siblings, 1 reply; 72+ messages in thread
From: Neal Gompa @ 2023-05-10 11:05 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Tue, May 9, 2023 at 6:48 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
>
>
>
> On 2023-05-09 04:05 pm, Neal Gompa wrote:
> > On Tue, May 9, 2023 at 12:14 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
> >>
> >>
> >> On 2023-05-09 08:11 am, Neal Gompa wrote:
> >>> On Mon, May 8, 2023 at 9:55 PM Steven Liu <lingjiujianke@gmail.com> wrote:
> >>>> Neal Gompa <ngompa13@gmail.com> 于2023年5月9日周二 07:08写道:
> >>>>> On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> >>>>>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> >>>>>> ---
> >>>>>>    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);
> >>>>>>            }
> >>>>>> --
> >>>>>> 2.40.0
> >>>>>>
> >>>>> I tested this by applying the patches on top of ffmpeg 6.0 and it
> >>>>> doesn't seem to work:
> >>>>>
> >>>>>     libavutil      58.  2.100 / 58.  2.100
> >>>>>     libavcodec     60.  3.100 / 60.  3.100
> >>>>>     libavformat    60.  3.100 / 60.  3.100
> >>>>>     libavdevice    60.  1.100 / 60.  1.100
> >>>>>     libavfilter     9.  3.100 /  9.  3.100
> >>>>>     libswscale      7.  1.100 /  7.  1.100
> >>>>>     libswresample   4. 10.100 /  4. 10.100
> >>>>>     libpostproc    57.  1.100 / 57.  1.100
> >>>>> [libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
> >>>>> Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
> >>>>>     Metadata:
> >>>>>       ENCODER         : Lavf60.3.100
> >>>>>     Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
> >>>>>     Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
> >>>>> fps, 30 tbr, 1k tbn
> >>>>>       Metadata:
> >>>>>         DURATION        : 00:02:00.533000000
> >>>>>     Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
> >>>>>       Metadata:
> >>>>>         title           : Track1
> >>>>>         DURATION        : 00:02:00.533000000
> >>>>> [flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
> >>>>> specification,
> >>>>> [flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
> >>>> Pay attention this warning message.
> >>>>
> >>>>> [out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
> >>>>> parameters ?): Invalid argument
> >>>>> [aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
> >>>>> Stream mapping:
> >>>>>     Stream #0:0 -> #0:0 (copy)
> >>>>>     Stream #0:1 -> #0:1 (copy)
> >>>>>       Last message repeated 1 times
> >>> Well, this is my command:
> >>>
> >>> $ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"
> >>>
> >>> What should I be doing instead?
> >>     ffmpeg -i "input.mkv" -vcodec copy -acodec copy -strict -1 "output.flv"
> >>
> > That defeats the point of this patch. This patch adds proper support
> > for AV1 to the FLV code, so it should not need that.
>
> This patch does not add HEVC or AV1 support to the FLV *specification*,
> hence the guard.
>

The thing is, this patch series is about implementing support for the
enhanced FLV specification. So my expectation is that I should not
need to do anything special to generate enhanced FLV files.



-- 
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-10 11:05               ` Neal Gompa
@ 2023-05-10 11:13                 ` Steven Liu
  2023-05-11  1:31                   ` Neal Gompa
  0 siblings, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-05-10 11:13 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Neal Gompa <ngompa13@gmail.com> 于2023年5月10日周三 19:05写道:
>
> On Tue, May 9, 2023 at 6:48 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
> >
> >
> >
> > On 2023-05-09 04:05 pm, Neal Gompa wrote:
> > > On Tue, May 9, 2023 at 12:14 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
> > >>
> > >>
> > >> On 2023-05-09 08:11 am, Neal Gompa wrote:
> > >>> On Mon, May 8, 2023 at 9:55 PM Steven Liu <lingjiujianke@gmail.com> wrote:
> > >>>> Neal Gompa <ngompa13@gmail.com> 于2023年5月9日周二 07:08写道:
> > >>>>> On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> > >>>>>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > >>>>>> ---
> > >>>>>>    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);
> > >>>>>>            }
> > >>>>>> --
> > >>>>>> 2.40.0
> > >>>>>>
> > >>>>> I tested this by applying the patches on top of ffmpeg 6.0 and it
> > >>>>> doesn't seem to work:
> > >>>>>
> > >>>>>     libavutil      58.  2.100 / 58.  2.100
> > >>>>>     libavcodec     60.  3.100 / 60.  3.100
> > >>>>>     libavformat    60.  3.100 / 60.  3.100
> > >>>>>     libavdevice    60.  1.100 / 60.  1.100
> > >>>>>     libavfilter     9.  3.100 /  9.  3.100
> > >>>>>     libswscale      7.  1.100 /  7.  1.100
> > >>>>>     libswresample   4. 10.100 /  4. 10.100
> > >>>>>     libpostproc    57.  1.100 / 57.  1.100
> > >>>>> [libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
> > >>>>> Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
> > >>>>>     Metadata:
> > >>>>>       ENCODER         : Lavf60.3.100
> > >>>>>     Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
> > >>>>>     Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
> > >>>>> fps, 30 tbr, 1k tbn
> > >>>>>       Metadata:
> > >>>>>         DURATION        : 00:02:00.533000000
> > >>>>>     Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
> > >>>>>       Metadata:
> > >>>>>         title           : Track1
> > >>>>>         DURATION        : 00:02:00.533000000
> > >>>>> [flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
> > >>>>> specification,
> > >>>>> [flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
> > >>>> Pay attention this warning message.
> > >>>>
> > >>>>> [out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
> > >>>>> parameters ?): Invalid argument
> > >>>>> [aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
> > >>>>> Stream mapping:
> > >>>>>     Stream #0:0 -> #0:0 (copy)
> > >>>>>     Stream #0:1 -> #0:1 (copy)
> > >>>>>       Last message repeated 1 times
> > >>> Well, this is my command:
> > >>>
> > >>> $ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"
> > >>>
> > >>> What should I be doing instead?
> > >>     ffmpeg -i "input.mkv" -vcodec copy -acodec copy -strict -1 "output.flv"
> > >>
> > > That defeats the point of this patch. This patch adds proper support
> > > for AV1 to the FLV code, so it should not need that.
> >
> > This patch does not add HEVC or AV1 support to the FLV *specification*,
> > hence the guard.
> >
>
> The thing is, this patch series is about implementing support for the
> enhanced FLV specification.
No, That documentation is not flv official specification, it just a document.

So my expectation is that I should not
> need to do anything special to generate enhanced FLV files.
>
>
>
> --

Thanks
Steven
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-10 11:13                 ` Steven Liu
@ 2023-05-11  1:31                   ` Neal Gompa
  2023-05-11  1:40                     ` Steven Liu
  0 siblings, 1 reply; 72+ messages in thread
From: Neal Gompa @ 2023-05-11  1:31 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Wed, May 10, 2023 at 7:13 AM Steven Liu <lingjiujianke@gmail.com> wrote:
>
> Neal Gompa <ngompa13@gmail.com> 于2023年5月10日周三 19:05写道:
> >
> > On Tue, May 9, 2023 at 6:48 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
> > >
> > >
> > >
> > > On 2023-05-09 04:05 pm, Neal Gompa wrote:
> > > > On Tue, May 9, 2023 at 12:14 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
> > > >>
> > > >>
> > > >> On 2023-05-09 08:11 am, Neal Gompa wrote:
> > > >>> On Mon, May 8, 2023 at 9:55 PM Steven Liu <lingjiujianke@gmail.com> wrote:
> > > >>>> Neal Gompa <ngompa13@gmail.com> 于2023年5月9日周二 07:08写道:
> > > >>>>> On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> > > >>>>>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > > >>>>>> ---
> > > >>>>>>    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);
> > > >>>>>>            }
> > > >>>>>> --
> > > >>>>>> 2.40.0
> > > >>>>>>
> > > >>>>> I tested this by applying the patches on top of ffmpeg 6.0 and it
> > > >>>>> doesn't seem to work:
> > > >>>>>
> > > >>>>>     libavutil      58.  2.100 / 58.  2.100
> > > >>>>>     libavcodec     60.  3.100 / 60.  3.100
> > > >>>>>     libavformat    60.  3.100 / 60.  3.100
> > > >>>>>     libavdevice    60.  1.100 / 60.  1.100
> > > >>>>>     libavfilter     9.  3.100 /  9.  3.100
> > > >>>>>     libswscale      7.  1.100 /  7.  1.100
> > > >>>>>     libswresample   4. 10.100 /  4. 10.100
> > > >>>>>     libpostproc    57.  1.100 / 57.  1.100
> > > >>>>> [libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
> > > >>>>> Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
> > > >>>>>     Metadata:
> > > >>>>>       ENCODER         : Lavf60.3.100
> > > >>>>>     Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
> > > >>>>>     Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
> > > >>>>> fps, 30 tbr, 1k tbn
> > > >>>>>       Metadata:
> > > >>>>>         DURATION        : 00:02:00.533000000
> > > >>>>>     Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
> > > >>>>>       Metadata:
> > > >>>>>         title           : Track1
> > > >>>>>         DURATION        : 00:02:00.533000000
> > > >>>>> [flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
> > > >>>>> specification,
> > > >>>>> [flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
> > > >>>> Pay attention this warning message.
> > > >>>>
> > > >>>>> [out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
> > > >>>>> parameters ?): Invalid argument
> > > >>>>> [aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
> > > >>>>> Stream mapping:
> > > >>>>>     Stream #0:0 -> #0:0 (copy)
> > > >>>>>     Stream #0:1 -> #0:1 (copy)
> > > >>>>>       Last message repeated 1 times
> > > >>> Well, this is my command:
> > > >>>
> > > >>> $ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"
> > > >>>
> > > >>> What should I be doing instead?
> > > >>     ffmpeg -i "input.mkv" -vcodec copy -acodec copy -strict -1 "output.flv"
> > > >>
> > > > That defeats the point of this patch. This patch adds proper support
> > > > for AV1 to the FLV code, so it should not need that.
> > >
> > > This patch does not add HEVC or AV1 support to the FLV *specification*,
> > > hence the guard.
> > >
> >
> > The thing is, this patch series is about implementing support for the
> > enhanced FLV specification.
> No, That documentation is not flv official specification, it just a document.

Frankly, so was the original one. The new specification is being
stewarded by a group that has the current owner of the RTMP spec as a
member (Veriskope).

RTMP was never IETF or ISO standardized, and neither was FLV. F4V was
derived from MP4/MOV, but that's not what RTMP uses.

This argument of it being "just a document" applies to the original
spec from Adobe/Veriskope too.

I still think it's reasonable that the enhanced FLV spec would be
supported without requiring disabling "strict" mode. That said, I
think it's fair to warn that we're using *new* features of the FLV
spec and there may be incompatibilities with older software.




--
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-11  1:31                   ` Neal Gompa
@ 2023-05-11  1:40                     ` Steven Liu
  2023-05-11 16:21                       ` Neal Gompa
  0 siblings, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-05-11  1:40 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Neal Gompa <ngompa13@gmail.com> 于2023年5月11日周四 09:31写道:
>
> On Wed, May 10, 2023 at 7:13 AM Steven Liu <lingjiujianke@gmail.com> wrote:
> >
> > Neal Gompa <ngompa13@gmail.com> 于2023年5月10日周三 19:05写道:
> > >
> > > On Tue, May 9, 2023 at 6:48 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
> > > >
> > > >
> > > >
> > > > On 2023-05-09 04:05 pm, Neal Gompa wrote:
> > > > > On Tue, May 9, 2023 at 12:14 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
> > > > >>
> > > > >>
> > > > >> On 2023-05-09 08:11 am, Neal Gompa wrote:
> > > > >>> On Mon, May 8, 2023 at 9:55 PM Steven Liu <lingjiujianke@gmail.com> wrote:
> > > > >>>> Neal Gompa <ngompa13@gmail.com> 于2023年5月9日周二 07:08写道:
> > > > >>>>> On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> > > > >>>>>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > > > >>>>>> ---
> > > > >>>>>>    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);
> > > > >>>>>>            }
> > > > >>>>>> --
> > > > >>>>>> 2.40.0
> > > > >>>>>>
> > > > >>>>> I tested this by applying the patches on top of ffmpeg 6.0 and it
> > > > >>>>> doesn't seem to work:
> > > > >>>>>
> > > > >>>>>     libavutil      58.  2.100 / 58.  2.100
> > > > >>>>>     libavcodec     60.  3.100 / 60.  3.100
> > > > >>>>>     libavformat    60.  3.100 / 60.  3.100
> > > > >>>>>     libavdevice    60.  1.100 / 60.  1.100
> > > > >>>>>     libavfilter     9.  3.100 /  9.  3.100
> > > > >>>>>     libswscale      7.  1.100 /  7.  1.100
> > > > >>>>>     libswresample   4. 10.100 /  4. 10.100
> > > > >>>>>     libpostproc    57.  1.100 / 57.  1.100
> > > > >>>>> [libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
> > > > >>>>> Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
> > > > >>>>>     Metadata:
> > > > >>>>>       ENCODER         : Lavf60.3.100
> > > > >>>>>     Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
> > > > >>>>>     Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
> > > > >>>>> fps, 30 tbr, 1k tbn
> > > > >>>>>       Metadata:
> > > > >>>>>         DURATION        : 00:02:00.533000000
> > > > >>>>>     Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
> > > > >>>>>       Metadata:
> > > > >>>>>         title           : Track1
> > > > >>>>>         DURATION        : 00:02:00.533000000
> > > > >>>>> [flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
> > > > >>>>> specification,
> > > > >>>>> [flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
> > > > >>>> Pay attention this warning message.
> > > > >>>>
> > > > >>>>> [out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
> > > > >>>>> parameters ?): Invalid argument
> > > > >>>>> [aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
> > > > >>>>> Stream mapping:
> > > > >>>>>     Stream #0:0 -> #0:0 (copy)
> > > > >>>>>     Stream #0:1 -> #0:1 (copy)
> > > > >>>>>       Last message repeated 1 times
> > > > >>> Well, this is my command:
> > > > >>>
> > > > >>> $ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"
> > > > >>>
> > > > >>> What should I be doing instead?
> > > > >>     ffmpeg -i "input.mkv" -vcodec copy -acodec copy -strict -1 "output.flv"
> > > > >>
> > > > > That defeats the point of this patch. This patch adds proper support
> > > > > for AV1 to the FLV code, so it should not need that.
> > > >
> > > > This patch does not add HEVC or AV1 support to the FLV *specification*,
> > > > hence the guard.
> > > >
> > >
> > > The thing is, this patch series is about implementing support for the
> > > enhanced FLV specification.
> > No, That documentation is not flv official specification, it just a document.
>
> Frankly, so was the original one. The new specification is being
> stewarded by a group that has the current owner of the RTMP spec as a
> member (Veriskope).
>
> RTMP was never IETF or ISO standardized, and neither was FLV. F4V was
> derived from MP4/MOV, but that's not what RTMP uses.

IIRC, RTMP and FLV official specification is released by Adobe, not
veovera, right?

>
> This argument of it being "just a document" applies to the original
> spec from Adobe/Veriskope too.
>
> I still think it's reasonable that the enhanced FLV spec would be
> supported without requiring disabling "strict" mode. That said, I
> think it's fair to warn that we're using *new* features of the FLV
> spec and there may be incompatibilities with older software.
>
>
>
>
Thanks
Steven
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-11  1:40                     ` Steven Liu
@ 2023-05-11 16:21                       ` Neal Gompa
  2023-05-11 16:26                         ` Jean-Baptiste Kempf
  0 siblings, 1 reply; 72+ messages in thread
From: Neal Gompa @ 2023-05-11 16:21 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Wed, May 10, 2023 at 9:40 PM Steven Liu <lingjiujianke@gmail.com> wrote:
>
> Neal Gompa <ngompa13@gmail.com> 于2023年5月11日周四 09:31写道:
> >
> > On Wed, May 10, 2023 at 7:13 AM Steven Liu <lingjiujianke@gmail.com> wrote:
> > >
> > > Neal Gompa <ngompa13@gmail.com> 于2023年5月10日周三 19:05写道:
> > > >
> > > > On Tue, May 9, 2023 at 6:48 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
> > > > >
> > > > >
> > > > >
> > > > > On 2023-05-09 04:05 pm, Neal Gompa wrote:
> > > > > > On Tue, May 9, 2023 at 12:14 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
> > > > > >>
> > > > > >>
> > > > > >> On 2023-05-09 08:11 am, Neal Gompa wrote:
> > > > > >>> On Mon, May 8, 2023 at 9:55 PM Steven Liu <lingjiujianke@gmail.com> wrote:
> > > > > >>>> Neal Gompa <ngompa13@gmail.com> 于2023年5月9日周二 07:08写道:
> > > > > >>>>> On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> > > > > >>>>>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > > > > >>>>>> ---
> > > > > >>>>>>    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);
> > > > > >>>>>>            }
> > > > > >>>>>> --
> > > > > >>>>>> 2.40.0
> > > > > >>>>>>
> > > > > >>>>> I tested this by applying the patches on top of ffmpeg 6.0 and it
> > > > > >>>>> doesn't seem to work:
> > > > > >>>>>
> > > > > >>>>>     libavutil      58.  2.100 / 58.  2.100
> > > > > >>>>>     libavcodec     60.  3.100 / 60.  3.100
> > > > > >>>>>     libavformat    60.  3.100 / 60.  3.100
> > > > > >>>>>     libavdevice    60.  1.100 / 60.  1.100
> > > > > >>>>>     libavfilter     9.  3.100 /  9.  3.100
> > > > > >>>>>     libswscale      7.  1.100 /  7.  1.100
> > > > > >>>>>     libswresample   4. 10.100 /  4. 10.100
> > > > > >>>>>     libpostproc    57.  1.100 / 57.  1.100
> > > > > >>>>> [libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
> > > > > >>>>> Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
> > > > > >>>>>     Metadata:
> > > > > >>>>>       ENCODER         : Lavf60.3.100
> > > > > >>>>>     Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
> > > > > >>>>>     Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
> > > > > >>>>> fps, 30 tbr, 1k tbn
> > > > > >>>>>       Metadata:
> > > > > >>>>>         DURATION        : 00:02:00.533000000
> > > > > >>>>>     Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
> > > > > >>>>>       Metadata:
> > > > > >>>>>         title           : Track1
> > > > > >>>>>         DURATION        : 00:02:00.533000000
> > > > > >>>>> [flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
> > > > > >>>>> specification,
> > > > > >>>>> [flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
> > > > > >>>> Pay attention this warning message.
> > > > > >>>>
> > > > > >>>>> [out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
> > > > > >>>>> parameters ?): Invalid argument
> > > > > >>>>> [aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
> > > > > >>>>> Stream mapping:
> > > > > >>>>>     Stream #0:0 -> #0:0 (copy)
> > > > > >>>>>     Stream #0:1 -> #0:1 (copy)
> > > > > >>>>>       Last message repeated 1 times
> > > > > >>> Well, this is my command:
> > > > > >>>
> > > > > >>> $ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"
> > > > > >>>
> > > > > >>> What should I be doing instead?
> > > > > >>     ffmpeg -i "input.mkv" -vcodec copy -acodec copy -strict -1 "output.flv"
> > > > > >>
> > > > > > That defeats the point of this patch. This patch adds proper support
> > > > > > for AV1 to the FLV code, so it should not need that.
> > > > >
> > > > > This patch does not add HEVC or AV1 support to the FLV *specification*,
> > > > > hence the guard.
> > > > >
> > > >
> > > > The thing is, this patch series is about implementing support for the
> > > > enhanced FLV specification.
> > > No, That documentation is not flv official specification, it just a document.
> >
> > Frankly, so was the original one. The new specification is being
> > stewarded by a group that has the current owner of the RTMP spec as a
> > member (Veriskope).
> >
> > RTMP was never IETF or ISO standardized, and neither was FLV. F4V was
> > derived from MP4/MOV, but that's not what RTMP uses.
>
> IIRC, RTMP and FLV official specification is released by Adobe, not
> veovera, right?
>

Not anymore. Adobe handed it over to Veriskope, and Veriskope seems to
have done new work in the Veovera group alongside Adobe, OBS,
VideoLAN, XSplit, and others.


-- 
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-11 16:21                       ` Neal Gompa
@ 2023-05-11 16:26                         ` Jean-Baptiste Kempf
  2023-05-12  3:35                           ` Neal Gompa
  0 siblings, 1 reply; 72+ messages in thread
From: Jean-Baptiste Kempf @ 2023-05-11 16:26 UTC (permalink / raw)
  To: ffmpeg-devel



On Thu, 11 May 2023, at 18:21, Neal Gompa wrote:
> On Wed, May 10, 2023 at 9:40 PM Steven Liu <lingjiujianke@gmail.com> wrote:
>>
>> Neal Gompa <ngompa13@gmail.com> 于2023年5月11日周四 09:31写道:
>> >
>> > On Wed, May 10, 2023 at 7:13 AM Steven Liu <lingjiujianke@gmail.com> wrote:
>> > >
>> > > Neal Gompa <ngompa13@gmail.com> 于2023年5月10日周三 19:05写道:
>> > > >
>> > > > On Tue, May 9, 2023 at 6:48 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
>> > > > >
>> > > > >
>> > > > >
>> > > > > On 2023-05-09 04:05 pm, Neal Gompa wrote:
>> > > > > > On Tue, May 9, 2023 at 12:14 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
>> > > > > >>
>> > > > > >>
>> > > > > >> On 2023-05-09 08:11 am, Neal Gompa wrote:
>> > > > > >>> On Mon, May 8, 2023 at 9:55 PM Steven Liu <lingjiujianke@gmail.com> wrote:
>> > > > > >>>> Neal Gompa <ngompa13@gmail.com> 于2023年5月9日周二 07:08写道:
>> > > > > >>>>> On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
>> > > > > >>>>>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
>> > > > > >>>>>> ---
>> > > > > >>>>>>    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);
>> > > > > >>>>>>            }
>> > > > > >>>>>> --
>> > > > > >>>>>> 2.40.0
>> > > > > >>>>>>
>> > > > > >>>>> I tested this by applying the patches on top of ffmpeg 6.0 and it
>> > > > > >>>>> doesn't seem to work:
>> > > > > >>>>>
>> > > > > >>>>>     libavutil      58.  2.100 / 58.  2.100
>> > > > > >>>>>     libavcodec     60.  3.100 / 60.  3.100
>> > > > > >>>>>     libavformat    60.  3.100 / 60.  3.100
>> > > > > >>>>>     libavdevice    60.  1.100 / 60.  1.100
>> > > > > >>>>>     libavfilter     9.  3.100 /  9.  3.100
>> > > > > >>>>>     libswscale      7.  1.100 /  7.  1.100
>> > > > > >>>>>     libswresample   4. 10.100 /  4. 10.100
>> > > > > >>>>>     libpostproc    57.  1.100 / 57.  1.100
>> > > > > >>>>> [libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
>> > > > > >>>>> Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
>> > > > > >>>>>     Metadata:
>> > > > > >>>>>       ENCODER         : Lavf60.3.100
>> > > > > >>>>>     Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
>> > > > > >>>>>     Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
>> > > > > >>>>> fps, 30 tbr, 1k tbn
>> > > > > >>>>>       Metadata:
>> > > > > >>>>>         DURATION        : 00:02:00.533000000
>> > > > > >>>>>     Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
>> > > > > >>>>>       Metadata:
>> > > > > >>>>>         title           : Track1
>> > > > > >>>>>         DURATION        : 00:02:00.533000000
>> > > > > >>>>> [flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
>> > > > > >>>>> specification,
>> > > > > >>>>> [flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
>> > > > > >>>> Pay attention this warning message.
>> > > > > >>>>
>> > > > > >>>>> [out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
>> > > > > >>>>> parameters ?): Invalid argument
>> > > > > >>>>> [aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
>> > > > > >>>>> Stream mapping:
>> > > > > >>>>>     Stream #0:0 -> #0:0 (copy)
>> > > > > >>>>>     Stream #0:1 -> #0:1 (copy)
>> > > > > >>>>>       Last message repeated 1 times
>> > > > > >>> Well, this is my command:
>> > > > > >>>
>> > > > > >>> $ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"
>> > > > > >>>
>> > > > > >>> What should I be doing instead?
>> > > > > >>     ffmpeg -i "input.mkv" -vcodec copy -acodec copy -strict -1 "output.flv"
>> > > > > >>
>> > > > > > That defeats the point of this patch. This patch adds proper support
>> > > > > > for AV1 to the FLV code, so it should not need that.
>> > > > >
>> > > > > This patch does not add HEVC or AV1 support to the FLV *specification*,
>> > > > > hence the guard.
>> > > > >
>> > > >
>> > > > The thing is, this patch series is about implementing support for the
>> > > > enhanced FLV specification.
>> > > No, That documentation is not flv official specification, it just a document.
>> >
>> > Frankly, so was the original one. The new specification is being
>> > stewarded by a group that has the current owner of the RTMP spec as a
>> > member (Veriskope).
>> >
>> > RTMP was never IETF or ISO standardized, and neither was FLV. F4V was
>> > derived from MP4/MOV, but that's not what RTMP uses.
>>
>> IIRC, RTMP and FLV official specification is released by Adobe, not
>> veovera, right?
>>
>
> Not anymore. Adobe handed it over to Veriskope, and Veriskope seems to
> have done new work in the Veovera group alongside Adobe, OBS,
> VideoLAN, XSplit, and others.

This is correct. Veriskope manages the Flash Server and therefore, de facto, the flv spec.

Currently, the issue is that this is not 100% standardized. Until it's official, it should be behind a flag.
After that, sure.

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 1/6] avformat/flvenc: Add support for HEVC over flv in muxer
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 1/6] avformat/flvenc: Add support for HEVC over flv in muxer Steven Liu
@ 2023-05-11 17:58   ` Andreas Rheinhardt
  2023-05-12  3:58     ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Steven Liu
  0 siblings, 1 reply; 72+ messages in thread
From: Andreas Rheinhardt @ 2023-05-11 17:58 UTC (permalink / raw)
  To: ffmpeg-devel

Steven Liu:
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  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)

This requires a flvenc->hevc.o Makefile dependency. Similarly for other
patches in this patchset.

> +                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) {

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-11 16:26                         ` Jean-Baptiste Kempf
@ 2023-05-12  3:35                           ` Neal Gompa
  2023-05-12  5:23                             ` Jean-Baptiste Kempf
  0 siblings, 1 reply; 72+ messages in thread
From: Neal Gompa @ 2023-05-12  3:35 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Thu, May 11, 2023 at 12:26 PM Jean-Baptiste Kempf <jb@videolan.org> wrote:
>
>
>
> On Thu, 11 May 2023, at 18:21, Neal Gompa wrote:
> > On Wed, May 10, 2023 at 9:40 PM Steven Liu <lingjiujianke@gmail.com> wrote:
> >>
> >> Neal Gompa <ngompa13@gmail.com> 于2023年5月11日周四 09:31写道:
> >> >
> >> > On Wed, May 10, 2023 at 7:13 AM Steven Liu <lingjiujianke@gmail.com> wrote:
> >> > >
> >> > > Neal Gompa <ngompa13@gmail.com> 于2023年5月10日周三 19:05写道:
> >> > > >
> >> > > > On Tue, May 9, 2023 at 6:48 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
> >> > > > >
> >> > > > >
> >> > > > >
> >> > > > > On 2023-05-09 04:05 pm, Neal Gompa wrote:
> >> > > > > > On Tue, May 9, 2023 at 12:14 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
> >> > > > > >>
> >> > > > > >>
> >> > > > > >> On 2023-05-09 08:11 am, Neal Gompa wrote:
> >> > > > > >>> On Mon, May 8, 2023 at 9:55 PM Steven Liu <lingjiujianke@gmail.com> wrote:
> >> > > > > >>>> Neal Gompa <ngompa13@gmail.com> 于2023年5月9日周二 07:08写道:
> >> > > > > >>>>> On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> >> > > > > >>>>>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> >> > > > > >>>>>> ---
> >> > > > > >>>>>>    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);
> >> > > > > >>>>>>            }
> >> > > > > >>>>>> --
> >> > > > > >>>>>> 2.40.0
> >> > > > > >>>>>>
> >> > > > > >>>>> I tested this by applying the patches on top of ffmpeg 6.0 and it
> >> > > > > >>>>> doesn't seem to work:
> >> > > > > >>>>>
> >> > > > > >>>>>     libavutil      58.  2.100 / 58.  2.100
> >> > > > > >>>>>     libavcodec     60.  3.100 / 60.  3.100
> >> > > > > >>>>>     libavformat    60.  3.100 / 60.  3.100
> >> > > > > >>>>>     libavdevice    60.  1.100 / 60.  1.100
> >> > > > > >>>>>     libavfilter     9.  3.100 /  9.  3.100
> >> > > > > >>>>>     libswscale      7.  1.100 /  7.  1.100
> >> > > > > >>>>>     libswresample   4. 10.100 /  4. 10.100
> >> > > > > >>>>>     libpostproc    57.  1.100 / 57.  1.100
> >> > > > > >>>>> [libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
> >> > > > > >>>>> Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
> >> > > > > >>>>>     Metadata:
> >> > > > > >>>>>       ENCODER         : Lavf60.3.100
> >> > > > > >>>>>     Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
> >> > > > > >>>>>     Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
> >> > > > > >>>>> fps, 30 tbr, 1k tbn
> >> > > > > >>>>>       Metadata:
> >> > > > > >>>>>         DURATION        : 00:02:00.533000000
> >> > > > > >>>>>     Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
> >> > > > > >>>>>       Metadata:
> >> > > > > >>>>>         title           : Track1
> >> > > > > >>>>>         DURATION        : 00:02:00.533000000
> >> > > > > >>>>> [flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
> >> > > > > >>>>> specification,
> >> > > > > >>>>> [flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
> >> > > > > >>>> Pay attention this warning message.
> >> > > > > >>>>
> >> > > > > >>>>> [out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
> >> > > > > >>>>> parameters ?): Invalid argument
> >> > > > > >>>>> [aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
> >> > > > > >>>>> Stream mapping:
> >> > > > > >>>>>     Stream #0:0 -> #0:0 (copy)
> >> > > > > >>>>>     Stream #0:1 -> #0:1 (copy)
> >> > > > > >>>>>       Last message repeated 1 times
> >> > > > > >>> Well, this is my command:
> >> > > > > >>>
> >> > > > > >>> $ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"
> >> > > > > >>>
> >> > > > > >>> What should I be doing instead?
> >> > > > > >>     ffmpeg -i "input.mkv" -vcodec copy -acodec copy -strict -1 "output.flv"
> >> > > > > >>
> >> > > > > > That defeats the point of this patch. This patch adds proper support
> >> > > > > > for AV1 to the FLV code, so it should not need that.
> >> > > > >
> >> > > > > This patch does not add HEVC or AV1 support to the FLV *specification*,
> >> > > > > hence the guard.
> >> > > > >
> >> > > >
> >> > > > The thing is, this patch series is about implementing support for the
> >> > > > enhanced FLV specification.
> >> > > No, That documentation is not flv official specification, it just a document.
> >> >
> >> > Frankly, so was the original one. The new specification is being
> >> > stewarded by a group that has the current owner of the RTMP spec as a
> >> > member (Veriskope).
> >> >
> >> > RTMP was never IETF or ISO standardized, and neither was FLV. F4V was
> >> > derived from MP4/MOV, but that's not what RTMP uses.
> >>
> >> IIRC, RTMP and FLV official specification is released by Adobe, not
> >> veovera, right?
> >>
> >
> > Not anymore. Adobe handed it over to Veriskope, and Veriskope seems to
> > have done new work in the Veovera group alongside Adobe, OBS,
> > VideoLAN, XSplit, and others.
>
> This is correct. Veriskope manages the Flash Server and therefore, de facto, the flv spec.
>
> Currently, the issue is that this is not 100% standardized. Until it's official, it should be behind a flag.
> After that, sure.
>

Do you know what's preventing it from being "official"? Do you know
when that'll change?



-- 
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg
  2023-05-11 17:58   ` Andreas Rheinhardt
@ 2023-05-12  3:58     ` Steven Liu
  2023-05-12  3:58       ` [FFmpeg-devel] [PATCH v9 1/6] avformat/flvenc: Add support for HEVC over flv in muxer Steven Liu
                         ` (7 more replies)
  0 siblings, 8 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-12  3:58 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
The enhanced flv documentation contributors include
Jean-Baptiste Kempf (FFmpeg, VideoLAN).
So this should be support by ffmpeg too.

v8:
    Support vp9 codec according to enhanced flv.
    Support PacketTypeCodedFrames type for hevc in flv.
v9:
    Add dependency codec object files for flvenc in Makefile.
    Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.

Steven Liu (6):
  avformat/flvenc: Add support for HEVC over flv in muxer
  avformat/flvdec: support demux hevc in enhanced flv
  avformat/flvenc: support mux av1 in enhanced flv
  avformat/flvdec: support demux av1 in enhanced flv
  avformat/flvenc: support mux vp9 in enhanced flv
  avformat/flvenc: support demux vp9 in enhanced flv

 libavformat/Makefile |  2 +-
 libavformat/flv.h    | 15 +++++++++
 libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
 libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
 4 files changed, 130 insertions(+), 18 deletions(-)

-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v9 1/6] avformat/flvenc: Add support for HEVC over flv in muxer
  2023-05-12  3:58     ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Steven Liu
@ 2023-05-12  3:58       ` Steven Liu
  2023-05-12  3:58       ` [FFmpeg-devel] [PATCH v9 2/6] avformat/flvdec: support demux hevc in enhanced flv Steven Liu
                         ` (6 subsequent siblings)
  7 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-12  3:58 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v9 2/6] avformat/flvdec: support demux hevc in enhanced flv
  2023-05-12  3:58     ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Steven Liu
  2023-05-12  3:58       ` [FFmpeg-devel] [PATCH v9 1/6] avformat/flvenc: Add support for HEVC over flv in muxer Steven Liu
@ 2023-05-12  3:58       ` Steven Liu
  2023-05-12  3:58       ` [FFmpeg-devel] [PATCH v9 3/6] avformat/flvenc: support mux av1 " Steven Liu
                         ` (5 subsequent siblings)
  7 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-12  3:58 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v9 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-12  3:58     ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Steven Liu
  2023-05-12  3:58       ` [FFmpeg-devel] [PATCH v9 1/6] avformat/flvenc: Add support for HEVC over flv in muxer Steven Liu
  2023-05-12  3:58       ` [FFmpeg-devel] [PATCH v9 2/6] avformat/flvdec: support demux hevc in enhanced flv Steven Liu
@ 2023-05-12  3:58       ` Steven Liu
  2023-05-12  3:58       ` [FFmpeg-devel] [PATCH v9 4/6] avformat/flvdec: support demux " Steven Liu
                         ` (4 subsequent siblings)
  7 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-12  3:58 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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);
         }
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v9 4/6] avformat/flvdec: support demux av1 in enhanced flv
  2023-05-12  3:58     ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Steven Liu
                         ` (2 preceding siblings ...)
  2023-05-12  3:58       ` [FFmpeg-devel] [PATCH v9 3/6] avformat/flvenc: support mux av1 " Steven Liu
@ 2023-05-12  3:58       ` Steven Liu
  2023-05-12  3:59       ` [FFmpeg-devel] [PATCH v9 5/6] avformat/flvenc: support mux vp9 " Steven Liu
                         ` (3 subsequent siblings)
  7 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-12  3:58 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v9 5/6] avformat/flvenc: support mux vp9 in enhanced flv
  2023-05-12  3:58     ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Steven Liu
                         ` (3 preceding siblings ...)
  2023-05-12  3:58       ` [FFmpeg-devel] [PATCH v9 4/6] avformat/flvdec: support demux " Steven Liu
@ 2023-05-12  3:59       ` Steven Liu
  2023-05-12  3:59       ` [FFmpeg-devel] [PATCH v9 6/6] avformat/flvenc: support demux " Steven Liu
                         ` (2 subsequent siblings)
  7 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-12  3:59 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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);
         }
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v9 6/6] avformat/flvenc: support demux vp9 in enhanced flv
  2023-05-12  3:58     ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Steven Liu
                         ` (4 preceding siblings ...)
  2023-05-12  3:59       ` [FFmpeg-devel] [PATCH v9 5/6] avformat/flvenc: support mux vp9 " Steven Liu
@ 2023-05-12  3:59       ` Steven Liu
  2023-05-12 10:31       ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Timo Rothenpieler
  2023-05-12 10:47       ` Vibhoothi
  7 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-12  3:59 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-12  3:35                           ` Neal Gompa
@ 2023-05-12  5:23                             ` Jean-Baptiste Kempf
  0 siblings, 0 replies; 72+ messages in thread
From: Jean-Baptiste Kempf @ 2023-05-12  5:23 UTC (permalink / raw)
  To: ffmpeg-devel

On Fri, 12 May 2023, at 05:35, Neal Gompa wrote:
> On Thu, May 11, 2023 at 12:26 PM Jean-Baptiste Kempf <jb@videolan.org> wrote:
>>
>>
>>
>> On Thu, 11 May 2023, at 18:21, Neal Gompa wrote:
>> > On Wed, May 10, 2023 at 9:40 PM Steven Liu <lingjiujianke@gmail.com> wrote:
>> >>
>> >> Neal Gompa <ngompa13@gmail.com> 于2023年5月11日周四 09:31写道:
>> >> >
>> >> > On Wed, May 10, 2023 at 7:13 AM Steven Liu <lingjiujianke@gmail.com> wrote:
>> >> > >
>> >> > > Neal Gompa <ngompa13@gmail.com> 于2023年5月10日周三 19:05写道:
>> >> > > >
>> >> > > > On Tue, May 9, 2023 at 6:48 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
>> >> > > > >
>> >> > > > >
>> >> > > > >
>> >> > > > > On 2023-05-09 04:05 pm, Neal Gompa wrote:
>> >> > > > > > On Tue, May 9, 2023 at 12:14 AM Gyan Doshi <ffmpeg@gyani.pro> wrote:
>> >> > > > > >>
>> >> > > > > >>
>> >> > > > > >> On 2023-05-09 08:11 am, Neal Gompa wrote:
>> >> > > > > >>> On Mon, May 8, 2023 at 9:55 PM Steven Liu <lingjiujianke@gmail.com> wrote:
>> >> > > > > >>>> Neal Gompa <ngompa13@gmail.com> 于2023年5月9日周二 07:08写道:
>> >> > > > > >>>>> On Thu, Apr 13, 2023 at 5:45 AM Steven Liu <lq@chinaffmpeg.org> wrote:
>> >> > > > > >>>>>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
>> >> > > > > >>>>>> ---
>> >> > > > > >>>>>>    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);
>> >> > > > > >>>>>>            }
>> >> > > > > >>>>>> --
>> >> > > > > >>>>>> 2.40.0
>> >> > > > > >>>>>>
>> >> > > > > >>>>> I tested this by applying the patches on top of ffmpeg 6.0 and it
>> >> > > > > >>>>> doesn't seem to work:
>> >> > > > > >>>>>
>> >> > > > > >>>>>     libavutil      58.  2.100 / 58.  2.100
>> >> > > > > >>>>>     libavcodec     60.  3.100 / 60.  3.100
>> >> > > > > >>>>>     libavformat    60.  3.100 / 60.  3.100
>> >> > > > > >>>>>     libavdevice    60.  1.100 / 60.  1.100
>> >> > > > > >>>>>     libavfilter     9.  3.100 /  9.  3.100
>> >> > > > > >>>>>     libswscale      7.  1.100 /  7.  1.100
>> >> > > > > >>>>>     libswresample   4. 10.100 /  4. 10.100
>> >> > > > > >>>>>     libpostproc    57.  1.100 / 57.  1.100
>> >> > > > > >>>>> [libdav1d @ 0x55c9ea8cae80] libdav1d 1.1.0
>> >> > > > > >>>>> Input #0, matroska,webm, from '2023-05-08 18-52-42.mkv':
>> >> > > > > >>>>>     Metadata:
>> >> > > > > >>>>>       ENCODER         : Lavf60.3.100
>> >> > > > > >>>>>     Duration: 00:02:00.53, start: 0.000000, bitrate: 1155 kb/s
>> >> > > > > >>>>>     Stream #0:0: Video: av1 (Main), yuv420p(tv, bt709), 1280x720, 30
>> >> > > > > >>>>> fps, 30 tbr, 1k tbn
>> >> > > > > >>>>>       Metadata:
>> >> > > > > >>>>>         DURATION        : 00:02:00.533000000
>> >> > > > > >>>>>     Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
>> >> > > > > >>>>>       Metadata:
>> >> > > > > >>>>>         title           : Track1
>> >> > > > > >>>>>         DURATION        : 00:02:00.533000000
>> >> > > > > >>>>> [flv @ 0x55c9ea936140] Codec av1 is not supported in the official FLV
>> >> > > > > >>>>> specification,
>> >> > > > > >>>>> [flv @ 0x55c9ea936140] use vstrict=-1 / -strict -1 to use it anyway.
>> >> > > > > >>>> Pay attention this warning message.
>> >> > > > > >>>>
>> >> > > > > >>>>> [out#0/flv @ 0x55c9ea8cda80] Could not write header (incorrect codec
>> >> > > > > >>>>> parameters ?): Invalid argument
>> >> > > > > >>>>> [aost#0:1/copy @ 0x55c9ea97ae00] Error initializing output stream:
>> >> > > > > >>>>> Stream mapping:
>> >> > > > > >>>>>     Stream #0:0 -> #0:0 (copy)
>> >> > > > > >>>>>     Stream #0:1 -> #0:1 (copy)
>> >> > > > > >>>>>       Last message repeated 1 times
>> >> > > > > >>> Well, this is my command:
>> >> > > > > >>>
>> >> > > > > >>> $ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"
>> >> > > > > >>>
>> >> > > > > >>> What should I be doing instead?
>> >> > > > > >>     ffmpeg -i "input.mkv" -vcodec copy -acodec copy -strict -1 "output.flv"
>> >> > > > > >>
>> >> > > > > > That defeats the point of this patch. This patch adds proper support
>> >> > > > > > for AV1 to the FLV code, so it should not need that.
>> >> > > > >
>> >> > > > > This patch does not add HEVC or AV1 support to the FLV *specification*,
>> >> > > > > hence the guard.
>> >> > > > >
>> >> > > >
>> >> > > > The thing is, this patch series is about implementing support for the
>> >> > > > enhanced FLV specification.
>> >> > > No, That documentation is not flv official specification, it just a document.
>> >> >
>> >> > Frankly, so was the original one. The new specification is being
>> >> > stewarded by a group that has the current owner of the RTMP spec as a
>> >> > member (Veriskope).
>> >> >
>> >> > RTMP was never IETF or ISO standardized, and neither was FLV. F4V was
>> >> > derived from MP4/MOV, but that's not what RTMP uses.
>> >>
>> >> IIRC, RTMP and FLV official specification is released by Adobe, not
>> >> veovera, right?
>> >>
>> >
>> > Not anymore. Adobe handed it over to Veriskope, and Veriskope seems to
>> > have done new work in the Veovera group alongside Adobe, OBS,
>> > VideoLAN, XSplit, and others.
>>
>> This is correct. Veriskope manages the Flash Server and therefore, de facto, the flv spec.
>>
>> Currently, the issue is that this is not 100% standardized. Until it's official, it should be behind a flag.
>> After that, sure.
>>
>
> Do you know what's preventing it from being "official"? Do you know
> when that'll change?

We're waiting for remarks, feedback and complaints about the extensions. So far, we've received very little.

jb
-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg
  2023-05-12  3:58     ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Steven Liu
                         ` (5 preceding siblings ...)
  2023-05-12  3:59       ` [FFmpeg-devel] [PATCH v9 6/6] avformat/flvenc: support demux " Steven Liu
@ 2023-05-12 10:31       ` Timo Rothenpieler
  2023-05-12 10:47         ` Steven Liu
  2023-05-12 10:47       ` Vibhoothi
  7 siblings, 1 reply; 72+ messages in thread
From: Timo Rothenpieler @ 2023-05-12 10:31 UTC (permalink / raw)
  To: ffmpeg-devel

On 12/05/2023 05:58, Steven Liu wrote:
> Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
> you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> The enhanced flv documentation contributors include
> Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> So this should be support by ffmpeg too.
> 
> v8:
>      Support vp9 codec according to enhanced flv.
>      Support PacketTypeCodedFrames type for hevc in flv.
> v9:
>      Add dependency codec object files for flvenc in Makefile.
>      Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
> 
> Steven Liu (6):
>    avformat/flvenc: Add support for HEVC over flv in muxer

This is very much a nit, but one of those commit messages is not like 
the others :D

>    avformat/flvdec: support demux hevc in enhanced flv
>    avformat/flvenc: support mux av1 in enhanced flv
>    avformat/flvdec: support demux av1 in enhanced flv
>    avformat/flvenc: support mux vp9 in enhanced flv
>    avformat/flvenc: support demux vp9 in enhanced flv
> 
>   libavformat/Makefile |  2 +-
>   libavformat/flv.h    | 15 +++++++++
>   libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
>   libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
>   4 files changed, 130 insertions(+), 18 deletions(-)
> 
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg
  2023-05-12 10:31       ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Timo Rothenpieler
@ 2023-05-12 10:47         ` Steven Liu
  2023-05-12 11:06           ` Timo Rothenpieler
  0 siblings, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-05-12 10:47 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Timo Rothenpieler <timo@rothenpieler.org> 于2023年5月12日周五 18:30写道:
Hi Timo,
>
> On 12/05/2023 05:58, Steven Liu wrote:
> > Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> > The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
> > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> > The enhanced flv documentation contributors include
> > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> > So this should be support by ffmpeg too.
> >
> > v8:
> >      Support vp9 codec according to enhanced flv.
> >      Support PacketTypeCodedFrames type for hevc in flv.
> > v9:
> >      Add dependency codec object files for flvenc in Makefile.
> >      Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
> >
> > Steven Liu (6):
> >    avformat/flvenc: Add support for HEVC over flv in muxer
>
> This is very much a nit, but one of those commit messages is not like
> the others :D
Should i resubmit one patch named v10? Or should i modify it like the
others before push? :D
>
> >    avformat/flvdec: support demux hevc in enhanced flv
> >    avformat/flvenc: support mux av1 in enhanced flv
> >    avformat/flvdec: support demux av1 in enhanced flv
> >    avformat/flvenc: support mux vp9 in enhanced flv
> >    avformat/flvenc: support demux vp9 in enhanced flv
> >
> >   libavformat/Makefile |  2 +-
> >   libavformat/flv.h    | 15 +++++++++
> >   libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
> >   libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
> >   4 files changed, 130 insertions(+), 18 deletions(-)
> >

Thanks
Steven
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg
  2023-05-12  3:58     ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Steven Liu
                         ` (6 preceding siblings ...)
  2023-05-12 10:31       ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Timo Rothenpieler
@ 2023-05-12 10:47       ` Vibhoothi
  2023-05-12 11:59         ` Steven Liu
  7 siblings, 1 reply; 72+ messages in thread
From: Vibhoothi @ 2023-05-12 10:47 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Hi,

On Fri, 12 May 2023 at 04:59, Steven Liu <lq@chinaffmpeg.org> wrote:
>
> Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
> you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> The enhanced flv documentation contributors include
> Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> So this should be support by ffmpeg too.
>
> v8:
>     Support vp9 codec according to enhanced flv.
>     Support PacketTypeCodedFrames type for hevc in flv.
> v9:
>     Add dependency codec object files for flvenc in Makefile.
>     Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
>
> Steven Liu (6):
>   avformat/flvenc: Add support for HEVC over flv in muxer
>   avformat/flvdec: support demux hevc in enhanced flv
>   avformat/flvenc: support mux av1 in enhanced flv
>   avformat/flvdec: support demux av1 in enhanced flv
>   avformat/flvenc: support mux vp9 in enhanced flv
>   avformat/flvenc: support demux vp9 in enhanced flv
Nit: Shouldn't the commit message be pointing flvdec
("avformat/flvdec") instead of flvenc ("avformat/flvenc") for
VP9 demuxer support?

I could see the changes being made to,
 libavformat/flvdec.c | 11 +++++++++--,
in the patch set.

>
>  libavformat/Makefile |  2 +-
>  libavformat/flv.h    | 15 +++++++++
>  libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
>  libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
>  4 files changed, 130 insertions(+), 18 deletions(-)
>
> --
> 2.40.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".


Best,
V
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg
  2023-05-12 10:47         ` Steven Liu
@ 2023-05-12 11:06           ` Timo Rothenpieler
  0 siblings, 0 replies; 72+ messages in thread
From: Timo Rothenpieler @ 2023-05-12 11:06 UTC (permalink / raw)
  To: ffmpeg-devel

On 12/05/2023 12:47, Steven Liu wrote:
> Timo Rothenpieler <timo@rothenpieler.org> 于2023年5月12日周五 18:30写道:
> Hi Timo,
>>
>> On 12/05/2023 05:58, Steven Liu wrote:
>>> Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
>>> The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
>>> you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
>>> The enhanced flv documentation contributors include
>>> Jean-Baptiste Kempf (FFmpeg, VideoLAN).
>>> So this should be support by ffmpeg too.
>>>
>>> v8:
>>>       Support vp9 codec according to enhanced flv.
>>>       Support PacketTypeCodedFrames type for hevc in flv.
>>> v9:
>>>       Add dependency codec object files for flvenc in Makefile.
>>>       Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
>>>
>>> Steven Liu (6):
>>>     avformat/flvenc: Add support for HEVC over flv in muxer
>>
>> This is very much a nit, but one of those commit messages is not like
>> the others :D
> Should i resubmit one patch named v10? Or should i modify it like the
> others before push? :D

Resubmitting the series for it seems silly.
Just format it like the other ones locally :D
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg
  2023-05-12 10:47       ` Vibhoothi
@ 2023-05-12 11:59         ` Steven Liu
  2023-05-13  2:40           ` Neal Gompa
  0 siblings, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-05-12 11:59 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Vibhoothi <vibhoothiiaanand@gmail.com> 于2023年5月12日周五 18:48写道:
>
> Hi,
>
> On Fri, 12 May 2023 at 04:59, Steven Liu <lq@chinaffmpeg.org> wrote:
> >
> > Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> > The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
> > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> > The enhanced flv documentation contributors include
> > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> > So this should be support by ffmpeg too.
> >
> > v8:
> >     Support vp9 codec according to enhanced flv.
> >     Support PacketTypeCodedFrames type for hevc in flv.
> > v9:
> >     Add dependency codec object files for flvenc in Makefile.
> >     Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
> >
> > Steven Liu (6):
> >   avformat/flvenc: Add support for HEVC over flv in muxer
> >   avformat/flvdec: support demux hevc in enhanced flv
> >   avformat/flvenc: support mux av1 in enhanced flv
> >   avformat/flvdec: support demux av1 in enhanced flv
> >   avformat/flvenc: support mux vp9 in enhanced flv
> >   avformat/flvenc: support demux vp9 in enhanced flv
> Nit: Shouldn't the commit message be pointing flvdec
> ("avformat/flvdec") instead of flvenc ("avformat/flvenc") for
> VP9 demuxer support?
Good catch,
Thanks Vibhoothi

 fix it localy.
>
> I could see the changes being made to,
>  libavformat/flvdec.c | 11 +++++++++--,
> in the patch set.
>
> >
> >  libavformat/Makefile |  2 +-
> >  libavformat/flv.h    | 15 +++++++++
> >  libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
> >  libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
> >  4 files changed, 130 insertions(+), 18 deletions(-)
> >
> > --
> > 2.40.0
> >


Thanks
Steven
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg
  2023-05-12 11:59         ` Steven Liu
@ 2023-05-13  2:40           ` Neal Gompa
  2023-05-15  8:31             ` [FFmpeg-devel] [PATCH v10 " Steven Liu
  2023-05-15  8:37             ` [FFmpeg-devel] [PATCH v9 " Steven Liu
  0 siblings, 2 replies; 72+ messages in thread
From: Neal Gompa @ 2023-05-13  2:40 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Fri, May 12, 2023 at 7:59 AM Steven Liu <lingjiujianke@gmail.com> wrote:
>
> Vibhoothi <vibhoothiiaanand@gmail.com> 于2023年5月12日周五 18:48写道:
> >
> > Hi,
> >
> > On Fri, 12 May 2023 at 04:59, Steven Liu <lq@chinaffmpeg.org> wrote:
> > >
> > > Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> > > The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
> > > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> > > The enhanced flv documentation contributors include
> > > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> > > So this should be support by ffmpeg too.
> > >
> > > v8:
> > >     Support vp9 codec according to enhanced flv.
> > >     Support PacketTypeCodedFrames type for hevc in flv.
> > > v9:
> > >     Add dependency codec object files for flvenc in Makefile.
> > >     Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
> > >
> > > Steven Liu (6):
> > >   avformat/flvenc: Add support for HEVC over flv in muxer
> > >   avformat/flvdec: support demux hevc in enhanced flv
> > >   avformat/flvenc: support mux av1 in enhanced flv
> > >   avformat/flvdec: support demux av1 in enhanced flv
> > >   avformat/flvenc: support mux vp9 in enhanced flv
> > >   avformat/flvenc: support demux vp9 in enhanced flv
> > Nit: Shouldn't the commit message be pointing flvdec
> > ("avformat/flvdec") instead of flvenc ("avformat/flvenc") for
> > VP9 demuxer support?
> Good catch,
> Thanks Vibhoothi
>
>  fix it localy.
> >
> > I could see the changes being made to,
> >  libavformat/flvdec.c | 11 +++++++++--,
> > in the patch set.
> >
> > >
> > >  libavformat/Makefile |  2 +-
> > >  libavformat/flv.h    | 15 +++++++++
> > >  libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
> > >  libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
> > >  4 files changed, 130 insertions(+), 18 deletions(-)
> > >
> > > --
> > > 2.40.0
> > >
>

I've applied your patch set to Fedora's ffmpeg 6.0 on Fedora 38 and
attempted to test it. It seems to mostly work now, except that AAC
audio doesn't play in the AV1+AAC sample remuxed from MKV to FLV. My
H264+AAC sample seems to work properly though.

Here are reproducer samples:
https://ngompa.fedorapeople.org/obs-recording-samples.tar

My command for remuxing them is simple:

$ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"


-- 
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-05-13  2:40           ` Neal Gompa
@ 2023-05-15  8:31             ` Steven Liu
  2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 1/6] avformat/flvenc: support mux hevc in enhanced flv Steven Liu
                                 ` (6 more replies)
  2023-05-15  8:37             ` [FFmpeg-devel] [PATCH v9 " Steven Liu
  1 sibling, 7 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-15  8:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
The enhanced flv documentation contributors include
Jean-Baptiste Kempf (FFmpeg, VideoLAN).
So this should be support by ffmpeg too.

v8:
    Support vp9 codec according to enhanced flv.
    Support PacketTypeCodedFrames type for hevc in flv.
v9:
    Add dependency codec object files for flvenc in Makefile.
    Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.

v10:
    modify first patch comment like the others before commit.
    exheader mode should only happened in video stream this patchset.

Steven Liu (6):
  avformat/flvenc: support mux hevc in enhanced flv
  avformat/flvdec: support demux hevc in enhanced flv
  avformat/flvenc: support mux av1 in enhanced flv
  avformat/flvdec: support demux av1 in enhanced flv
  avformat/flvenc: support mux vp9 in enhanced flv
  avformat/flvdec: support demux vp9 in enhanced flv

 libavformat/Makefile |  2 +-
 libavformat/flv.h    | 15 +++++++++
 libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
 libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
 4 files changed, 130 insertions(+), 18 deletions(-)

-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v10 1/6] avformat/flvenc: support mux hevc in enhanced flv
  2023-05-15  8:31             ` [FFmpeg-devel] [PATCH v10 " Steven Liu
@ 2023-05-15  8:31               ` Steven Liu
  2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 2/6] avformat/flvdec: support demux " Steven Liu
                                 ` (5 subsequent siblings)
  6 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-15  8:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v10 2/6] avformat/flvdec: support demux hevc in enhanced flv
  2023-05-15  8:31             ` [FFmpeg-devel] [PATCH v10 " Steven Liu
  2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 1/6] avformat/flvenc: support mux hevc in enhanced flv Steven Liu
@ 2023-05-15  8:31               ` Steven Liu
  2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 3/6] avformat/flvenc: support mux av1 " Steven Liu
                                 ` (4 subsequent siblings)
  6 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-15  8:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/flvdec.c | 58 ++++++++++++++++++++++++++++++++++++++------
 1 file changed, 50 insertions(+), 8 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index d83edff727..c8e6cadf1c 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 && stream_type == FLV_STREAM_TYPE_VIDEO) {
+            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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v10 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-15  8:31             ` [FFmpeg-devel] [PATCH v10 " Steven Liu
  2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 1/6] avformat/flvenc: support mux hevc in enhanced flv Steven Liu
  2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 2/6] avformat/flvdec: support demux " Steven Liu
@ 2023-05-15  8:31               ` Steven Liu
  2023-06-02  4:49                 ` Tristan Matthews
  2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 4/6] avformat/flvdec: support demux av1 " Steven Liu
                                 ` (3 subsequent siblings)
  6 siblings, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-05-15  8:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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);
         }
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v10 4/6] avformat/flvdec: support demux av1 in enhanced flv
  2023-05-15  8:31             ` [FFmpeg-devel] [PATCH v10 " Steven Liu
                                 ` (2 preceding siblings ...)
  2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 3/6] avformat/flvenc: support mux av1 " Steven Liu
@ 2023-05-15  8:31               ` Steven Liu
  2023-05-15  8:32               ` [FFmpeg-devel] [PATCH v10 5/6] avformat/flvenc: support mux vp9 " Steven Liu
                                 ` (2 subsequent siblings)
  6 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-15  8:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/flvdec.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index c8e6cadf1c..a0362ff11c 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 && stream_type == FLV_STREAM_TYPE_VIDEO) {
             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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v10 5/6] avformat/flvenc: support mux vp9 in enhanced flv
  2023-05-15  8:31             ` [FFmpeg-devel] [PATCH v10 " Steven Liu
                                 ` (3 preceding siblings ...)
  2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 4/6] avformat/flvdec: support demux av1 " Steven Liu
@ 2023-05-15  8:32               ` Steven Liu
  2023-05-15  8:32               ` [FFmpeg-devel] [PATCH v10 6/6] avformat/flvdec: support demux " Steven Liu
  2023-05-15 20:41               ` [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg Neal Gompa
  6 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-15  8:32 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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);
         }
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v10 6/6] avformat/flvdec: support demux vp9 in enhanced flv
  2023-05-15  8:31             ` [FFmpeg-devel] [PATCH v10 " Steven Liu
                                 ` (4 preceding siblings ...)
  2023-05-15  8:32               ` [FFmpeg-devel] [PATCH v10 5/6] avformat/flvenc: support mux vp9 " Steven Liu
@ 2023-05-15  8:32               ` Steven Liu
  2023-05-15 20:41               ` [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg Neal Gompa
  6 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-15  8:32 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/flvdec.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index a0362ff11c..a6a94a4021 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 && stream_type == FLV_STREAM_TYPE_VIDEO) {
             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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg
  2023-05-13  2:40           ` Neal Gompa
  2023-05-15  8:31             ` [FFmpeg-devel] [PATCH v10 " Steven Liu
@ 2023-05-15  8:37             ` Steven Liu
  1 sibling, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-05-15  8:37 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Neal Gompa <ngompa13@gmail.com> 于2023年5月13日周六 10:41写道:
Hi Neal,

>
>
> I've applied your patch set to Fedora's ffmpeg 6.0 on Fedora 38 and
> attempted to test it. It seems to mostly work now, except that AAC
> audio doesn't play in the AV1+AAC sample remuxed from MKV to FLV. My
> H264+AAC sample seems to work properly though.
>
> Here are reproducer samples:
> https://ngompa.fedorapeople.org/obs-recording-samples.tar
>
> My command for remuxing them is simple:
>
> $ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv"

    Thanks for your test, that because the exheader flag is used in
audio stream too,
    It should used in video stream and exheader mode.



Thanks
Steven
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-05-15  8:31             ` [FFmpeg-devel] [PATCH v10 " Steven Liu
                                 ` (5 preceding siblings ...)
  2023-05-15  8:32               ` [FFmpeg-devel] [PATCH v10 6/6] avformat/flvdec: support demux " Steven Liu
@ 2023-05-15 20:41               ` Neal Gompa
  2023-05-31  5:47                 ` Neal Gompa
  6 siblings, 1 reply; 72+ messages in thread
From: Neal Gompa @ 2023-05-15 20:41 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Steven Liu

On Mon, May 15, 2023 at 4:32 AM Steven Liu <lq@chinaffmpeg.org> wrote:
>
> Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
> you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> The enhanced flv documentation contributors include
> Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> So this should be support by ffmpeg too.
>
> v8:
>     Support vp9 codec according to enhanced flv.
>     Support PacketTypeCodedFrames type for hevc in flv.
> v9:
>     Add dependency codec object files for flvenc in Makefile.
>     Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
>
> v10:
>     modify first patch comment like the others before commit.
>     exheader mode should only happened in video stream this patchset.
>
> Steven Liu (6):
>   avformat/flvenc: support mux hevc in enhanced flv
>   avformat/flvdec: support demux hevc in enhanced flv
>   avformat/flvenc: support mux av1 in enhanced flv
>   avformat/flvdec: support demux av1 in enhanced flv
>   avformat/flvenc: support mux vp9 in enhanced flv
>   avformat/flvdec: support demux vp9 in enhanced flv
>
>  libavformat/Makefile |  2 +-
>  libavformat/flv.h    | 15 +++++++++
>  libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
>  libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
>  4 files changed, 130 insertions(+), 18 deletions(-)
>

This version works for me. Thanks for this work!

Tested-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>



-- 
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-05-15 20:41               ` [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg Neal Gompa
@ 2023-05-31  5:47                 ` Neal Gompa
  2023-06-01  0:02                   ` Steven Liu
  2023-06-06  6:42                   ` Steven Liu
  0 siblings, 2 replies; 72+ messages in thread
From: Neal Gompa @ 2023-05-31  5:47 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Steven Liu

On Mon, May 15, 2023 at 10:41 PM Neal Gompa <ngompa13@gmail.com> wrote:
>
> On Mon, May 15, 2023 at 4:32 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> >
> > Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> > The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
> > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> > The enhanced flv documentation contributors include
> > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> > So this should be support by ffmpeg too.
> >
> > v8:
> >     Support vp9 codec according to enhanced flv.
> >     Support PacketTypeCodedFrames type for hevc in flv.
> > v9:
> >     Add dependency codec object files for flvenc in Makefile.
> >     Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
> >
> > v10:
> >     modify first patch comment like the others before commit.
> >     exheader mode should only happened in video stream this patchset.
> >
> > Steven Liu (6):
> >   avformat/flvenc: support mux hevc in enhanced flv
> >   avformat/flvdec: support demux hevc in enhanced flv
> >   avformat/flvenc: support mux av1 in enhanced flv
> >   avformat/flvdec: support demux av1 in enhanced flv
> >   avformat/flvenc: support mux vp9 in enhanced flv
> >   avformat/flvdec: support demux vp9 in enhanced flv
> >
> >  libavformat/Makefile |  2 +-
> >  libavformat/flv.h    | 15 +++++++++
> >  libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
> >  libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
> >  4 files changed, 130 insertions(+), 18 deletions(-)
> >
>
> This version works for me. Thanks for this work!
>
> Tested-by: Neal Gompa <ngompa13@gmail.com>
> Reviewed-by: Neal Gompa <ngompa13@gmail.com>
>

Is this patch set going to get pushed to master anytime soon?



-- 
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-05-31  5:47                 ` Neal Gompa
@ 2023-06-01  0:02                   ` Steven Liu
  2023-06-01  5:03                     ` Tristan Matthews
  2023-06-01  9:29                     ` Jean-Baptiste Kempf
  2023-06-06  6:42                   ` Steven Liu
  1 sibling, 2 replies; 72+ messages in thread
From: Steven Liu @ 2023-06-01  0:02 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Steven Liu

Neal Gompa <ngompa13@gmail.com> 于2023年5月31日周三 13:47写道:
>
> On Mon, May 15, 2023 at 10:41 PM Neal Gompa <ngompa13@gmail.com> wrote:
> >
> > On Mon, May 15, 2023 at 4:32 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> > >
> > > Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> > > The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
> > > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> > > The enhanced flv documentation contributors include
> > > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> > > So this should be support by ffmpeg too.
> > >
> > > v8:
> > >     Support vp9 codec according to enhanced flv.
> > >     Support PacketTypeCodedFrames type for hevc in flv.
> > > v9:
> > >     Add dependency codec object files for flvenc in Makefile.
> > >     Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
> > >
> > > v10:
> > >     modify first patch comment like the others before commit.
> > >     exheader mode should only happened in video stream this patchset.
> > >
> > > Steven Liu (6):
> > >   avformat/flvenc: support mux hevc in enhanced flv
> > >   avformat/flvdec: support demux hevc in enhanced flv
> > >   avformat/flvenc: support mux av1 in enhanced flv
> > >   avformat/flvdec: support demux av1 in enhanced flv
> > >   avformat/flvenc: support mux vp9 in enhanced flv
> > >   avformat/flvdec: support demux vp9 in enhanced flv
> > >
> > >  libavformat/Makefile |  2 +-
> > >  libavformat/flv.h    | 15 +++++++++
> > >  libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
> > >  libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
> > >  4 files changed, 130 insertions(+), 18 deletions(-)
> > >
> >
> > This version works for me. Thanks for this work!
> >
> > Tested-by: Neal Gompa <ngompa13@gmail.com>
> > Reviewed-by: Neal Gompa <ngompa13@gmail.com>
> >
>
> Is this patch set going to get pushed to master anytime soon?

Hi Neal,

Waiting for j-b check about the Enhanced-FLV status, i cannot sure if
this patch can be pushed now.




Thanks
Steven
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-06-01  0:02                   ` Steven Liu
@ 2023-06-01  5:03                     ` Tristan Matthews
  2023-06-01  6:07                       ` Steven Liu
  2023-06-01  9:29                     ` Jean-Baptiste Kempf
  1 sibling, 1 reply; 72+ messages in thread
From: Tristan Matthews @ 2023-06-01  5:03 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Steven Liu

> you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.

Were you able to push av1 or vp9 to Youtube with this patchset alone?

Best,
-t

On Wed, May 31, 2023 at 8:03 PM Steven Liu <lingjiujianke@gmail.com> wrote:
>
> Neal Gompa <ngompa13@gmail.com> 于2023年5月31日周三 13:47写道:
> >
> > On Mon, May 15, 2023 at 10:41 PM Neal Gompa <ngompa13@gmail.com> wrote:
> > >
> > > On Mon, May 15, 2023 at 4:32 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> > > >
> > > > Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> > > > The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
> > > > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> > > > The enhanced flv documentation contributors include
> > > > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> > > > So this should be support by ffmpeg too.
> > > >
> > > > v8:
> > > >     Support vp9 codec according to enhanced flv.
> > > >     Support PacketTypeCodedFrames type for hevc in flv.
> > > > v9:
> > > >     Add dependency codec object files for flvenc in Makefile.
> > > >     Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
> > > >
> > > > v10:
> > > >     modify first patch comment like the others before commit.
> > > >     exheader mode should only happened in video stream this patchset.
> > > >
> > > > Steven Liu (6):
> > > >   avformat/flvenc: support mux hevc in enhanced flv
> > > >   avformat/flvdec: support demux hevc in enhanced flv
> > > >   avformat/flvenc: support mux av1 in enhanced flv
> > > >   avformat/flvdec: support demux av1 in enhanced flv
> > > >   avformat/flvenc: support mux vp9 in enhanced flv
> > > >   avformat/flvdec: support demux vp9 in enhanced flv
> > > >
> > > >  libavformat/Makefile |  2 +-
> > > >  libavformat/flv.h    | 15 +++++++++
> > > >  libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
> > > >  libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
> > > >  4 files changed, 130 insertions(+), 18 deletions(-)
> > > >
> > >
> > > This version works for me. Thanks for this work!
> > >
> > > Tested-by: Neal Gompa <ngompa13@gmail.com>
> > > Reviewed-by: Neal Gompa <ngompa13@gmail.com>
> > >
> >
> > Is this patch set going to get pushed to master anytime soon?
>
> Hi Neal,
>
> Waiting for j-b check about the Enhanced-FLV status, i cannot sure if
> this patch can be pushed now.
>
>
>
>
> Thanks
> Steven
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-06-01  5:03                     ` Tristan Matthews
@ 2023-06-01  6:07                       ` Steven Liu
  2023-06-01 17:57                         ` Tristan Matthews
  0 siblings, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-06-01  6:07 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Tristan Matthews <tmatth@videolan.org> 于2023年6月1日周四 13:03写道:
>
> > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
>
> Were you able to push av1 or vp9 to Youtube with this patchset alone?
I've tested push them after after this patchset, do you mean you get
some problems after this patchset?


Thanks
Steven
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-06-01  0:02                   ` Steven Liu
  2023-06-01  5:03                     ` Tristan Matthews
@ 2023-06-01  9:29                     ` Jean-Baptiste Kempf
  2023-07-17 11:37                       ` Jean-Baptiste Kempf
  1 sibling, 1 reply; 72+ messages in thread
From: Jean-Baptiste Kempf @ 2023-06-01  9:29 UTC (permalink / raw)
  To: Steven Liu, ffmpeg-devel; +Cc: Steven Liu

Hello,

On Thu, 1 Jun 2023, at 02:02, Steven Liu wrote:
> Neal Gompa <ngompa13@gmail.com> 于2023年5月31日周三 13:47写道:
>>
>> On Mon, May 15, 2023 at 10:41 PM Neal Gompa <ngompa13@gmail.com> wrote:
>> >
>> > On Mon, May 15, 2023 at 4:32 AM Steven Liu <lq@chinaffmpeg.org> wrote:
>> > >
>> > > Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
>> > > The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
>> > > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
>> > > The enhanced flv documentation contributors include
>> > > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
>> > > So this should be support by ffmpeg too.
>> > >
>> > > v8:
>> > >     Support vp9 codec according to enhanced flv.
>> > >     Support PacketTypeCodedFrames type for hevc in flv.
>> > > v9:
>> > >     Add dependency codec object files for flvenc in Makefile.
>> > >     Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
>> > >
>> > > v10:
>> > >     modify first patch comment like the others before commit.
>> > >     exheader mode should only happened in video stream this patchset.
>> > >
>> > > Steven Liu (6):
>> > >   avformat/flvenc: support mux hevc in enhanced flv
>> > >   avformat/flvdec: support demux hevc in enhanced flv
>> > >   avformat/flvenc: support mux av1 in enhanced flv
>> > >   avformat/flvdec: support demux av1 in enhanced flv
>> > >   avformat/flvenc: support mux vp9 in enhanced flv
>> > >   avformat/flvdec: support demux vp9 in enhanced flv
>> > >
>> > >  libavformat/Makefile |  2 +-
>> > >  libavformat/flv.h    | 15 +++++++++
>> > >  libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
>> > >  libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
>> > >  4 files changed, 130 insertions(+), 18 deletions(-)
>> > >
>> >
>> > This version works for me. Thanks for this work!
>> >
>> > Tested-by: Neal Gompa <ngompa13@gmail.com>
>> > Reviewed-by: Neal Gompa <ngompa13@gmail.com>
>> >
>>
>> Is this patch set going to get pushed to master anytime soon?
>
> Hi Neal,
>
> Waiting for j-b check about the Enhanced-FLV status, i cannot sure if
> this patch can be pushed now.

I've just re-asked what is the final status of the spec.

If you cannot wait, use experimental flags.

jb
-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-06-01  6:07                       ` Steven Liu
@ 2023-06-01 17:57                         ` Tristan Matthews
  2023-06-02  1:37                           ` Steven Liu
  0 siblings, 1 reply; 72+ messages in thread
From: Tristan Matthews @ 2023-06-01 17:57 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Thu, Jun 1, 2023 at 2:08 AM Steven Liu <lingjiujianke@gmail.com> wrote:
>
> Tristan Matthews <tmatth@videolan.org> 于2023年6月1日周四 13:03写道:
> >
> > > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> >
> > Were you able to push av1 or vp9 to Youtube with this patchset alone?
> I've tested push them after after this patchset, do you mean you get
> some problems after this patchset?

Yeah for me at least vp9 and av1 are falling over when I try to push
to youtube over RTMP, I was under the impression that beyond patching
the FLV muxer you'd also need to add a `fourCcList` to the connect
command of the rtmp muxer (see "Extending NetConnection connect
command" of https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf).

In any case that's not really the scope of this patchset and I don't
want to derail the discussion, muxing to an flv file works fine. I
just wanted to clarify what was possible with these changes and I'm
surprised that you were able to push to youtube live with this given
the above, as I am not.

Best,
-t

>
>
> Thanks
> Steven
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-06-01 17:57                         ` Tristan Matthews
@ 2023-06-02  1:37                           ` Steven Liu
  0 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-06-02  1:37 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Tristan Matthews <tmatth@videolan.org> 于2023年6月2日周五 01:58写道:
>
> On Thu, Jun 1, 2023 at 2:08 AM Steven Liu <lingjiujianke@gmail.com> wrote:
> >
> > Tristan Matthews <tmatth@videolan.org> 于2023年6月1日周四 13:03写道:
> > >
> > > > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> > >
> > > Were you able to push av1 or vp9 to Youtube with this patchset alone?
> > I've tested push them after after this patchset, do you mean you get
> > some problems after this patchset?
>
> Yeah for me at least vp9 and av1 are falling over when I try to push
> to youtube over RTMP, I was under the impression that beyond patching
> the FLV muxer you'd also need to add a `fourCcList` to the connect
> command of the rtmp muxer (see "Extending NetConnection connect
> command" of https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf).
>
> In any case that's not really the scope of this patchset and I don't
> want to derail the discussion, muxing to an flv file works fine. I
> just wanted to clarify what was possible with these changes and I'm
> surprised that you were able to push to youtube live with this given
> the above, as I am not.
I tested publish the two codecs type, av1,vp9 to youtube, and i can
play by youtube player, but i saw the stream info always is vp9 in
flv.

Thanks
Steven
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 3/6] avformat/flvenc: support mux av1 " Steven Liu
@ 2023-06-02  4:49                 ` Tristan Matthews
  2023-06-02  7:19                   ` Steven Liu
  2023-06-02  7:31                   ` [FFmpeg-devel] [PATCH v11 0/6] Support enhanced flv in FFmpeg Steven Liu
  0 siblings, 2 replies; 72+ messages in thread
From: Tristan Matthews @ 2023-06-02  4:49 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Steven Liu

On Mon, May 15, 2023 at 4:43 AM Steven Liu <lq@chinaffmpeg.org> wrote:
>
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  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);

For this and all the other instances of writing the EX_HEADER bytes,
given that in the spec it specifies:
> isExHeader | FrameType     UB[4]

where FrameType is in this context either keyframe (1) or inter frame
(2), shouldn't this be something like:

avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeCodedFramesX | is_keyframe?
FLV_KEY : FLV_INTER);

?

Best,
-t
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-06-02  4:49                 ` Tristan Matthews
@ 2023-06-02  7:19                   ` Steven Liu
  2023-06-02  7:31                   ` [FFmpeg-devel] [PATCH v11 0/6] Support enhanced flv in FFmpeg Steven Liu
  1 sibling, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-06-02  7:19 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Steven Liu

Tristan Matthews <tmatth@videolan.org> 于2023年6月2日周五 12:50写道:
>
> On Mon, May 15, 2023 at 4:43 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> >
> > Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > ---
> >  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);
>
> For this and all the other instances of writing the EX_HEADER bytes,
> given that in the spec it specifies:
> > isExHeader | FrameType     UB[4]
>
> where FrameType is in this context either keyframe (1) or inter frame
> (2), shouldn't this be something like:
>
> avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeCodedFramesX | is_keyframe?
> FLV_KEY : FLV_INTER);
Good catch, i have make new patchset some days ago, will resubmit
soon, not only this way.


Thanks
Steven
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v11 0/6] Support enhanced flv in FFmpeg
  2023-06-02  4:49                 ` Tristan Matthews
  2023-06-02  7:19                   ` Steven Liu
@ 2023-06-02  7:31                   ` Steven Liu
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 1/6] avformat/flvenc: support mux hevc in enhanced flv Steven Liu
                                       ` (5 more replies)
  1 sibling, 6 replies; 72+ messages in thread
From: Steven Liu @ 2023-06-02  7:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
The enhanced flv documentation contributors include
Jean-Baptiste Kempf (FFmpeg, VideoLAN).
So this should be support by ffmpeg too.

v8:
    Support vp9 codec according to enhanced flv.
    Support PacketTypeCodedFrames type for hevc in flv.
v9:
    Add dependency codec object files for flvenc in Makefile.
    Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.

v10:
    modify first patch comment like the others before commit.
    exheader mode should only happened in video stream this patchset.

v11:
    use IsExHeader|FrameType in enhanced flv muxer,

Steven Liu (6):
  avformat/flvenc: support mux hevc in enhanced flv
  avformat/flvdec: support demux hevc in enhanced flv
  avformat/flvenc: support mux av1 in enhanced flv
  avformat/flvdec: support demux av1 in enhanced flv
  avformat/flvenc: support mux vp9 in enhanced flv
  avformat/flvdec: support demux vp9 in enhanced flv

 libavformat/Makefile |  2 +-
 libavformat/flv.h    | 15 +++++++++
 libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
 libavformat/flvenc.c | 61 ++++++++++++++++++++++++++++++------
 4 files changed, 132 insertions(+), 19 deletions(-)

-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v11 1/6] avformat/flvenc: support mux hevc in enhanced flv
  2023-06-02  7:31                   ` [FFmpeg-devel] [PATCH v11 0/6] Support enhanced flv in FFmpeg Steven Liu
@ 2023-06-02  7:31                     ` Steven Liu
  2023-06-02 11:08                       ` Lance Wang
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 2/6] avformat/flvdec: support demux " Steven Liu
                                       ` (4 subsequent siblings)
  5 siblings, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-06-02  7:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/Makefile |  2 +-
 libavformat/flv.h    | 15 +++++++++++++++
 libavformat/flvenc.c | 41 +++++++++++++++++++++++++++++++----------
 3 files changed, 47 insertions(+), 11 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..aed0946a2e 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 | FLV_FRAME_KEY); // 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);
@@ -821,6 +832,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
     unsigned ts;
     int size = pkt->size;
     uint8_t *data = NULL;
+    uint8_t frametype = pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER;
     int flags = -1, flags_size, ret = 0;
     int64_t cur_offset = avio_tell(pb);
 
@@ -832,13 +844,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 +870,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);
@@ -881,7 +893,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
 
         flags = ff_codec_get_tag(flv_video_codec_ids, par->codec_id);
 
-        flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER;
+        flags |= frametype;
         break;
     case AVMEDIA_TYPE_AUDIO:
         flags = get_audio_flags(s, par);
@@ -903,6 +915,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 +980,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 | frametype); // 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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v11 2/6] avformat/flvdec: support demux hevc in enhanced flv
  2023-06-02  7:31                   ` [FFmpeg-devel] [PATCH v11 0/6] Support enhanced flv in FFmpeg Steven Liu
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 1/6] avformat/flvenc: support mux hevc in enhanced flv Steven Liu
@ 2023-06-02  7:31                     ` Steven Liu
  2023-06-02 11:15                       ` Lance Wang
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 3/6] avformat/flvenc: support mux av1 " Steven Liu
                                       ` (3 subsequent siblings)
  5 siblings, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-06-02  7:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/flvdec.c | 58 ++++++++++++++++++++++++++++++++++++++------
 1 file changed, 50 insertions(+), 8 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index d83edff727..c8e6cadf1c 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 && stream_type == FLV_STREAM_TYPE_VIDEO) {
+            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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v11 3/6] avformat/flvenc: support mux av1 in enhanced flv
  2023-06-02  7:31                   ` [FFmpeg-devel] [PATCH v11 0/6] Support enhanced flv in FFmpeg Steven Liu
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 1/6] avformat/flvenc: support mux hevc in enhanced flv Steven Liu
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 2/6] avformat/flvdec: support demux " Steven Liu
@ 2023-06-02  7:31                     ` Steven Liu
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 4/6] avformat/flvdec: support demux " Steven Liu
                                       ` (2 subsequent siblings)
  5 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-06-02  7:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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 aed0946a2e..99fa1bd723 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 | FLV_FRAME_KEY); // 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 | FLV_FRAME_KEY);
+                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);
         }
@@ -844,13 +852,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))) {
@@ -870,7 +880,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);
@@ -983,6 +994,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 | frametype); // 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 | frametype);
+            avio_write(pb, "av01", 4);
         } else {
             avio_w8(pb, flags);
         }
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v11 4/6] avformat/flvdec: support demux av1 in enhanced flv
  2023-06-02  7:31                   ` [FFmpeg-devel] [PATCH v11 0/6] Support enhanced flv in FFmpeg Steven Liu
                                       ` (2 preceding siblings ...)
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 3/6] avformat/flvenc: support mux av1 " Steven Liu
@ 2023-06-02  7:31                     ` Steven Liu
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 5/6] avformat/flvenc: support mux vp9 " Steven Liu
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 6/6] avformat/flvdec: support demux " Steven Liu
  5 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-06-02  7:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/flvdec.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index c8e6cadf1c..a0362ff11c 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 && stream_type == FLV_STREAM_TYPE_VIDEO) {
             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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v11 5/6] avformat/flvenc: support mux vp9 in enhanced flv
  2023-06-02  7:31                   ` [FFmpeg-devel] [PATCH v11 0/6] Support enhanced flv in FFmpeg Steven Liu
                                       ` (3 preceding siblings ...)
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 4/6] avformat/flvdec: support demux " Steven Liu
@ 2023-06-02  7:31                     ` Steven Liu
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 6/6] avformat/flvdec: support demux " Steven Liu
  5 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-06-02  7:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 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 99fa1bd723..335d900415 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 | FLV_FRAME_KEY); // 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 | FLV_FRAME_KEY);
-                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);
         }
@@ -853,14 +857,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))) {
@@ -881,7 +886,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);
@@ -994,9 +1000,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 | frametype); // 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 | frametype);
-            avio_write(pb, "av01", 4);
+            avio_write(pb, par->codec_id == AV_CODEC_ID_AV1 ? "av01" : "vp09", 4);
         } else {
             avio_w8(pb, flags);
         }
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* [FFmpeg-devel] [PATCH v11 6/6] avformat/flvdec: support demux vp9 in enhanced flv
  2023-06-02  7:31                   ` [FFmpeg-devel] [PATCH v11 0/6] Support enhanced flv in FFmpeg Steven Liu
                                       ` (4 preceding siblings ...)
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 5/6] avformat/flvenc: support mux vp9 " Steven Liu
@ 2023-06-02  7:31                     ` Steven Liu
  5 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-06-02  7:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Steven Liu

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/flvdec.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index a0362ff11c..a6a94a4021 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 && stream_type == FLV_STREAM_TYPE_VIDEO) {
             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) {
-- 
2.40.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v11 1/6] avformat/flvenc: support mux hevc in enhanced flv
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 1/6] avformat/flvenc: support mux hevc in enhanced flv Steven Liu
@ 2023-06-02 11:08                       ` Lance Wang
  2023-06-02 11:28                         ` Steven Liu
  0 siblings, 1 reply; 72+ messages in thread
From: Lance Wang @ 2023-06-02 11:08 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Fri, Jun 2, 2023 at 3:31 PM Steven Liu <lq@chinaffmpeg.org> wrote:

> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/Makefile |  2 +-
>  libavformat/flv.h    | 15 +++++++++++++++
>  libavformat/flvenc.c | 41 +++++++++++++++++++++++++++++++----------
>  3 files changed, 47 insertions(+), 11 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,
> +};
> +
>

format and align the "="?



>  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..aed0946a2e 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 |
> FLV_FRAME_KEY); // ExVideoTagHeader mode with PacketTypeSequenceStart
> +                avio_write(pb, "hvc1", 4);
>
 ff_isom_write_hvcc(pb, par->extradata, par->extradata_size, 0);


> +            } 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)
> +                ff_isom_write_hvcc(pb, par->extradata,
> par->extradata_size, 0);
> +            else
> +                ff_isom_write_avcc(pb, par->extradata,
> par->extradata_size);
>

merge the if else?

         }
>          data_size = avio_tell(pb) - pos;
>          avio_seek(pb, -data_size - 10, SEEK_CUR);
> @@ -821,6 +832,7 @@ static int flv_write_packet(AVFormatContext *s,
> AVPacket *pkt)
>      unsigned ts;
>      int size = pkt->size;
>      uint8_t *data = NULL;
> +    uint8_t frametype = pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY :
> FLV_FRAME_INTER;
>      int flags = -1, flags_size, ret = 0;
>      int64_t cur_offset = avio_tell(pb);
>
> @@ -832,13 +844,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 +870,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);
> @@ -881,7 +893,7 @@ static int flv_write_packet(AVFormatContext *s,
> AVPacket *pkt)
>
>          flags = ff_codec_get_tag(flv_video_codec_ids, par->codec_id);
>
> -        flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY :
> FLV_FRAME_INTER;
> +        flags |= frametype;
>          break;
>      case AVMEDIA_TYPE_AUDIO:
>          flags = get_audio_flags(s, par);
> @@ -903,6 +915,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)
>

For the annexb format, stricter checks are as follows if follow by standard
IMO:
AV_RB24(par->extradata) == 1 || AV_RB32(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 +980,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 |
> frametype); // ExVideoTagHeader mode with PacketTypeCodedFramesX
>

frametype will << 2, so it's better to use below order:
FLV_IS_EX_HEADER | frametype | 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) {
> --
> 2.40.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v11 2/6] avformat/flvdec: support demux hevc in enhanced flv
  2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 2/6] avformat/flvdec: support demux " Steven Liu
@ 2023-06-02 11:15                       ` Lance Wang
  0 siblings, 0 replies; 72+ messages in thread
From: Lance Wang @ 2023-06-02 11:15 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Fri, Jun 2, 2023 at 3:32 PM Steven Liu <lq@chinaffmpeg.org> wrote:

> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/flvdec.c | 58 ++++++++++++++++++++++++++++++++++++++------
>  1 file changed, 50 insertions(+), 8 deletions(-)
>
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index d83edff727..c8e6cadf1c 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;
>

int type;

+        if (flv->exheader && stream_type == FLV_STREAM_TYPE_VIDEO) {
> +            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) {
> --
> 2.40.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v11 1/6] avformat/flvenc: support mux hevc in enhanced flv
  2023-06-02 11:08                       ` Lance Wang
@ 2023-06-02 11:28                         ` Steven Liu
  2023-06-02 15:52                           ` Lance Wang
  0 siblings, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-06-02 11:28 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Lance Wang <lance.lmwang@gmail.com> 于2023年6月2日周五 19:09写道:
>
> On Fri, Jun 2, 2023 at 3:31 PM Steven Liu <lq@chinaffmpeg.org> wrote:
>
> > Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > ---
> >  libavformat/Makefile |  2 +-
> >  libavformat/flv.h    | 15 +++++++++++++++
> >  libavformat/flvenc.c | 41 +++++++++++++++++++++++++++++++----------
> >  3 files changed, 47 insertions(+), 11 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,
> > +};
> > +
> >
>
> format and align the "="?
yes it is aligned in patch, you can reference in
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20230602073109.14086-2-lq@chinaffmpeg.org/
>
>
>
> >  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..aed0946a2e 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 |
> > FLV_FRAME_KEY); // ExVideoTagHeader mode with PacketTypeSequenceStart
> > +                avio_write(pb, "hvc1", 4);
> >
>  ff_isom_write_hvcc(pb, par->extradata, par->extradata_size, 0);
>
>
> > +            } 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)
> > +                ff_isom_write_hvcc(pb, par->extradata,
> > par->extradata_size, 0);
> > +            else
> > +                ff_isom_write_avcc(pb, par->extradata,
> > par->extradata_size);
> >
>
> merge the if else?
No, these modify will be used at the patches after this patch,
>
>          }
> >          data_size = avio_tell(pb) - pos;
> >          avio_seek(pb, -data_size - 10, SEEK_CUR);
> > @@ -821,6 +832,7 @@ static int flv_write_packet(AVFormatContext *s,
> > AVPacket *pkt)
> >      unsigned ts;
> >      int size = pkt->size;
> >      uint8_t *data = NULL;
> > +    uint8_t frametype = pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY :
> > FLV_FRAME_INTER;
> >      int flags = -1, flags_size, ret = 0;
> >      int64_t cur_offset = avio_tell(pb);
> >
> > @@ -832,13 +844,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 +870,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);
> > @@ -881,7 +893,7 @@ static int flv_write_packet(AVFormatContext *s,
> > AVPacket *pkt)
> >
> >          flags = ff_codec_get_tag(flv_video_codec_ids, par->codec_id);
> >
> > -        flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY :
> > FLV_FRAME_INTER;
> > +        flags |= frametype;
> >          break;
> >      case AVMEDIA_TYPE_AUDIO:
> >          flags = get_audio_flags(s, par);
> > @@ -903,6 +915,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)
> >
>
> For the annexb format, stricter checks are as follows if follow by standard
> IMO:
> AV_RB24(par->extradata) == 1 || AV_RB32(par->extradata) == 1)
Are there have some problems if i use the code  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 +980,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 |
> > frametype); // ExVideoTagHeader mode with PacketTypeCodedFramesX
> >
>
> frametype will << 2, so it's better to use below order:
> FLV_IS_EX_HEADER | frametype | PacketTypeCodedFramesX
fixed locally.
>
>
>
> > +            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) {
> > --
> > 2.40.0
> >


Thanks
Steven
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v11 1/6] avformat/flvenc: support mux hevc in enhanced flv
  2023-06-02 11:28                         ` Steven Liu
@ 2023-06-02 15:52                           ` Lance Wang
  2023-06-02 23:44                             ` Steven Liu
  0 siblings, 1 reply; 72+ messages in thread
From: Lance Wang @ 2023-06-02 15:52 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Fri, Jun 2, 2023 at 7:29 PM Steven Liu <lingjiujianke@gmail.com> wrote:

> Lance Wang <lance.lmwang@gmail.com> 于2023年6月2日周五 19:09写道:
> >
> > On Fri, Jun 2, 2023 at 3:31 PM Steven Liu <lq@chinaffmpeg.org> wrote:
> >
> > > Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > > ---
> > >  libavformat/Makefile |  2 +-
> > >  libavformat/flv.h    | 15 +++++++++++++++
> > >  libavformat/flvenc.c | 41 +++++++++++++++++++++++++++++++----------
> > >  3 files changed, 47 insertions(+), 11 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,
> > > +};
> > > +
> > >
> >
> > format and align the "="?
> yes it is aligned in patch, you can reference in
>
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20230602073109.14086-2-lq@chinaffmpeg.org/
> >
> >
> >
> > >  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..aed0946a2e 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 |
> > > FLV_FRAME_KEY); // ExVideoTagHeader mode with PacketTypeSequenceStart
> > > +                avio_write(pb, "hvc1", 4);
> > >
> >  ff_isom_write_hvcc(pb, par->extradata, par->extradata_size, 0);
> >
> >
> > > +            } 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)
> > > +                ff_isom_write_hvcc(pb, par->extradata,
> > > par->extradata_size, 0);
> > > +            else
> > > +                ff_isom_write_avcc(pb, par->extradata,
> > > par->extradata_size);
> > >
> >
> > merge the if else?
> No, these modify will be used at the patches after this patch,
> >
> >          }
> > >          data_size = avio_tell(pb) - pos;
> > >          avio_seek(pb, -data_size - 10, SEEK_CUR);
> > > @@ -821,6 +832,7 @@ static int flv_write_packet(AVFormatContext *s,
> > > AVPacket *pkt)
> > >      unsigned ts;
> > >      int size = pkt->size;
> > >      uint8_t *data = NULL;
> > > +    uint8_t frametype = pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY :
> > > FLV_FRAME_INTER;
> > >      int flags = -1, flags_size, ret = 0;
> > >      int64_t cur_offset = avio_tell(pb);
> > >
> > > @@ -832,13 +844,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 +870,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);
> > > @@ -881,7 +893,7 @@ static int flv_write_packet(AVFormatContext *s,
> > > AVPacket *pkt)
> > >
> > >          flags = ff_codec_get_tag(flv_video_codec_ids, par->codec_id);
> > >
> > > -        flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY :
> > > FLV_FRAME_INTER;
> > > +        flags |= frametype;
> > >          break;
> > >      case AVMEDIA_TYPE_AUDIO:
> > >          flags = get_audio_flags(s, par);
> > > @@ -903,6 +915,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)
> > >
> >
> > For the annexb format, stricter checks are as follows if follow by
> standard
> > IMO:
> > AV_RB24(par->extradata) == 1 || AV_RB32(par->extradata) == 1)
> Are there have some problems if i use the code  if
> (par->extradata_size > 0 && *(uint8_t*)par->extradata != 1) ?
>
>
the pattern is very simple and will be misdetected if extradata is corrupt
etc.
Now the extradata is hvcc or annexb,  for hvcc, the
*(uint8_t*)par->extradata == 1,
so the condition is assuming if it's not hvcc, then it's annexb. isn't 100%
correct?




> >
> >
> > > +            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 +980,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 |
> > > frametype); // ExVideoTagHeader mode with PacketTypeCodedFramesX
> > >
> >
> > frametype will << 2, so it's better to use below order:
> > FLV_IS_EX_HEADER | frametype | PacketTypeCodedFramesX
> fixed locally.
> >
> >
> >
> > > +            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) {
> > > --
> > > 2.40.0
> > >
>
>
> Thanks
> Steven
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v11 1/6] avformat/flvenc: support mux hevc in enhanced flv
  2023-06-02 15:52                           ` Lance Wang
@ 2023-06-02 23:44                             ` Steven Liu
  0 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-06-02 23:44 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Lance Wang <lance.lmwang@gmail.com> 于2023年6月2日周五 23:52写道:
>
> On Fri, Jun 2, 2023 at 7:29 PM Steven Liu <lingjiujianke@gmail.com> wrote:
>
> > Lance Wang <lance.lmwang@gmail.com> 于2023年6月2日周五 19:09写道:
> > >
> > > On Fri, Jun 2, 2023 at 3:31 PM Steven Liu <lq@chinaffmpeg.org> wrote:
> > >
> > > > Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > > > ---
> > > >  libavformat/Makefile |  2 +-
> > > >  libavformat/flv.h    | 15 +++++++++++++++
> > > >  libavformat/flvenc.c | 41 +++++++++++++++++++++++++++++++----------
> > > >  3 files changed, 47 insertions(+), 11 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,
> > > > +};
> > > > +
> > > >
> > >
> > > format and align the "="?
> > yes it is aligned in patch, you can reference in
> >
> > https://patchwork.ffmpeg.org/project/ffmpeg/patch/20230602073109.14086-2-lq@chinaffmpeg.org/
> > >
> > >
> > >
> > > >  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..aed0946a2e 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 |
> > > > FLV_FRAME_KEY); // ExVideoTagHeader mode with PacketTypeSequenceStart
> > > > +                avio_write(pb, "hvc1", 4);
> > > >
> > >  ff_isom_write_hvcc(pb, par->extradata, par->extradata_size, 0);
> > >
> > >
> > > > +            } 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)
> > > > +                ff_isom_write_hvcc(pb, par->extradata,
> > > > par->extradata_size, 0);
> > > > +            else
> > > > +                ff_isom_write_avcc(pb, par->extradata,
> > > > par->extradata_size);
> > > >
> > >
> > > merge the if else?
> > No, these modify will be used at the patches after this patch,
> > >
> > >          }
> > > >          data_size = avio_tell(pb) - pos;
> > > >          avio_seek(pb, -data_size - 10, SEEK_CUR);
> > > > @@ -821,6 +832,7 @@ static int flv_write_packet(AVFormatContext *s,
> > > > AVPacket *pkt)
> > > >      unsigned ts;
> > > >      int size = pkt->size;
> > > >      uint8_t *data = NULL;
> > > > +    uint8_t frametype = pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY :
> > > > FLV_FRAME_INTER;
> > > >      int flags = -1, flags_size, ret = 0;
> > > >      int64_t cur_offset = avio_tell(pb);
> > > >
> > > > @@ -832,13 +844,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 +870,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);
> > > > @@ -881,7 +893,7 @@ static int flv_write_packet(AVFormatContext *s,
> > > > AVPacket *pkt)
> > > >
> > > >          flags = ff_codec_get_tag(flv_video_codec_ids, par->codec_id);
> > > >
> > > > -        flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY :
> > > > FLV_FRAME_INTER;
> > > > +        flags |= frametype;
> > > >          break;
> > > >      case AVMEDIA_TYPE_AUDIO:
> > > >          flags = get_audio_flags(s, par);
> > > > @@ -903,6 +915,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)
> > > >
> > >
> > > For the annexb format, stricter checks are as follows if follow by
> > standard
> > > IMO:
> > > AV_RB24(par->extradata) == 1 || AV_RB32(par->extradata) == 1)
> > Are there have some problems if i use the code  if
> > (par->extradata_size > 0 && *(uint8_t*)par->extradata != 1) ?
> >
> >
> the pattern is very simple and will be misdetected if extradata is corrupt
> etc.
> Now the extradata is hvcc or annexb,  for hvcc, the
> *(uint8_t*)par->extradata == 1,
> so the condition is assuming if it's not hvcc, then it's annexb. isn't 100%
> correct?
No, it will crash if extradata is null, so i check the extradata_size first.
>
>
>
>
> > >
> > >
> > > > +            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 +980,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 |
> > > > frametype); // ExVideoTagHeader mode with PacketTypeCodedFramesX
> > > >
> > >
> > > frametype will << 2, so it's better to use below order:
> > > FLV_IS_EX_HEADER | frametype | PacketTypeCodedFramesX
> > fixed locally.
> > >
> > >
> > >
> > > > +            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) {
> > > > --
> > > > 2.40.0
> > > >
> >
> >
> > Thanks
> > Steven
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> >
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-05-31  5:47                 ` Neal Gompa
  2023-06-01  0:02                   ` Steven Liu
@ 2023-06-06  6:42                   ` Steven Liu
  2023-06-08  0:02                     ` Neal Gompa
  1 sibling, 1 reply; 72+ messages in thread
From: Steven Liu @ 2023-06-06  6:42 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Neal Gompa <ngompa13@gmail.com> 于2023年5月31日周三 13:47写道:
>
> On Mon, May 15, 2023 at 10:41 PM Neal Gompa <ngompa13@gmail.com> wrote:
> >
> > On Mon, May 15, 2023 at 4:32 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> > >
> > > Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> > > The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
> > > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> > > The enhanced flv documentation contributors include
> > > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> > > So this should be support by ffmpeg too.
> > >
> > > v8:
> > >     Support vp9 codec according to enhanced flv.
> > >     Support PacketTypeCodedFrames type for hevc in flv.
> > > v9:
> > >     Add dependency codec object files for flvenc in Makefile.
> > >     Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
> > >
> > > v10:
> > >     modify first patch comment like the others before commit.
> > >     exheader mode should only happened in video stream this patchset.
> > >
> > > Steven Liu (6):
> > >   avformat/flvenc: support mux hevc in enhanced flv
> > >   avformat/flvdec: support demux hevc in enhanced flv
> > >   avformat/flvenc: support mux av1 in enhanced flv
> > >   avformat/flvdec: support demux av1 in enhanced flv
> > >   avformat/flvenc: support mux vp9 in enhanced flv
> > >   avformat/flvdec: support demux vp9 in enhanced flv
> > >
> > >  libavformat/Makefile |  2 +-
> > >  libavformat/flv.h    | 15 +++++++++
> > >  libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
> > >  libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
> > >  4 files changed, 130 insertions(+), 18 deletions(-)
> > >
> >
> > This version works for me. Thanks for this work!
> >
> > Tested-by: Neal Gompa <ngompa13@gmail.com>
> > Reviewed-by: Neal Gompa <ngompa13@gmail.com>
> >
>
> Is this patch set going to get pushed to master anytime soon?

Hi Neal,

    Do you agree move the enhanced flv support into experimental flags?



Thanks
Steven
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-06-06  6:42                   ` Steven Liu
@ 2023-06-08  0:02                     ` Neal Gompa
  2023-06-09 22:46                       ` Tristan Matthews
  0 siblings, 1 reply; 72+ messages in thread
From: Neal Gompa @ 2023-06-08  0:02 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Tue, Jun 6, 2023 at 2:43 AM Steven Liu <lingjiujianke@gmail.com> wrote:
>
> Neal Gompa <ngompa13@gmail.com> 于2023年5月31日周三 13:47写道:
> >
> > On Mon, May 15, 2023 at 10:41 PM Neal Gompa <ngompa13@gmail.com> wrote:
> > >
> > > On Mon, May 15, 2023 at 4:32 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> > > >
> > > > Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> > > > The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
> > > > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> > > > The enhanced flv documentation contributors include
> > > > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> > > > So this should be support by ffmpeg too.
> > > >
> > > > v8:
> > > >     Support vp9 codec according to enhanced flv.
> > > >     Support PacketTypeCodedFrames type for hevc in flv.
> > > > v9:
> > > >     Add dependency codec object files for flvenc in Makefile.
> > > >     Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
> > > >
> > > > v10:
> > > >     modify first patch comment like the others before commit.
> > > >     exheader mode should only happened in video stream this patchset.
> > > >
> > > > Steven Liu (6):
> > > >   avformat/flvenc: support mux hevc in enhanced flv
> > > >   avformat/flvdec: support demux hevc in enhanced flv
> > > >   avformat/flvenc: support mux av1 in enhanced flv
> > > >   avformat/flvdec: support demux av1 in enhanced flv
> > > >   avformat/flvenc: support mux vp9 in enhanced flv
> > > >   avformat/flvdec: support demux vp9 in enhanced flv
> > > >
> > > >  libavformat/Makefile |  2 +-
> > > >  libavformat/flv.h    | 15 +++++++++
> > > >  libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
> > > >  libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
> > > >  4 files changed, 130 insertions(+), 18 deletions(-)
> > > >
> > >
> > > This version works for me. Thanks for this work!
> > >
> > > Tested-by: Neal Gompa <ngompa13@gmail.com>
> > > Reviewed-by: Neal Gompa <ngompa13@gmail.com>
> > >
> >
> > Is this patch set going to get pushed to master anytime soon?
>
> Hi Neal,
>
>     Do you agree move the enhanced flv support into experimental flags?
>

I don't think we should mark it experimental. Aside from the fact that
other implementations haven't done that, it's in production now with
YouTube.



-- 
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-06-08  0:02                     ` Neal Gompa
@ 2023-06-09 22:46                       ` Tristan Matthews
  0 siblings, 0 replies; 72+ messages in thread
From: Tristan Matthews @ 2023-06-09 22:46 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Wed, Jun 7, 2023 at 8:02 PM Neal Gompa <ngompa13@gmail.com> wrote:
>
> On Tue, Jun 6, 2023 at 2:43 AM Steven Liu <lingjiujianke@gmail.com> wrote:
> >
> > Neal Gompa <ngompa13@gmail.com> 于2023年5月31日周三 13:47写道:
> > >
> > > On Mon, May 15, 2023 at 10:41 PM Neal Gompa <ngompa13@gmail.com> wrote:
> > > >
> > > > On Mon, May 15, 2023 at 4:32 AM Steven Liu <lq@chinaffmpeg.org> wrote:
> > > > >
> > > > > Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> > > > > The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
> > > > > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> > > > > The enhanced flv documentation contributors include
> > > > > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> > > > > So this should be support by ffmpeg too.
> > > > >
> > > > > v8:
> > > > >     Support vp9 codec according to enhanced flv.
> > > > >     Support PacketTypeCodedFrames type for hevc in flv.
> > > > > v9:
> > > > >     Add dependency codec object files for flvenc in Makefile.
> > > > >     Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
> > > > >
> > > > > v10:
> > > > >     modify first patch comment like the others before commit.
> > > > >     exheader mode should only happened in video stream this patchset.
> > > > >
> > > > > Steven Liu (6):
> > > > >   avformat/flvenc: support mux hevc in enhanced flv
> > > > >   avformat/flvdec: support demux hevc in enhanced flv
> > > > >   avformat/flvenc: support mux av1 in enhanced flv
> > > > >   avformat/flvdec: support demux av1 in enhanced flv
> > > > >   avformat/flvenc: support mux vp9 in enhanced flv
> > > > >   avformat/flvdec: support demux vp9 in enhanced flv
> > > > >
> > > > >  libavformat/Makefile |  2 +-
> > > > >  libavformat/flv.h    | 15 +++++++++
> > > > >  libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
> > > > >  libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
> > > > >  4 files changed, 130 insertions(+), 18 deletions(-)
> > > > >
> > > >
> > > > This version works for me. Thanks for this work!
> > > >
> > > > Tested-by: Neal Gompa <ngompa13@gmail.com>
> > > > Reviewed-by: Neal Gompa <ngompa13@gmail.com>
> > > >
> > >
> > > Is this patch set going to get pushed to master anytime soon?
> >
> > Hi Neal,
> >
> >     Do you agree move the enhanced flv support into experimental flags?
> >
>
> I don't think we should mark it experimental. Aside from the fact that
> other implementations haven't done that, it's in production now with
> YouTube.
>

Just wanted to add that v11 also worked for me (successfully tested
pushing RTMP 720p and 1080p AV1 from a live source, tried VP9 but
YouTube doesn't seem to support it as ingest). I can also confirm what
Steven reported that YouTube will output VP9 or AVC given AV1 RTMP
(from the "Stats for nerds" menu).

Great work!

Tested-by: Tristan Matthews <tmatth@videolan.org>
Reviewed-by: Tristan Matthews <tmatth@videolan.org>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-06-01  9:29                     ` Jean-Baptiste Kempf
@ 2023-07-17 11:37                       ` Jean-Baptiste Kempf
  2023-07-17 14:07                         ` Steven Liu
  0 siblings, 1 reply; 72+ messages in thread
From: Jean-Baptiste Kempf @ 2023-07-17 11:37 UTC (permalink / raw)
  To: Jean-Baptiste Kempf, ffmpeg-devel, Steven Liu; +Cc: Steven Liu

Please merge.

On Thu, 1 Jun 2023, at 12:29, Jean-Baptiste Kempf wrote:
> Hello,
>
> On Thu, 1 Jun 2023, at 02:02, Steven Liu wrote:
>> Neal Gompa <ngompa13@gmail.com> 于2023年5月31日周三 13:47写道:
>>>
>>> On Mon, May 15, 2023 at 10:41 PM Neal Gompa <ngompa13@gmail.com> wrote:
>>> >
>>> > On Mon, May 15, 2023 at 4:32 AM Steven Liu <lq@chinaffmpeg.org> wrote:
>>> > >
>>> > > Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
>>> > > The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js.
>>> > > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
>>> > > The enhanced flv documentation contributors include
>>> > > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
>>> > > So this should be support by ffmpeg too.
>>> > >
>>> > > v8:
>>> > >     Support vp9 codec according to enhanced flv.
>>> > >     Support PacketTypeCodedFrames type for hevc in flv.
>>> > > v9:
>>> > >     Add dependency codec object files for flvenc in Makefile.
>>> > >     Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
>>> > >
>>> > > v10:
>>> > >     modify first patch comment like the others before commit.
>>> > >     exheader mode should only happened in video stream this patchset.
>>> > >
>>> > > Steven Liu (6):
>>> > >   avformat/flvenc: support mux hevc in enhanced flv
>>> > >   avformat/flvdec: support demux hevc in enhanced flv
>>> > >   avformat/flvenc: support mux av1 in enhanced flv
>>> > >   avformat/flvdec: support demux av1 in enhanced flv
>>> > >   avformat/flvenc: support mux vp9 in enhanced flv
>>> > >   avformat/flvdec: support demux vp9 in enhanced flv
>>> > >
>>> > >  libavformat/Makefile |  2 +-
>>> > >  libavformat/flv.h    | 15 +++++++++
>>> > >  libavformat/flvdec.c | 73 +++++++++++++++++++++++++++++++++++++++-----
>>> > >  libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
>>> > >  4 files changed, 130 insertions(+), 18 deletions(-)
>>> > >
>>> >
>>> > This version works for me. Thanks for this work!
>>> >
>>> > Tested-by: Neal Gompa <ngompa13@gmail.com>
>>> > Reviewed-by: Neal Gompa <ngompa13@gmail.com>
>>> >
>>>
>>> Is this patch set going to get pushed to master anytime soon?
>>
>> Hi Neal,
>>
>> Waiting for j-b check about the Enhanced-FLV status, i cannot sure if
>> this patch can be pushed now.
>
> I've just re-asked what is the final status of the spec.
>
> If you cannot wait, use experimental flags.
>
> jb
> -- 
> Jean-Baptiste Kempf -  President
> +33 672 704 734
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg
  2023-07-17 11:37                       ` Jean-Baptiste Kempf
@ 2023-07-17 14:07                         ` Steven Liu
  0 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-07-17 14:07 UTC (permalink / raw)
  To: Jean-Baptiste Kempf; +Cc: Steven Liu, ffmpeg-devel

Jean-Baptiste Kempf <jb@videolan.org>于2023年7月17日 周一19:37写道:

> Please merge.

will apply

>
>
> On Thu, 1 Jun 2023, at 12:29, Jean-Baptiste Kempf wrote:
> > Hello,
> >
> > On Thu, 1 Jun 2023, at 02:02, Steven Liu wrote:
> >> Neal Gompa <ngompa13@gmail.com> 于2023年5月31日周三 13:47写道:
> >>>
> >>> On Mon, May 15, 2023 at 10:41 PM Neal Gompa <ngompa13@gmail.com>
> wrote:
> >>> >
> >>> > On Mon, May 15, 2023 at 4:32 AM Steven Liu <lq@chinaffmpeg.org>
> wrote:
> >>> > >
> >>> > > Reference file:
> https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> >>> > > The Enhanced flv has been supported by OBS, Simple Realtime
> Server, mpegts.js.
> >>> > > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> >>> > > The enhanced flv documentation contributors include
> >>> > > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> >>> > > So this should be support by ffmpeg too.
> >>> > >
> >>> > > v8:
> >>> > >     Support vp9 codec according to enhanced flv.
> >>> > >     Support PacketTypeCodedFrames type for hevc in flv.
> >>> > > v9:
> >>> > >     Add dependency codec object files for flvenc in Makefile.
> >>> > >     Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
> >>> > >
> >>> > > v10:
> >>> > >     modify first patch comment like the others before commit.
> >>> > >     exheader mode should only happened in video stream this
> patchset.
> >>> > >
> >>> > > Steven Liu (6):
> >>> > >   avformat/flvenc: support mux hevc in enhanced flv
> >>> > >   avformat/flvdec: support demux hevc in enhanced flv
> >>> > >   avformat/flvenc: support mux av1 in enhanced flv
> >>> > >   avformat/flvdec: support demux av1 in enhanced flv
> >>> > >   avformat/flvenc: support mux vp9 in enhanced flv
> >>> > >   avformat/flvdec: support demux vp9 in enhanced flv
> >>> > >
> >>> > >  libavformat/Makefile |  2 +-
> >>> > >  libavformat/flv.h    | 15 +++++++++
> >>> > >  libavformat/flvdec.c | 73
> +++++++++++++++++++++++++++++++++++++++-----
> >>> > >  libavformat/flvenc.c | 58 +++++++++++++++++++++++++++++------
> >>> > >  4 files changed, 130 insertions(+), 18 deletions(-)
> >>> > >
> >>> >
> >>> > This version works for me. Thanks for this work!
> >>> >
> >>> > Tested-by: Neal Gompa <ngompa13@gmail.com>
> >>> > Reviewed-by: Neal Gompa <ngompa13@gmail.com>
> >>> >
> >>>
> >>> Is this patch set going to get pushed to master anytime soon?
> >>
> >> Hi Neal,
> >>
> >> Waiting for j-b check about the Enhanced-FLV status, i cannot sure if
> >> this patch can be pushed now.
> >
> > I've just re-asked what is the final status of the spec.
> >
> > If you cannot wait, use experimental flags.
> >
> > jb
> > --
> > Jean-Baptiste Kempf -  President
> > +33 672 704 734
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
> --
> Jean-Baptiste Kempf -  President
> +33 672 704 734
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 2/6] avformat/flvdec: support demux hevc in enhanced flv
  2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 2/6] avformat/flvdec: support demux hevc in enhanced flv Steven Liu
@ 2023-07-26 23:27   ` Michael Niedermayer
  2023-07-27  2:43     ` Steven Liu
  0 siblings, 1 reply; 72+ messages in thread
From: Michael Niedermayer @ 2023-07-26 23:27 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 2201 bytes --]

On Thu, Apr 13, 2023 at 05:44:37PM +0800, Steven Liu wrote:
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  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;

pb->buf_ptr is in general not supposed to be directly accessed

In this case here it segfaults

READ of size 1 at 0x6100000003b7 thread T0
    #0 0x7f928d in flv_same_video_codec ffmpeg/libavformat/flvdec.c:317:29
    #1 0x7f928d in flv_read_packet ffmpeg/libavformat/flvdec.c:1177
    #2 0x6ff32f in ff_read_packet ffmpeg/libavformat/demux.c:575:15
    #3 0x70a2fd in read_frame_internal ffmpeg/libavformat/demux.c:1263:15
    #4 0x71d158 in avformat_find_stream_info ffmpeg/libavformat/demux.c:2634:15
    #5 0x4c821b in LLVMFuzzerTestOneInput ffmpeg/tools/target_dem_fuzzer.c:206:11

can you remove pb->buf_ptr use ?
I can fix it too but i have no testcase and fate doesnt cover this so my fix would
be untested ...

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

* Re: [FFmpeg-devel] [PATCH v8 2/6] avformat/flvdec: support demux hevc in enhanced flv
  2023-07-26 23:27   ` Michael Niedermayer
@ 2023-07-27  2:43     ` Steven Liu
  0 siblings, 0 replies; 72+ messages in thread
From: Steven Liu @ 2023-07-27  2:43 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Michael Niedermayer <michael@niedermayer.cc> 于2023年7月27日周四 07:27写道:
Hi Michael,
>
> On Thu, Apr 13, 2023 at 05:44:37PM +0800, Steven Liu wrote:
> > Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > ---
> >  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;
>
> pb->buf_ptr is in general not supposed to be directly accessed
>
> In this case here it segfaults
>
> READ of size 1 at 0x6100000003b7 thread T0
>     #0 0x7f928d in flv_same_video_codec ffmpeg/libavformat/flvdec.c:317:29
>     #1 0x7f928d in flv_read_packet ffmpeg/libavformat/flvdec.c:1177
>     #2 0x6ff32f in ff_read_packet ffmpeg/libavformat/demux.c:575:15
>     #3 0x70a2fd in read_frame_internal ffmpeg/libavformat/demux.c:1263:15
>     #4 0x71d158 in avformat_find_stream_info ffmpeg/libavformat/demux.c:2634:15
>     #5 0x4c821b in LLVMFuzzerTestOneInput ffmpeg/tools/target_dem_fuzzer.c:206:11
>
> can you remove pb->buf_ptr use ?
> I can fix it too but i have no testcase and fate doesnt cover this so my fix would
> be untested ...
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20230727023744.20984-1-lq@chinaffmpeg.org/
Can this patch fix it?
>
> thx
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Democracy is the form of government in which you can choose your dictator
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Thanks
Steven
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 72+ messages in thread

end of thread, other threads:[~2023-07-27  2:43 UTC | newest]

Thread overview: 72+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13  9:44 [FFmpeg-devel] [PATCH v8 0/6] Suppor hevc av1 and vp9 codec in enhanced flv Steven Liu
2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 1/6] avformat/flvenc: Add support for HEVC over flv in muxer Steven Liu
2023-05-11 17:58   ` Andreas Rheinhardt
2023-05-12  3:58     ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Steven Liu
2023-05-12  3:58       ` [FFmpeg-devel] [PATCH v9 1/6] avformat/flvenc: Add support for HEVC over flv in muxer Steven Liu
2023-05-12  3:58       ` [FFmpeg-devel] [PATCH v9 2/6] avformat/flvdec: support demux hevc in enhanced flv Steven Liu
2023-05-12  3:58       ` [FFmpeg-devel] [PATCH v9 3/6] avformat/flvenc: support mux av1 " Steven Liu
2023-05-12  3:58       ` [FFmpeg-devel] [PATCH v9 4/6] avformat/flvdec: support demux " Steven Liu
2023-05-12  3:59       ` [FFmpeg-devel] [PATCH v9 5/6] avformat/flvenc: support mux vp9 " Steven Liu
2023-05-12  3:59       ` [FFmpeg-devel] [PATCH v9 6/6] avformat/flvenc: support demux " Steven Liu
2023-05-12 10:31       ` [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg Timo Rothenpieler
2023-05-12 10:47         ` Steven Liu
2023-05-12 11:06           ` Timo Rothenpieler
2023-05-12 10:47       ` Vibhoothi
2023-05-12 11:59         ` Steven Liu
2023-05-13  2:40           ` Neal Gompa
2023-05-15  8:31             ` [FFmpeg-devel] [PATCH v10 " Steven Liu
2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 1/6] avformat/flvenc: support mux hevc in enhanced flv Steven Liu
2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 2/6] avformat/flvdec: support demux " Steven Liu
2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 3/6] avformat/flvenc: support mux av1 " Steven Liu
2023-06-02  4:49                 ` Tristan Matthews
2023-06-02  7:19                   ` Steven Liu
2023-06-02  7:31                   ` [FFmpeg-devel] [PATCH v11 0/6] Support enhanced flv in FFmpeg Steven Liu
2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 1/6] avformat/flvenc: support mux hevc in enhanced flv Steven Liu
2023-06-02 11:08                       ` Lance Wang
2023-06-02 11:28                         ` Steven Liu
2023-06-02 15:52                           ` Lance Wang
2023-06-02 23:44                             ` Steven Liu
2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 2/6] avformat/flvdec: support demux " Steven Liu
2023-06-02 11:15                       ` Lance Wang
2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 3/6] avformat/flvenc: support mux av1 " Steven Liu
2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 4/6] avformat/flvdec: support demux " Steven Liu
2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 5/6] avformat/flvenc: support mux vp9 " Steven Liu
2023-06-02  7:31                     ` [FFmpeg-devel] [PATCH v11 6/6] avformat/flvdec: support demux " Steven Liu
2023-05-15  8:31               ` [FFmpeg-devel] [PATCH v10 4/6] avformat/flvdec: support demux av1 " Steven Liu
2023-05-15  8:32               ` [FFmpeg-devel] [PATCH v10 5/6] avformat/flvenc: support mux vp9 " Steven Liu
2023-05-15  8:32               ` [FFmpeg-devel] [PATCH v10 6/6] avformat/flvdec: support demux " Steven Liu
2023-05-15 20:41               ` [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg Neal Gompa
2023-05-31  5:47                 ` Neal Gompa
2023-06-01  0:02                   ` Steven Liu
2023-06-01  5:03                     ` Tristan Matthews
2023-06-01  6:07                       ` Steven Liu
2023-06-01 17:57                         ` Tristan Matthews
2023-06-02  1:37                           ` Steven Liu
2023-06-01  9:29                     ` Jean-Baptiste Kempf
2023-07-17 11:37                       ` Jean-Baptiste Kempf
2023-07-17 14:07                         ` Steven Liu
2023-06-06  6:42                   ` Steven Liu
2023-06-08  0:02                     ` Neal Gompa
2023-06-09 22:46                       ` Tristan Matthews
2023-05-15  8:37             ` [FFmpeg-devel] [PATCH v9 " Steven Liu
2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 2/6] avformat/flvdec: support demux hevc in enhanced flv Steven Liu
2023-07-26 23:27   ` Michael Niedermayer
2023-07-27  2:43     ` Steven Liu
2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 3/6] avformat/flvenc: support mux av1 " Steven Liu
2023-05-08 23:07   ` Neal Gompa
2023-05-09  1:55     ` Steven Liu
2023-05-09  2:41       ` Neal Gompa
2023-05-09  4:14         ` Gyan Doshi
2023-05-09 10:35           ` Neal Gompa
2023-05-09 10:48             ` Gyan Doshi
2023-05-10 11:05               ` Neal Gompa
2023-05-10 11:13                 ` Steven Liu
2023-05-11  1:31                   ` Neal Gompa
2023-05-11  1:40                     ` Steven Liu
2023-05-11 16:21                       ` Neal Gompa
2023-05-11 16:26                         ` Jean-Baptiste Kempf
2023-05-12  3:35                           ` Neal Gompa
2023-05-12  5:23                             ` Jean-Baptiste Kempf
2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 4/6] avformat/flvdec: support demux " Steven Liu
2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 5/6] avformat/flvenc: support mux vp9 " Steven Liu
2023-04-13  9:44 ` [FFmpeg-devel] [PATCH v8 6/6] avformat/flvenc: support demux " Steven Liu

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git