-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Parse avcc
Box ?
#159
Comments
Not at the moment. It just copies the box contents into the It'd be nice if the library was more complete, but anything currently missing is either handled by other (C++) code inside Gecko or unused by Gecko, so there are no immediate plans to extend the parser. Contributions with tests are welcome, of course. |
Line: https://github.com/mozilla/mp4parse-rust/blob/master/mp4parse/src/lib.rs#L1867-L1868 #[derive(Debug)]
struct AVCVideoConfigurationRecord {
version: u8,
profile: u8,
compatibility: u8,
level: u8,
// indicates the length in bytes of the length field in an AVC video access unit used indicate the length of each NAL unit.
length_size_minus_one: u8,
sps: Vec<Vec<u8>>,
pps: Vec<Vec<u8>>,
}
fn parse_avc_config(data: &[u8]) -> AVCVideoConfigurationRecord {
let version = data[0];
let avc_profile = data[1];
let avc_compatibility = data[2];
let avc_level = data[3];
let NALULengthSizeMinusOne = data[4] & 0b00000011;
let number_of_SPS_NALUs = data[5] & 0b00011111;
let mut i: usize = 6;
let sps_elems = (0..number_of_SPS_NALUs)
.map(|_|{
let sps_size = u16::from_be_bytes([data[i], data[i+1]]) as usize;
i += 2;
let sps: Vec<u8> = data[i..i+sps_size].to_vec();
i += sps_size;
sps
})
.collect::<Vec<Vec<u8>>>();
let number_of_PPS_NALUs = data[i];
i += 1;
let pps_elems = (0..number_of_PPS_NALUs)
.map(|_|{
let pps_size = u16::from_be_bytes([data[i], data[i+1]]) as usize;
i += 2;
let sps: Vec<u8> = data[i..i+pps_size].to_vec();
i += pps_size;
sps
})
.collect::<Vec<Vec<u8>>>();
assert_eq!(version, 1);
AVCVideoConfigurationRecord {
version,
profile: avc_profile,
compatibility: avc_compatibility,
level: avc_level,
length_size_minus_one: NALULengthSizeMinusOne,
sps: sps_elems,
pps: pps_elems,
}
} this work for me. but change this line is difficult for me: https://github.com/mozilla/mp4parse-rust/blob/master/mp4parse_capi/src/lib.rs#L640 |
Hi,
Does this library now support parsing
avcc
box?I wrote some code to convert the MP4 (H264) file into a
H264
stream file.Since the
avcc
box parsing is not currently supported,I cannot extract
SPS NAL
andPPS NAL
frommp4parse::track
.Code: https://gist.github.com/LuoZijun/3e727fd5d337e2e780ba7d68c7bef618#file-mp4_video_samples_to_h264-rs-L259
Raw H.264 Stream:
The text was updated successfully, but these errors were encountered: