1
0
Fork 0
mirror of https://github.com/alfg/mp4-rust.git synced 2025-04-15 08:14:15 +00:00
This commit is contained in:
damitha 2025-03-23 20:42:15 +11:00
parent 4e0db2a3a3
commit 231d70d297
4 changed files with 20 additions and 10 deletions

View file

@ -63,7 +63,7 @@ fn copy<P: AsRef<Path>>(src_filename: &P, dst_filename: &P) -> Result<()> {
profile: track.audio_profile()?,
freq_index: track.sample_freq_index()?,
chan_conf: track.channel_config()?,
esds: None
esds: None,
}),
MediaType::OPUS => MediaConfig::OpusConfig(OpusConfig {
bitrate: track.bitrate(),

View file

@ -28,7 +28,7 @@ impl Default for Mp4aBox {
}
impl Mp4aBox {
pub fn new(config: &AacConfig ) -> Self {
pub fn new(config: &AacConfig) -> Self {
Self {
data_reference_index: 1,
channelcount: config.chan_conf as u16,
@ -314,7 +314,7 @@ pub struct ESDescriptor {
impl ESDescriptor {
pub fn new(config: &AacConfig) -> Self {
let mut dec_config = DecoderConfigDescriptor::new(config);
let mut sl_config = SLConfigDescriptor::new();
let mut sl_config = SLConfigDescriptor::new();
if config.esds.is_some() {
dec_config = config.esds.clone().unwrap().es_desc.dec_config;
sl_config = config.esds.clone().unwrap().es_desc.sl_config;

View file

@ -270,7 +270,11 @@ impl<R: Read + Seek> Mp4Reader<R> {
}
}
pub fn read_sample_metadata(&mut self, track_id: u32, sample_id: u32) -> Result<Option<Mp4SampleMetadata>> {
pub fn read_sample_metadata(
&mut self,
track_id: u32,
sample_id: u32,
) -> Result<Option<Mp4SampleMetadata>> {
if let Some(track) = self.tracks.get(&track_id) {
track.read_sample_metadata(sample_id)
} else {
@ -278,7 +282,6 @@ impl<R: Read + Seek> Mp4Reader<R> {
}
}
pub fn sample_offset(&mut self, track_id: u32, sample_id: u32) -> Result<u64> {
if let Some(track) = self.tracks.get(&track_id) {
track.sample_offset(sample_id)

View file

@ -5,6 +5,7 @@ use std::io::{Read, Seek, SeekFrom, Write};
use std::time::Duration;
use crate::elst::ElstEntry;
use crate::mp4a::EsdsBox;
use crate::mp4box::traf::TrafBox;
use crate::mp4box::trak::TrakBox;
use crate::mp4box::trun::TrunBox;
@ -303,6 +304,15 @@ impl Mp4Track {
}
}
pub fn get_esds(&self) -> Result<&EsdsBox> {
if let Some(ref mp4a) = self.trak.mdia.minf.stbl.stsd.mp4a {
if let Some(ref esds) = mp4a.esds {
return Ok(esds);
}
}
Err(Error::BoxInStblNotFound(self.track_id(), BoxType::EsdsBox))
}
pub fn picture_parameter_set(&self) -> Result<&[u8]> {
if let Some(ref avc1) = self.trak.mdia.minf.stbl.stsd.avc1 {
match avc1.avcc.picture_parameter_sets.first() {
@ -619,11 +629,8 @@ impl Mp4Track {
}
}
pub(crate) fn read_sample_metadata(
&self,
sample_id: u32,
) -> Result<Option<Mp4SampleMetadata>> {
let (start_time, duration) = self.sample_time(sample_id).unwrap();
pub(crate) fn read_sample_metadata(&self, sample_id: u32) -> Result<Option<Mp4SampleMetadata>> {
let (start_time, duration) = self.sample_time(sample_id).unwrap();
let rendering_offset = self.sample_rendering_offset(sample_id);
let is_sync = self.is_sync_sample(sample_id);