fmp4: Add support for VP8

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1086>
This commit is contained in:
Sebastian Dröge 2023-02-02 15:02:44 +02:00
parent 40cada5f69
commit 1029669427
2 changed files with 17 additions and 5 deletions

View file

@ -629,7 +629,7 @@ fn write_tkhd(
// Width/height // Width/height
match s.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" => {
let width = s.get::<i32>("width").context("video caps without width")? as u32; let width = s.get::<i32>("width").context("video caps without width")? as u32;
let height = s let height = s
.get::<i32>("height") .get::<i32>("height")
@ -739,7 +739,7 @@ fn write_hdlr(
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
let (handler_type, name) = match s.name() { 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()) (b"vide", b"VideoHandler\0".as_slice())
} }
"audio/mpeg" | "audio/x-opus" | "audio/x-alaw" | "audio/x-mulaw" | "audio/x-adpcm" => { "audio/mpeg" | "audio/x-opus" | "audio/x-alaw" | "audio/x-mulaw" | "audio/x-adpcm" => {
@ -769,7 +769,7 @@ fn write_minf(
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
match s.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" => {
// Flags are always 1 for unspecified reasons // Flags are always 1 for unspecified reasons
write_full_box(v, b"vmhd", FULL_BOX_VERSION_0, 1, |v| write_vmhd(v, cfg))? write_full_box(v, b"vmhd", FULL_BOX_VERSION_0, 1, |v| write_vmhd(v, cfg))?
} }
@ -880,7 +880,7 @@ fn write_stsd(
let s = stream.caps.structure(0).unwrap(); let s = stream.caps.structure(0).unwrap();
match s.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" => {
write_visual_sample_entry(v, cfg, stream)? write_visual_sample_entry(v, cfg, stream)?
} }
"audio/mpeg" | "audio/x-opus" | "audio/x-alaw" | "audio/x-mulaw" | "audio/x-adpcm" => { "audio/mpeg" | "audio/x-opus" | "audio/x-alaw" | "audio/x-mulaw" | "audio/x-adpcm" => {
@ -933,6 +933,7 @@ fn write_visual_sample_entry(
} }
} }
"image/jpeg" => b"jpeg", "image/jpeg" => b"jpeg",
"video/x-vp8" => b"vp08",
"video/x-vp9" => b"vp09", "video/x-vp9" => b"vp09",
_ => unreachable!(), _ => unreachable!(),
}; };
@ -1065,7 +1066,7 @@ fn write_visual_sample_entry(
Ok(()) Ok(())
})?; })?;
} }
"image/jpeg" => { "video/x-vp8" | "image/jpeg" => {
// Nothing to do here // Nothing to do here
} }
_ => unreachable!(), _ => unreachable!(),

View file

@ -2410,6 +2410,9 @@ impl FMP4Mux {
} }
delta_frames = DeltaFrames::Bidirectional; delta_frames = DeltaFrames::Bidirectional;
} }
"video/x-vp8" => {
delta_frames = DeltaFrames::PredictiveOnly;
}
"video/x-vp9" => { "video/x-vp9" => {
if !s.has_field_with_type("colorimetry", str::static_type()) { if !s.has_field_with_type("colorimetry", str::static_type()) {
gst::error!(CAT, obj: pad, "Received caps without colorimetry"); gst::error!(CAT, obj: pad, "Received caps without colorimetry");
@ -3266,6 +3269,10 @@ impl ElementImpl for ISOFMP4Mux {
.field("width", gst::IntRange::new(1, u16::MAX as i32)) .field("width", gst::IntRange::new(1, u16::MAX as i32))
.field("height", gst::IntRange::new(1, u16::MAX as i32)) .field("height", gst::IntRange::new(1, u16::MAX as i32))
.build(), .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") gst::Structure::builder("video/x-vp9")
.field("profile", gst::List::new(["0", "1", "2", "3"])) .field("profile", gst::List::new(["0", "1", "2", "3"]))
.field("chroma-format", gst::List::new(["4:2:0", "4:2:2", "4:4:4"])) .field("chroma-format", gst::List::new(["4:2:0", "4:2:2", "4:4:4"]))
@ -3445,6 +3452,10 @@ impl ElementImpl for DASHMP4Mux {
.field("width", gst::IntRange::<i32>::new(1, u16::MAX as i32)) .field("width", gst::IntRange::<i32>::new(1, u16::MAX as i32))
.field("height", gst::IntRange::<i32>::new(1, u16::MAX as i32)) .field("height", gst::IntRange::<i32>::new(1, u16::MAX as i32))
.build(), .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") gst::Structure::builder("video/x-vp9")
.field("profile", gst::List::new(["0", "1", "2", "3"])) .field("profile", gst::List::new(["0", "1", "2", "3"]))
.field("chroma-format", gst::List::new(["4:2:0", "4:2:2", "4:4:4"])) .field("chroma-format", gst::List::new(["4:2:0", "4:2:2", "4:4:4"]))