forked from alfg/mp4-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ReadBox trait * Add boxtype macro * Remove offset in BoxHeader * Fix parsing error when box has largesize * Remove duplicated codes reading version and flags * Add avc1 box * Add mp4a box * Add mp4a box * Add DecoderSpecificDescriptor in esds box * Add necessary sub-boxes to stbl box * Improve ReadBox::read_box() * Add smhd box * Refactor BoxHeader * Refactor BMFF * Refactor * Add some functions to get offset and size of sample * Add Mp4Reader::read_sample() that read media samples Co-authored-by: Byungwan Jun <unipro.kr@gmail.com>
- Loading branch information
1 parent
6fc03d5
commit 2af9131
Showing
31 changed files
with
2,489 additions
and
624 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,5 @@ license = "MIT" | |
[dependencies] | ||
thiserror = "^1.0" | ||
byteorder = "1" | ||
bytes = "0.5" | ||
num-rational = "0.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use std::env; | ||
use std::fs::File; | ||
use std::io::prelude::*; | ||
use std::io::{self, BufReader}; | ||
use std::path::Path; | ||
|
||
use mp4::Result; | ||
|
||
fn main() { | ||
let args: Vec<String> = env::args().collect(); | ||
|
||
if args.len() < 3 { | ||
println!("Usage: mp4copy <source file> <target file>"); | ||
std::process::exit(1); | ||
} | ||
|
||
if let Err(err) = copy(&args[1], &args[2]) { | ||
let _ = writeln!(io::stderr(), "{}", err); | ||
} | ||
} | ||
|
||
fn copy<P: AsRef<Path>>(src_filename: &P, _dst_filename: &P) -> Result<()> { | ||
let src_file = File::open(src_filename)?; | ||
let size = src_file.metadata()?.len(); | ||
let reader = BufReader::new(src_file); | ||
|
||
let mut mp4 = mp4::Mp4Reader::new(reader); | ||
mp4.read(size)?; | ||
|
||
for tix in 0..mp4.track_count()? { | ||
let track_id = tix + 1; | ||
let sample_count = mp4.sample_count(track_id)?; | ||
for six in 0..sample_count { | ||
let sample_id = six + 1; | ||
let sample = mp4.read_sample(track_id, sample_id)?.unwrap(); | ||
println!("sample_id: {}, {}", sample_id, sample); | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.