From 3592bf772686867066c68754680d551e2f0a0f80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 11 Sep 2021 09:24:35 +0300 Subject: [PATCH] matroska: Add support for muxing/demuxing ffv1 Previously only demuxing when stored via the RIFF/AVI mapping was supported. See https://github.com/FFmpeg/FFV1/blob/master/ffv1.md#matroska-file-format Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/923 Part-of: --- docs/gst_plugins_cache.json | 2 +- gst/matroska/matroska-demux.c | 13 +++++++++++++ gst/matroska/matroska-ids.h | 1 + gst/matroska/matroska-mux.c | 9 ++++++++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/gst_plugins_cache.json b/docs/gst_plugins_cache.json index 5378baf..96b6ca3 100644 --- a/docs/gst_plugins_cache.json +++ b/docs/gst_plugins_cache.json @@ -9114,7 +9114,7 @@ "presence": "request" }, "video_%%u": { - "caps": "video/mpeg:\n mpegversion: { (int)1, (int)2, (int)4 }\n systemstream: false\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-h264:\n stream-format: { (string)avc, (string)avc3 }\n alignment: au\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-h265:\n stream-format: { (string)hvc1, (string)hev1 }\n alignment: au\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-divx:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-huffyuv:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-dv:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-h263:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-msmpeg:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nimage/jpeg:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-theora:\nvideo/x-dirac:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-pn-realvideo:\n rmversion: [ 1, 4 ]\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-vp8:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-vp9:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-raw:\n format: { YUY2, I420, YV12, UYVY, AYUV, GRAY8, BGR, RGB }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-prores:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-wmv:\n wmvversion: [ 1, 3 ]\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-av1:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n", + "caps": "video/mpeg:\n mpegversion: { (int)1, (int)2, (int)4 }\n systemstream: false\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-h264:\n stream-format: { (string)avc, (string)avc3 }\n alignment: au\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-h265:\n stream-format: { (string)hvc1, (string)hev1 }\n alignment: au\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-divx:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-huffyuv:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-dv:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-h263:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-msmpeg:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nimage/jpeg:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-theora:\nvideo/x-dirac:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-pn-realvideo:\n rmversion: [ 1, 4 ]\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-vp8:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-vp9:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-raw:\n format: { YUY2, I420, YV12, UYVY, AYUV, GRAY8, BGR, RGB }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-prores:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-wmv:\n wmvversion: [ 1, 3 ]\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-av1:\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\nvideo/x-ffv:\n ffversion: 1\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n", "direction": "sink", "presence": "request" } diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 75319bc..1eb429f 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -6623,6 +6623,19 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext * GST_WARNING ("No AV1 codec data found!"); } *codec_name = g_strdup_printf ("AOM AV1"); + } else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_FFV1)) { + caps = + gst_caps_new_simple ("video/x-ffv", "ffvversion", G_TYPE_INT, 1, NULL); + if (data) { + GstBuffer *priv; + + priv = gst_buffer_new_memdup (data, size); + gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, priv, NULL); + gst_buffer_unref (priv); + } else { + GST_WARNING ("No FFV1 codec data found!"); + } + *codec_name = g_strdup_printf ("FFMpeg v1"); } else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_PRORES)) { guint32 fourcc; const gchar *variant, *variant_descr = ""; diff --git a/gst/matroska/matroska-ids.h b/gst/matroska/matroska-ids.h index ba44f10..c4fc73c 100644 --- a/gst/matroska/matroska-ids.h +++ b/gst/matroska/matroska-ids.h @@ -380,6 +380,7 @@ #define GST_MATROSKA_CODEC_ID_VIDEO_AV1 "V_AV1" #define GST_MATROSKA_CODEC_ID_VIDEO_MPEGH_HEVC "V_MPEGH/ISO/HEVC" #define GST_MATROSKA_CODEC_ID_VIDEO_PRORES "V_PRORES" +#define GST_MATROSKA_CODEC_ID_VIDEO_FFV1 "V_FFV1" #define GST_MATROSKA_CODEC_ID_AUDIO_MPEG1_L1 "A_MPEG/L1" #define GST_MATROSKA_CODEC_ID_AUDIO_MPEG1_L2 "A_MPEG/L2" diff --git a/gst/matroska/matroska-mux.c b/gst/matroska/matroska-mux.c index 28970a6..c7a5adf 100644 --- a/gst/matroska/matroska-mux.c +++ b/gst/matroska/matroska-mux.c @@ -146,7 +146,8 @@ static GstStaticPadTemplate videosink_templ = "video/x-prores, " COMMON_VIDEO_CAPS "; " "video/x-wmv, " "wmvversion = (int) [ 1, 3 ], " COMMON_VIDEO_CAPS "; " - "video/x-av1, " COMMON_VIDEO_CAPS) + "video/x-av1, " COMMON_VIDEO_CAPS ";" + "video/x-ffv, ffversion = (int) 1, " COMMON_VIDEO_CAPS) ); #define COMMON_AUDIO_CAPS \ @@ -1344,6 +1345,12 @@ skip_details: if (codec_buf != NULL) gst_buffer_extract_dup (codec_buf, 0, gst_buffer_get_size (codec_buf), &context->codec_priv, &context->codec_priv_size); + } else if (!strcmp (mimetype, "video/x-ffv")) { + gst_matroska_mux_set_codec_id (context, GST_MATROSKA_CODEC_ID_VIDEO_FFV1); + gst_matroska_mux_free_codec_priv (context); + if (codec_buf != NULL) + gst_buffer_extract_dup (codec_buf, 0, gst_buffer_get_size (codec_buf), + &context->codec_priv, &context->codec_priv_size); } else if (!strcmp (mimetype, "video/mpeg")) { gint mpegversion; -- 2.7.4