mirror of
https://github.com/alfg/mp4-rust.git
synced 2024-06-11 01:19:21 +00:00
feat: mp4 writer set vp09 box into stsd box
This commit is contained in:
parent
63e3e114f6
commit
a0265654f1
|
@ -31,6 +31,38 @@ impl Vp09Box {
|
|||
pub const DEFAULT_FRAME_COUNT: u16 = 1;
|
||||
pub const DEFAULT_COMPRESSORNAME: [u8; 32] = [0; 32];
|
||||
pub const DEFAULT_DEPTH: u16 = 24;
|
||||
|
||||
pub fn new(config: &Vp9Config) -> Self {
|
||||
Vp09Box {
|
||||
version: 0,
|
||||
flags: 0,
|
||||
start_code: Vp09Box::DEFAULT_START_CODE,
|
||||
data_reference_index: Vp09Box::DEFAULT_DATA_REFERENCE_INDEX,
|
||||
reserved0: Default::default(),
|
||||
width: config.width,
|
||||
height: config.height,
|
||||
horizresolution: Vp09Box::DEFAULT_HORIZRESOLUTION,
|
||||
vertresolution: Vp09Box::DEFAULT_VERTRESOLUTION,
|
||||
reserved1: Default::default(),
|
||||
frame_count: Vp09Box::DEFAULT_FRAME_COUNT,
|
||||
compressorname: Vp09Box::DEFAULT_COMPRESSORNAME,
|
||||
depth: Vp09Box::DEFAULT_DEPTH,
|
||||
end_code: Vp09Box::DEFAULT_END_CODE,
|
||||
vpcc: VpccBox {
|
||||
version: VpccBox::DEFAULT_VERSION,
|
||||
flags: 0,
|
||||
profile: 0,
|
||||
level: 0x1F,
|
||||
bit_depth: VpccBox::DEFAULT_BIT_DEPTH,
|
||||
chroma_subsampling: 0,
|
||||
video_full_range_flag: false,
|
||||
color_primaries: 0,
|
||||
transfer_characteristics: 0,
|
||||
matrix_coefficients: 0,
|
||||
codec_initialization_data_size: 0,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Mp4Box for Vp09Box {
|
||||
|
@ -143,35 +175,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_vpcc() {
|
||||
let src_box = Vp09Box {
|
||||
version: 0,
|
||||
flags: 0,
|
||||
start_code: Vp09Box::DEFAULT_START_CODE,
|
||||
data_reference_index: Vp09Box::DEFAULT_DATA_REFERENCE_INDEX,
|
||||
reserved0: Default::default(),
|
||||
width: 0,
|
||||
height: 0,
|
||||
horizresolution: Vp09Box::DEFAULT_HORIZRESOLUTION,
|
||||
vertresolution: Vp09Box::DEFAULT_VERTRESOLUTION,
|
||||
reserved1: Default::default(),
|
||||
frame_count: Vp09Box::DEFAULT_FRAME_COUNT,
|
||||
compressorname: Vp09Box::DEFAULT_COMPRESSORNAME,
|
||||
depth: Vp09Box::DEFAULT_DEPTH,
|
||||
end_code: Vp09Box::DEFAULT_END_CODE,
|
||||
vpcc: VpccBox {
|
||||
version: VpccBox::DEFAULT_VERSION,
|
||||
flags: 0,
|
||||
profile: 0,
|
||||
level: 0x1F,
|
||||
bit_depth: VpccBox::DEFAULT_BIT_DEPTH,
|
||||
chroma_subsampling: 0,
|
||||
video_full_range_flag: false,
|
||||
color_primaries: 0,
|
||||
transfer_characteristics: 0,
|
||||
matrix_coefficients: 0,
|
||||
codec_initialization_data_size: 0,
|
||||
},
|
||||
};
|
||||
let src_box = Vp09Box::new(&Vp9Config{ width: 1920, height: 1080 });
|
||||
let mut buf = Vec::new();
|
||||
src_box.write_box(&mut buf).unwrap();
|
||||
assert_eq!(buf.len(), src_box.box_size() as usize);
|
||||
|
|
|
@ -10,6 +10,7 @@ use crate::mp4box::*;
|
|||
use crate::mp4box::{
|
||||
avc1::Avc1Box,
|
||||
hev1::Hev1Box,
|
||||
vp09::Vp09Box,
|
||||
ctts::CttsBox,
|
||||
ctts::CttsEntry,
|
||||
mp4a::Mp4aBox,
|
||||
|
@ -575,7 +576,7 @@ impl Mp4TrackWriter {
|
|||
trak.tkhd.set_width(config.width);
|
||||
trak.tkhd.set_height(config.height);
|
||||
|
||||
trak.mdia.minf.stbl.stsd.vp09 = Default::default();
|
||||
trak.mdia.minf.stbl.stsd.vp09 = Some(Vp09Box::new(config));
|
||||
}
|
||||
MediaConfig::AacConfig(ref aac_config) => {
|
||||
let smhd = SmhdBox::default();
|
||||
|
|
Loading…
Reference in a new issue