Skip to content

Commit 9951fea

Browse files
committed
Expose the mvhd timescale when getting the fragment duration
1 parent 34e91fd commit 9951fea

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

mp4parse_capi/src/lib.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,9 @@ impl Default for Mp4parseTrackVideoInfo {
275275
#[derive(Default, Debug)]
276276
pub struct Mp4parseFragmentInfo {
277277
pub fragment_duration: u64, // in ticks
278-
// TODO:
279-
// info in trex box.
278+
pub time_scale: u64,
279+
// TODO:
280+
// info in trex box.
280281
}
281282

282283
#[derive(Default)]
@@ -1425,14 +1426,12 @@ pub unsafe extern "C" fn mp4parse_get_fragment_info(
14251426
None => return Mp4parseStatus::Invalid,
14261427
};
14271428

1428-
match duration {
1429-
Some(duration_ticks) => {
1430-
info.fragment_duration = duration_ticks.0;
1431-
}
1432-
None => return Mp4parseStatus::Invalid,
1429+
if let (Some(time), Some(scale)) = (duration, context.timescale) {
1430+
info.fragment_duration = time.0;
1431+
info.time_scale = scale.0;
1432+
return Mp4parseStatus::Ok;
14331433
};
1434-
1435-
Mp4parseStatus::Ok
1434+
Mp4parseStatus::Invalid
14361435
}
14371436

14381437
/// Determine if an mp4 file is fragmented. A fragmented file needs mvex table

mp4parse_capi/tests/test_fragment.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ fn parse_fragment() {
5959
rv = mp4parse_get_fragment_info(parser, &mut fragment_info);
6060
assert_eq!(rv, Mp4parseStatus::Ok);
6161
assert_eq!(fragment_info.fragment_duration, 10_032);
62+
assert_eq!(fragment_info.time_scale, 1000);
6263

6364
mp4parse_free(parser);
6465
}

0 commit comments

Comments
 (0)