mirror of
https://github.com/alfg/mp4-rust.git
synced 2025-04-15 08:14:15 +00:00
.
This commit is contained in:
parent
4807dc26e1
commit
0e70b58892
3 changed files with 26 additions and 4 deletions
|
@ -5,8 +5,7 @@ use std::io::{self, BufReader, BufWriter};
|
|||
use std::path::Path;
|
||||
|
||||
use mp4::{
|
||||
AacConfig, AvcConfig, HevcConfig, MediaConfig, MediaType, Mp4Config, OpusConfig, Result,
|
||||
TrackConfig, TtxtConfig, Vp9Config,
|
||||
AacConfig, AvcConfig, HevcBoxType, HevcConfig, MediaConfig, MediaType, Mp4Config, OpusConfig, Result, TrackConfig, TtxtConfig, Vp9Config
|
||||
};
|
||||
|
||||
fn main() {
|
||||
|
@ -71,6 +70,7 @@ fn copy<P: AsRef<Path>>(src_filename: &P, dst_filename: &P) -> Result<()> {
|
|||
temporal_id_nested: Some(false),
|
||||
length_size_minus_one: Some(3),
|
||||
arrays: Some(vec![]),
|
||||
box_type: Some(HevcBoxType::Hev1),
|
||||
}),
|
||||
MediaType::VP9 => MediaConfig::Vp9Config(Vp9Config {
|
||||
width: track.width(),
|
||||
|
|
13
src/track.rs
13
src/track.rs
|
@ -5,6 +5,7 @@ use std::io::{Read, Seek, SeekFrom, Write};
|
|||
use std::time::Duration;
|
||||
|
||||
use crate::elst::ElstEntry;
|
||||
use crate::hvc1::Hvc1Box;
|
||||
use crate::mp4a::EsdsBox;
|
||||
use crate::mp4box::traf::TrafBox;
|
||||
use crate::mp4box::trak::TrakBox;
|
||||
|
@ -790,8 +791,16 @@ impl Mp4TrackWriter {
|
|||
let vmhd = VmhdBox::default();
|
||||
trak.mdia.minf.vmhd = Some(vmhd);
|
||||
|
||||
let hev1 = Hev1Box::new(hevc_config);
|
||||
trak.mdia.minf.stbl.stsd.hev1 = Some(hev1);
|
||||
match hevc_config.box_type.unwrap_or(HevcBoxType::Hev1) {
|
||||
HevcBoxType::Hev1 => {
|
||||
let hev1 = Hev1Box::new(hevc_config);
|
||||
trak.mdia.minf.stbl.stsd.hev1 = Some(hev1);
|
||||
}
|
||||
HevcBoxType::Hvc1 => {
|
||||
let hvc1 = Hvc1Box::new(hevc_config);
|
||||
trak.mdia.minf.stbl.stsd.hvc1 = Some(hvc1);
|
||||
}
|
||||
}
|
||||
}
|
||||
MediaConfig::Vp9Config(ref config) => {
|
||||
trak.tkhd.set_width(config.width);
|
||||
|
|
13
src/types.rs
13
src/types.rs
|
@ -611,6 +611,12 @@ pub struct AvcConfig {
|
|||
pub pic_param_set: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum HevcBoxType {
|
||||
Hev1,
|
||||
Hvc1,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub struct HevcConfig {
|
||||
pub width: Option<u16>,
|
||||
|
@ -633,6 +639,7 @@ pub struct HevcConfig {
|
|||
pub temporal_id_nested: Option<bool>,
|
||||
pub length_size_minus_one: Option<u8>,
|
||||
pub arrays: Option<Vec<HvcCArray>>,
|
||||
pub box_type: Option<HevcBoxType>,
|
||||
}
|
||||
|
||||
impl Default for HevcConfig {
|
||||
|
@ -658,6 +665,7 @@ impl Default for HevcConfig {
|
|||
temporal_id_nested: None,
|
||||
length_size_minus_one: None,
|
||||
arrays: None,
|
||||
box_type: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -683,6 +691,11 @@ impl HevcConfig {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_box_type(mut self, box_type: HevcBoxType) -> Self {
|
||||
self.box_type = Some(box_type);
|
||||
self
|
||||
}
|
||||
|
||||
// ... add similar methods for all other fields ...
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue