[FFmpeg-user] Ffmpeg issues multiple HTTP requests when starting a video from a URL

Edward Park kumowoon1025 at gmail.com
Fri Jul 17 14:08:38 EEST 2020


> There is no attempt to seek the video on the command line. The server returns HTTP/1.1 206 Partial Content initially and ffmpeg then tries to get data at different offsets before it prints "All info found" and proceeds with the conversion. Multiple connections cause an additional delay which I'd like to avoid no matter how small it is. Is there a mechanism to override this behavior and have ffmpeg to work with the data stream as it is being read?

Information needed to parse the content can be near the end of the file, as it is in this case.

> [mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [debug] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
> [mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'ftyp' parent:'root' sz: 32 8 9495632
> [mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [debug] ISO: File Type Major Brand: isom
> [mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'free' parent:'root' sz: 8 40 9495632
> [mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'mdat' parent:'root' sz: 9468817 48 9495632

At the beginning of the file, it is apparent that after 'ftyp' then 'free', 'mdat', media data, will continue for another ~9 mbytes, but that's not really useful if it can't be decoded. So rather than keep downloading, it skips to the next section of the file, looking for the necessary info.
> [mov,mp4,m4a,3gp,3g2,mj2 @ 000001faa550d080] [] type:'moov' parent:'root' sz: 26775 9468865 9495632

And 'moov' contains the info needed to make sense of the rest of the file. Now that it has that, it goes back and downloads from where it short-circuited before. At <10MBs, as you say, it might make more sense to download the whole file and then work with it on disk. But for larger downloads, or with a not-so-great connection, I'd imagine opening/closing multiple connections isn't as big a cost, resource or performance wise. And maybe more so in situations like where one might not need the video stream, for example.

-multiple_requests is supposed to keep the same connection, but I don't know if it actually works, especially depending on which ssl. If it doesn't, you can always curl or wget the whole file and avoid the extra connections' overhead, probably? Assuming that the media is self-contained in that one file, that is.

Ted Park

More information about the ffmpeg-user mailing list