From 4313c32d82018a6ed89bba2ee2af680f334abdd5 Mon Sep 17 00:00:00 2001 From: Takeru Ohta Date: Fri, 6 Dec 2024 14:04:33 +0900 Subject: [PATCH] =?UTF-8?q?`Mp4MediaStream`=20=E3=81=AE=E5=AF=BE=E5=BF=9C?= =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=87=E3=83=83=E3=82=AF=E3=81=AB=20VP9=20?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 2 ++ packages/mp4-media-stream/README.md | 1 + packages/mp4-media-stream/wasm/src/mp4.rs | 20 +++++++++++++++++++- packages/mp4-media-stream/wasm/src/player.rs | 4 ++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index eb229120..cb62c440 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,8 @@ ## develop +- [ADD] `Mp4MediaStream` の対応コーデックに VP9 を追加する + - @sile - [ADD] `Mp4MediaStream` の対応コーデックに VP8 を追加する - @sile - [ADD] `Mp4MediaStream` の対応コーデックに AAC を追加する diff --git a/packages/mp4-media-stream/README.md b/packages/mp4-media-stream/README.md index 66df35b0..ed8c009b 100644 --- a/packages/mp4-media-stream/README.md +++ b/packages/mp4-media-stream/README.md @@ -33,6 +33,7 @@ video.srcObject = stream - 映像: - H.264 - VP8 + - VP9 - 音声: - AAC - Opus diff --git a/packages/mp4-media-stream/wasm/src/mp4.rs b/packages/mp4-media-stream/wasm/src/mp4.rs index a6c25f5a..4ca941e8 100644 --- a/packages/mp4-media-stream/wasm/src/mp4.rs +++ b/packages/mp4-media-stream/wasm/src/mp4.rs @@ -6,7 +6,7 @@ use shiguredo_mp4::{ aux::SampleTableAccessor, boxes::{ Avc1Box, FtypBox, HdlrBox, IgnoredBox, MoovBox, Mp4aBox, OpusBox, SampleEntry, StblBox, - TrakBox, Vp08Box, + TrakBox, Vp08Box, Vp09Box, }, BaseBox, Decode, Either, Encode, }; @@ -47,6 +47,20 @@ impl VideoDecoderConfig { coded_height: b.visual.height, } } + + pub fn from_vp09_box(b: &Vp09Box) -> Self { + Self { + codec: format!( + "vp09.{:02}.{:02}.{:02}", + b.vpcc_box.profile, + b.vpcc_box.level, + b.vpcc_box.bit_depth.get() + ), + description: Vec::new(), + coded_width: b.visual.width, + coded_height: b.visual.height, + } + } } #[derive(Debug, Serialize)] @@ -121,6 +135,7 @@ impl Track { match sample_table.stbl_box().stsd_box.entries.first() { Some(SampleEntry::Avc1(_)) => (), Some(SampleEntry::Vp08(_)) => (), + Some(SampleEntry::Vp09(_)) => (), Some(SampleEntry::Opus(_)) => (), Some(SampleEntry::Mp4a(_)) => (), Some(b) => { @@ -214,6 +229,9 @@ impl Mp4 { SampleEntry::Vp08(b) => { video_configs.push(VideoDecoderConfig::from_vp08_box(b)); } + SampleEntry::Vp09(b) => { + video_configs.push(VideoDecoderConfig::from_vp09_box(b)); + } SampleEntry::Opus(b) => { audio_configs.push(AudioDecoderConfig::from_opus_box(b)); } diff --git a/packages/mp4-media-stream/wasm/src/player.rs b/packages/mp4-media-stream/wasm/src/player.rs index af09f4f4..3e103076 100644 --- a/packages/mp4-media-stream/wasm/src/player.rs +++ b/packages/mp4-media-stream/wasm/src/player.rs @@ -184,6 +184,10 @@ impl TrackPlayer { let config = VideoDecoderConfig::from_vp08_box(b); WasmApi::create_video_decoder(self.player_id, config).await } + SampleEntry::Vp09(b) => { + let config = VideoDecoderConfig::from_vp09_box(b); + WasmApi::create_video_decoder(self.player_id, config).await + } SampleEntry::Opus(b) => { let config = AudioDecoderConfig::from_opus_box(b); WasmApi::create_audio_decoder(self.player_id, config).await