* [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 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 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 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 ` 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
* 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
* 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 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
* [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
* 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
* [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
* [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 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 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 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 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 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 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