mirror of
https://github.com/alfg/mp4-rust.git
synced 2024-12-22 03:56:28 +00:00
Writer: Set mvhd/tkhd/mdhd version to 1 if duration is greater than u32::MAX (#76)
This commit is contained in:
parent
cc9bf192fa
commit
00385bad0b
2 changed files with 9 additions and 0 deletions
|
@ -724,8 +724,14 @@ impl Mp4TrackWriter {
|
|||
|
||||
fn update_durations(&mut self, dur: u32, movie_timescale: u32) {
|
||||
self.trak.mdia.mdhd.duration += dur as u64;
|
||||
if self.trak.mdia.mdhd.duration > (u32::MAX as u64) {
|
||||
self.trak.mdia.mdhd.version = 1
|
||||
}
|
||||
self.trak.tkhd.duration +=
|
||||
dur as u64 * movie_timescale as u64 / self.trak.mdia.mdhd.timescale as u64;
|
||||
if self.trak.tkhd.duration > (u32::MAX as u64) {
|
||||
self.trak.tkhd.version = 1
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn write_sample<W: Write + Seek>(
|
||||
|
|
|
@ -135,6 +135,9 @@ impl<W: Write + Seek> Mp4Writer<W> {
|
|||
|
||||
moov.mvhd.timescale = self.timescale;
|
||||
moov.mvhd.duration = self.duration;
|
||||
if moov.mvhd.duration > (u32::MAX as u64) {
|
||||
moov.mvhd.version = 1
|
||||
}
|
||||
moov.write_box(&mut self.writer)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue