I want to extract single frames (as thumbs) from videos, without having to download the full video file. I would like to just read the mp4 header (the info should be in the moov atom) and then download the required byte ranges. Afaik thats what browsers (HTML5 video) do when you skip to an unbuffered part
I already looked at: How can HTML5 video's byte-range requests (pseudo-streaming) work? but i can't figure out how to use it with ffmpeg for example.
Thanks a lot!
Here's how a general algorithm might operate if you were absolutely determined to make this approach work:
moov atom is up front; determine moov atom's length and make another request to fetch the rest of the atommoov atom to find the video trak atom; dig into that atom to find the following atoms: stsd, stss, stco/co64, and stszstsd will give you initialization information required to feed into the H.264 video decoderstss atom gives you a list of all the sync samples (keyframes); these can be decoded independently and would be ideal for your thumbnailing prospectsstss atom, you can cross reference with the stco or co64 atoms (a trak will have one or the other) in order to find the absolute file location, and the stsz atom, which will tell you exactly how many bytes are in the frameWith all of this information combined, you should be able to download and decode (and thus resize and re-compress for thumbnailing) just the keyframes of an MP4 video.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With