[Ffmpeg-devel] file length / http
Ronald S. Bultje
Mon Dec 18 04:15:48 CET 2006
I've looked at the input provided to my http seeking patch, and am also
looking at making sure it works correctly with both seekable and
unseekable servers without too much trouble.
One thing I noticed is that a lot of demuxers currently use SEEK_END, -1
followed by SEEK_SET, 0 to find out the length of a file. Worse yet,
url_fsize() is implemented in exactly that manner.
This is OK for files. However, for streams, this can cause considerable
delay while reopening the HTTP/tcp connection. Also, this will not
always work, e.g. if the server doesn't support seeking. Still, the file
length may be known (through the http Content-Length property in the
Would anyone oppose if instead, I add a "length" value into URLContext?
For files that are still being written, I can update it after every
read(). I can also not make it a value in the URLContext structure, but
just a virtual function in URLProtocol (which calls stat in the file.c
implementation, but just replies the same value all the time in http.c
and possibly other network protocols).
Obviously, in both cases, several demuxers will need to be adapted to
not cache the reply of url_fsize() (or their direct call to SET_END,
-1), but instead repeatedly call url_size() or whatever this function
will be named.
Any comments or does anyone have a better idea?
More information about the ffmpeg-devel