From 40cada5f6985648c87a7e7910ef8e4a74e0d1e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 2 Feb 2023 15:02:39 +0200 Subject: [PATCH] mp4: Add support for VP8 Part-of: --- mux/mp4/src/mp4mux/boxes.rs | 11 ++++++----- mux/mp4/src/mp4mux/imp.rs | 7 +++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/mux/mp4/src/mp4mux/boxes.rs b/mux/mp4/src/mp4mux/boxes.rs index 9db658ee..505d2a08 100644 --- a/mux/mp4/src/mp4mux/boxes.rs +++ b/mux/mp4/src/mp4mux/boxes.rs @@ -407,7 +407,7 @@ fn write_tkhd( // Width/height match s.name() { - "video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => { + "video/x-h264" | "video/x-h265" | "video/x-vp8" | "video/x-vp9" | "image/jpeg" => { let width = s.get::("width").context("video caps without width")? as u32; let height = s .get::("height") @@ -508,7 +508,7 @@ fn write_hdlr( let s = stream.caps.structure(0).unwrap(); let (handler_type, name) = match s.name() { - "video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => { + "video/x-h264" | "video/x-h265" | "video/x-vp8" | "video/x-vp9" | "image/jpeg" => { (b"vide", b"VideoHandler\0".as_slice()) } "audio/mpeg" | "audio/x-opus" | "audio/x-alaw" | "audio/x-mulaw" | "audio/x-adpcm" => { @@ -538,7 +538,7 @@ fn write_minf( let s = stream.caps.structure(0).unwrap(); match s.name() { - "video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => { + "video/x-h264" | "video/x-h265" | "video/x-vp8" | "video/x-vp9" | "image/jpeg" => { // Flags are always 1 for unspecified reasons write_full_box(v, b"vmhd", FULL_BOX_VERSION_0, 1, |v| write_vmhd(v, header))? } @@ -697,7 +697,7 @@ fn write_stsd( let s = stream.caps.structure(0).unwrap(); match s.name() { - "video/x-h264" | "video/x-h265" | "video/x-vp9" | "image/jpeg" => { + "video/x-h264" | "video/x-h265" | "video/x-vp8" | "video/x-vp9" | "image/jpeg" => { write_visual_sample_entry(v, header, stream)? } "audio/mpeg" | "audio/x-opus" | "audio/x-alaw" | "audio/x-mulaw" | "audio/x-adpcm" => { @@ -750,6 +750,7 @@ fn write_visual_sample_entry( } } "image/jpeg" => b"jpeg", + "video/x-vp8" => b"vp08", "video/x-vp9" => b"vp09", _ => unreachable!(), }; @@ -882,7 +883,7 @@ fn write_visual_sample_entry( Ok(()) })?; } - "image/jpeg" => { + "video/x-vp8" | "image/jpeg" => { // Nothing to do here } _ => unreachable!(), diff --git a/mux/mp4/src/mp4mux/imp.rs b/mux/mp4/src/mp4mux/imp.rs index 7b88845f..91c8ebcc 100644 --- a/mux/mp4/src/mp4mux/imp.rs +++ b/mux/mp4/src/mp4mux/imp.rs @@ -881,6 +881,9 @@ impl MP4Mux { } delta_frames = super::DeltaFrames::Bidirectional; } + "video/x-vp8" => { + delta_frames = super::DeltaFrames::PredictiveOnly; + } "video/x-vp9" => { if !s.has_field_with_type("colorimetry", str::static_type()) { gst::error!(CAT, obj: pad, "Received caps without colorimetry"); @@ -1479,6 +1482,10 @@ impl ElementImpl for ISOMP4Mux { .field("width", gst::IntRange::new(1, u16::MAX as i32)) .field("height", gst::IntRange::new(1, u16::MAX as i32)) .build(), + gst::Structure::builder("video/x-vp8") + .field("width", gst::IntRange::new(1, u16::MAX as i32)) + .field("height", gst::IntRange::new(1, u16::MAX as i32)) + .build(), gst::Structure::builder("video/x-vp9") .field("profile", gst::List::new(["0", "1", "2", "3"])) .field("chroma-format", gst::List::new(["4:2:0", "4:2:2", "4:4:4"]))