From 6c478453a8c0b94bd0ca34e303f95af74f829c0c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Cr=C3=AAte?= Date: Wed, 25 Jul 2018 18:37:48 -0400 Subject: [PATCH] qtmux: Implement muxing of AV1 into MP4 files According to https://aomediacodec.github.io/av1-isobmff/ --- gst/isomp4/gstqtmux.c | 29 +++++++++++++++++++++++++++++ gst/isomp4/gstqtmuxmap.c | 6 ++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/gst/isomp4/gstqtmux.c b/gst/isomp4/gstqtmux.c index be0fb17..8aaddf0 100644 --- a/gst/isomp4/gstqtmux.c +++ b/gst/isomp4/gstqtmux.c @@ -5760,6 +5760,35 @@ gst_qt_mux_video_sink_set_caps (GstQTPad * qtpad, GstCaps * caps) } else if (strcmp (mimetype, "video/x-cineform") == 0) { entry.fourcc = FOURCC_cfhd; sync = FALSE; + } else if (strcmp (mimetype, "video/x-av1") == 0) { + gint presentation_delay; + guint8 presentation_delay_byte = 0; + GstBuffer *av1_codec_data; + + if (gst_structure_get_int (structure, "presentation-delay", + &presentation_delay)) { + presentation_delay_byte = 1 << 5; + presentation_delay_byte |= MAX (0xF, presentation_delay & 0xF); + } + + + av1_codec_data = gst_buffer_new_allocate (NULL, 5, NULL); + /* Fill version and 3 bytes of flags to 0 */ + gst_buffer_memset (av1_codec_data, 0, 0, 4); + gst_buffer_fill (av1_codec_data, 4, &presentation_delay_byte, 1); + if (codec_data) + av1_codec_data = gst_buffer_append (av1_codec_data, + gst_buffer_ref ((GstBuffer *) codec_data)); + + entry.fourcc = FOURCC_av01; + + ext_atom = build_btrt_extension (0, qtpad->avg_bitrate, qtpad->max_bitrate); + if (ext_atom != NULL) + ext_atom_list = g_list_prepend (ext_atom_list, ext_atom); + ext_atom = build_codec_data_extension (FOURCC_av1C, av1_codec_data); + if (ext_atom != NULL) + ext_atom_list = g_list_prepend (ext_atom_list, ext_atom); + gst_buffer_unref (av1_codec_data); } if (!entry.fourcc) diff --git a/gst/isomp4/gstqtmuxmap.c b/gst/isomp4/gstqtmuxmap.c index fc59ed2..6735f9d 100644 --- a/gst/isomp4/gstqtmuxmap.c +++ b/gst/isomp4/gstqtmuxmap.c @@ -204,7 +204,8 @@ GstQTMuxFormatProp gst_qt_mux_format_list[] = { "video/x-vp9, " COMMON_VIDEO_CAPS "; " "video/x-dirac, " - COMMON_VIDEO_CAPS "; " "video/x-qt-part, " COMMON_VIDEO_CAPS), + COMMON_VIDEO_CAPS "; " "video/x-qt-part, " COMMON_VIDEO_CAPS "; " + "video/x-av1, " COMMON_VIDEO_CAPS), GST_STATIC_CAPS (PCM_CAPS_FULL "; " PCM_CAPS_UNPOSITIONED " ; " MP123_CAPS " ; " @@ -227,7 +228,8 @@ GstQTMuxFormatProp gst_qt_mux_format_list[] = { "GstMP4Mux", GST_STATIC_CAPS ("video/quicktime, variant = (string) iso"), GST_STATIC_CAPS (MPEG4V_CAPS "; " H264_CAPS ";" H265_CAPS ";" - "video/x-mp4-part," COMMON_VIDEO_CAPS), + "video/x-mp4-part," COMMON_VIDEO_CAPS "; " + "video/x-av1, " COMMON_VIDEO_CAPS), GST_STATIC_CAPS (MP123_CAPS "; " AAC_CAPS " ; " AC3_CAPS " ; " ALAC_CAPS " ; " OPUS_CAPS), GST_STATIC_CAPS (TEXT_UTF8), -- 2.7.4