diff --git a/CHANGES.md b/CHANGES.md index 28b00780..6077b34c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,8 @@ ## develop +- [ADD] `Mp4MediaStream` の対応コーデックに H.265 を追加する + - @sile - [ADD] `Mp4MediaStream` の対応コーデックに AV1 を追加する - @sile - [ADD] `Mp4MediaStream` の対応コーデックに VP9 を追加する diff --git a/packages/mp4-media-stream/README.md b/packages/mp4-media-stream/README.md index 681b567e..fab96df7 100644 --- a/packages/mp4-media-stream/README.md +++ b/packages/mp4-media-stream/README.md @@ -32,6 +32,7 @@ video.srcObject = stream - 映像: - H.264 + - H.265 - VP8 - VP9 - AV1 diff --git a/packages/mp4-media-stream/wasm/src/mp4.rs b/packages/mp4-media-stream/wasm/src/mp4.rs index 58663de5..6b601ef2 100644 --- a/packages/mp4-media-stream/wasm/src/mp4.rs +++ b/packages/mp4-media-stream/wasm/src/mp4.rs @@ -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::>() + .join(".") ), description, coded_width: b.visual.width,