Skip to content

Commit

Permalink
Merge pull request #509 from shiguredo/feature/mp4-media-stream-vp9
Browse files Browse the repository at this point in the history
`Mp4MediaStream` の対応コーデックに VP9 を追加する
  • Loading branch information
sile authored Dec 6, 2024
2 parents 8093dc4 + 4313c32 commit b749217
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

## develop

- [ADD] `Mp4MediaStream` の対応コーデックに VP9 を追加する
- @sile
- [ADD] `Mp4MediaStream` の対応コーデックに VP8 を追加する
- @sile
- [ADD] `Mp4MediaStream` の対応コーデックに AAC を追加する
Expand Down
1 change: 1 addition & 0 deletions packages/mp4-media-stream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ video.srcObject = stream
- 映像:
- H.264
- VP8
- VP9
- 音声:
- AAC
- Opus
Expand Down
20 changes: 19 additions & 1 deletion packages/mp4-media-stream/wasm/src/mp4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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));
}
Expand Down
4 changes: 4 additions & 0 deletions packages/mp4-media-stream/wasm/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b749217

Please sign in to comment.