[FFmpeg-devel] [PATCH] avformat/matroska: add support for VVC streams

James Almer jamrial at gmail.com
Sat Jan 11 17:48:45 EET 2025


As defined in https://github.com/ietf-wg-cellar/matroska-specification/blob/master/codec_specs.md#v_mpegiisovvc

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/matroska.c    |  1 +
 libavformat/matroskaenc.c | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroska.c b/libavformat/matroska.c
index d0ecfbeb6a..bbad9a7f54 100644
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -90,6 +90,7 @@ const CodecTags ff_mkv_codec_tags[]={
     {"V_MPEG4/ISO/SP"   , AV_CODEC_ID_MPEG4},
     {"V_MPEG4/ISO/AVC"  , AV_CODEC_ID_H264},
     {"V_MPEGH/ISO/HEVC" , AV_CODEC_ID_HEVC},
+    {"V_MPEGI/ISO/VVC"  , AV_CODEC_ID_VVC},
     {"V_MPEG4/MS/V3"    , AV_CODEC_ID_MSMPEG4V3},
     {"V_PRORES"         , AV_CODEC_ID_PRORES},
     {"V_REAL/RV10"      , AV_CODEC_ID_RV10},
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 16f48e7864..f98e2971f8 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -39,6 +39,7 @@
 #include "riff.h"
 #include "version.h"
 #include "vorbiscomment.h"
+#include "vvc.h"
 #include "wv.h"
 
 #include "libavutil/avstring.h"
@@ -1141,6 +1142,9 @@ static int mkv_assemble_native_codecprivate(AVFormatContext *s, AVIOContext *dyn
     case AV_CODEC_ID_HEVC:
         return ff_isom_write_hvcc(dyn_cp, extradata,
                                   extradata_size, 0, s);
+    case AV_CODEC_ID_VVC:
+        return ff_isom_write_vvcc(dyn_cp, extradata,
+                                  extradata_size, 0);
     case AV_CODEC_ID_ALAC:
         if (extradata_size < 36) {
             av_log(s, AV_LOG_ERROR,
@@ -3441,8 +3445,10 @@ static int mkv_init(struct AVFormatContext *s)
             break;
         case AV_CODEC_ID_H264:
         case AV_CODEC_ID_HEVC:
-            if ((par->codec_id == AV_CODEC_ID_H264 && par->extradata_size > 0 ||
-                 par->codec_id == AV_CODEC_ID_HEVC && par->extradata_size > 6) &&
+        case AV_CODEC_ID_VVC:
+            if (((par->codec_id == AV_CODEC_ID_H264 && par->extradata_size > 0) ||
+                 (par->codec_id == AV_CODEC_ID_HEVC && par->extradata_size > 6) ||
+                 (par->codec_id == AV_CODEC_ID_VVC  && par->extradata_size > 6)) &&
                 (AV_RB24(par->extradata) == 1 || AV_RB32(par->extradata) == 1))
                 track->reformat = mkv_reformat_h2645;
             break;
-- 
2.47.1



More information about the ffmpeg-devel mailing list