Skip to content

Commit 833e852

Browse files
Feature/writebox trait (alfg#11)
* Add ReadBox trait * Add boxtype macro * Remove offset in BoxHeader * Fix parsing error when box has largesize * Remove duplicated codes reading version and flags * Simplify all box size types as largesize * Add WriteBox trait and improve compatibility with large box * Split large atoms file into smaller ones * Refator Error Co-authored-by: Byungwan Jun <[email protected]>
1 parent e7d175d commit 833e852

File tree

22 files changed

+1747
-792
lines changed

22 files changed

+1747
-792
lines changed

Cargo.lock

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ keywords = ["mp4", "isobmff"]
1818
license = "MIT"
1919

2020
[dependencies]
21+
thiserror = "^1.0"
2122
byteorder = "1"

examples/mp4info.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn main() {
5858

5959
println!(" media:");
6060
if let Some(ref s) = stts {
61-
println!(" sample count: {:?}", s.sample_counts[0]);
61+
println!(" sample count: {:?}", s.entries[0].sample_count);
6262
}
6363
println!(" timescale: {:?}", mdhd.timescale);
6464
println!(
@@ -73,7 +73,7 @@ fn main() {
7373
if let Some(ref s) = stts {
7474
println!(
7575
" frame rate: (computed): {:?}",
76-
get_framerate(&s.sample_counts, mdhd.duration, mdhd.timescale)
76+
get_framerate(s.entries[0].sample_count, mdhd.duration, mdhd.timescale)
7777
);
7878
}
7979
}
@@ -97,18 +97,18 @@ fn get_handler_type(handler: &str) -> mp4::TrackType {
9797
return typ;
9898
}
9999

100-
fn get_duration_ms(duration: u32, timescale: u32) -> String {
100+
fn get_duration_ms(duration: u64, timescale: u32) -> String {
101101
let ms = (duration as f64 / timescale as f64) * 1000.0;
102102
return format!("{:.2}", ms.floor());
103103
}
104104

105-
fn get_framerate(sample_counts: &Vec<u32>, duration: u32, timescale: u32) -> String {
106-
let sc = (sample_counts[0] as f64) * 1000.0;
105+
fn get_framerate(sample_count: u32, duration: u64, timescale: u32) -> String {
106+
let sc = (sample_count as f64) * 1000.0;
107107
let ms = (duration as f64 / timescale as f64) * 1000.0;
108108
return format!("{:.2}", sc / ms.floor());
109109
}
110110

111-
fn creation_time(creation_time: u32) -> u32 {
111+
fn creation_time(creation_time: u64) -> u64 {
112112
// convert from MP4 epoch (1904-01-01) to Unix epoch (1970-01-01)
113113
if creation_time >= 2082844800 {
114114
creation_time - 2082844800

0 commit comments

Comments
 (0)