-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example to use the crate. #1
Comments
there is currently no easy way to read, you have to do it a bit manually, unfortunately the project was put on hold before i got there. You ned two things: A reader that is let header = BoxHeader::read(&mut reader).await?; // The Mp4Readable read
let ftyp = FtypBox::read(header, &mut reader).await?; // The BoxRead trait read
// read other boxes like the previous, ideally with an enum based on the ID of what you expect. one of the tests goes like this: let base = Box::default();
let mut buf = vec![];
let mut cursor = std::io::Cursor::new(&mut buf);
let pos = base.write(&mut cursor)?;
assert_eq!(pos, base.byte_size());
assert_eq!(pos as u64, cursor.position());
let mut cursor = futures::io::Cursor::new(&mut buf);
let header = BoxHeader::read(&mut cursor).await?;
assert_eq!(header.id, Box::ID);
let new = Box::read(header, &mut cursor).await?;
assert_eq!(base, new);
Ok(()) Creating a proper easy to use reader wouldn't be too complicated, either with dyn Any + Other traits, or an enum. That would be a great PR if it's something you enjoy :) |
Hi, Thanks for reply. |
my reader was |
You have async_std::net::TcpStream, but since you need seek wrap it in a async_std::io::BufReader. |
Hey i think i am getting hang of stuff now. Looks like Bufreader doesn't provide asyncSeek. The issue i see is that there is no way of know how much buffer is required. |
In principle, to be sure you can parse all kinds of MP4 you need to store the whole stream, even if you can start parsing before the end. But if you know where the mdats are and store the data separately with their proper offsets like in a fragmented mp4 then you don't really need to seek i think. |
ah i see, here is the use: async-mp4/src/mp4box/box_root.rs Lines 64 to 91 in 902ddff
|
To be fair, reading linearly could still be possible, but a bug in one of the boxes implementation could corrupt the whole parsing... |
futures::io::BufReader is AsyncRead and AsyncSeek |
The What is see is the if the data is stored for header size then we don't really need seek. Can you explain May be you are write mp4 cannot be streamable. alfg/mp4-rust#53 |
if we implement things around a content aware context it should be possible to stream. Seek isn't used very often, it's mostly used to make sure there are no mistakes. |
I just went through this video looks like there is lot of stuff to video decoding. Will close this issue as i am not going to pick this immediate but thanks for the guidance was really helpful. |
I want to read frame from tcp stream. how to use the crate to do the same ?
I don't see any struct or new method which might be helpful for the same.
The text was updated successfully, but these errors were encountered: