Skip to content

Commit

Permalink
Mp4MediaStream の対応コーデックに H.265 を追加する
Browse files Browse the repository at this point in the history
  • Loading branch information
sile committed Dec 6, 2024
1 parent fd90b72 commit e046102
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
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` の対応コーデックに H.265 を追加する
- @sile
- [ADD] `Mp4MediaStream` の対応コーデックに AV1 を追加する
- @sile
- [ADD] `Mp4MediaStream` の対応コーデックに VP9 を追加する
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 @@ -32,6 +32,7 @@ video.srcObject = stream

- 映像:
- H.264
- H.265
- VP8
- VP9
- AV1
Expand Down
38 changes: 35 additions & 3 deletions packages/mp4-media-stream/wasm/src/mp4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,43 @@ impl VideoDecoderConfig {
b.hvcc_box.encode(&mut description).expect("unreachable");
description.drain(..8); // ボックスヘッダ部分を取り除く

let mut constraints = b
.hvcc_box
.general_constraint_indicator_flags
.get()
.to_be_bytes()
.to_vec();
while constraints.len() > 1 && constraints.last() == Some(&0) {
constraints.pop();
}

Self {
// ISO / IEC 14496-15 E.3
codec: format!(
"hev1.1.6.L90.B0" // b.c_profile_indication,
// b.avcc_box.profile_compatibility,
// b.avcc_box.avc_level_indication
"hev1.{}.{:X}.{}.{}",
match b.hvcc_box.general_profile_space.get() {
1 => format!("A{}", b.hvcc_box.general_profile_idc.get()),
2 => format!("B{}", b.hvcc_box.general_profile_idc.get()),
3 => format!("C{}", b.hvcc_box.general_profile_idc.get()),
v => format!("{v}"),
},
b.hvcc_box
.general_profile_compatibility_flags
.reverse_bits(),
format!(
"{}{}",
if b.hvcc_box.general_tier_flag.get() == 0 {
'L'
} else {
'H'
},
b.hvcc_box.general_level_idc
),
constraints
.into_iter()
.map(|b| format!("{:02X}", b))
.collect::<Vec<_>>()
.join(".")
),
description,
coded_width: b.visual.width,
Expand Down

0 comments on commit e046102

Please sign in to comment.