[FFmpeg-devel] [PATCH v7 7/9] avformat: add h266/vvc muxer

Nuo Mi nuomi2021 at gmail.com
Mon Mar 8 16:05:51 EET 2021


---
 libavformat/Makefile     |  1 +
 libavformat/allformats.c |  1 +
 libavformat/rawenc.c     | 25 +++++++++++++++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index af6428541d..d5aa0cc843 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -568,6 +568,7 @@ OBJS-$(CONFIG_VPK_DEMUXER)               += vpk.o
 OBJS-$(CONFIG_VPLAYER_DEMUXER)           += vplayerdec.o subtitles.o
 OBJS-$(CONFIG_VQF_DEMUXER)               += vqf.o
 OBJS-$(CONFIG_VVC_DEMUXER)               += vvcdec.o rawdec.o
+OBJS-$(CONFIG_VVC_MUXER)                 += rawenc.o
 OBJS-$(CONFIG_W64_DEMUXER)               += wavdec.o w64.o pcm.o
 OBJS-$(CONFIG_W64_MUXER)                 += wavenc.o w64.o
 OBJS-$(CONFIG_WAV_DEMUXER)               += wavdec.o pcm.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1543d0d7ca..00b7c60dad 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -467,6 +467,7 @@ extern AVInputFormat  ff_vpk_demuxer;
 extern AVInputFormat  ff_vplayer_demuxer;
 extern AVInputFormat  ff_vqf_demuxer;
 extern AVInputFormat  ff_vvc_demuxer;
+extern AVOutputFormat ff_vvc_muxer;
 extern AVInputFormat  ff_w64_demuxer;
 extern AVOutputFormat ff_w64_muxer;
 extern AVInputFormat  ff_wav_demuxer;
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index 32704f9bfd..b4e24c3e26 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -372,6 +372,31 @@ AVOutputFormat ff_hevc_muxer = {
 };
 #endif
 
+#if CONFIG_VVC_MUXER
+static int vvc_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
+{
+    if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 &&
+                          AV_RB24(pkt->data) != 0x000001) {
+        //TODO: fixed this after vvc codec defined in http://mp4ra.org/#/codecs
+        av_log(s, AV_LOG_ERROR, "vvc: mp4 to annexb is not supported\n");
+        return AVERROR_PATCHWELCOME;
+    }
+    return 1;
+}
+
+AVOutputFormat ff_vvc_muxer = {
+    .name              = "vvc",
+    .long_name         = NULL_IF_CONFIG_SMALL("raw VVC video"),
+    .extensions        = "vvc,h266,266",
+    .audio_codec       = AV_CODEC_ID_NONE,
+    .video_codec       = AV_CODEC_ID_VVC,
+    .write_header      = force_one_stream,
+    .write_packet      = ff_raw_write_packet,
+    .check_bitstream   = vvc_check_bitstream,
+    .flags             = AVFMT_NOTIMESTAMPS,
+};
+#endif
+
 #if CONFIG_M4V_MUXER
 AVOutputFormat ff_m4v_muxer = {
     .name              = "m4v",
-- 
2.25.1



More information about the ffmpeg-devel mailing list