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 stsz
stsd
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.