1
0
Fork 0
mirror of https://github.com/alfg/mp4-rust.git synced 2024-06-02 13:39:54 +00:00

Public read sample offset

This commit is contained in:
Eric Knapp 2023-04-24 08:58:46 -04:00
parent d53fea37c6
commit b414f1ec60
2 changed files with 9 additions and 1 deletions

View file

@ -172,6 +172,14 @@ impl<R: Read + Seek> Mp4Reader<R> {
Err(Error::TrakNotFound(track_id))
}
}
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)
} else {
Err(Error::TrakNotFound(track_id))
}
}
}
impl<R> Mp4Reader<R> {

View file

@ -434,7 +434,7 @@ impl Mp4Track {
}
}
fn sample_offset(&self, sample_id: u32) -> Result<u64> {
pub fn sample_offset(&self, sample_id: u32) -> Result<u64> {
if !self.trafs.is_empty() {
if let Some((traf_idx, _sample_idx)) = self.find_traf_idx_and_sample_idx(sample_id) {
Ok(self.trafs[traf_idx].tfhd.base_data_offset.unwrap_or(0))