[Libav-user] Issues when playing files from http

Bjoern Drabeck bjoern.drabeck at gmail.com
Wed Apr 24 17:54:56 CEST 2013


Hi,

in my player I want to play back files that are located online (usually mp4
files provided from some server or CDN (http)), which generally works fine,
however I have two issues that I need to address, but am not quite sure
about:

1. when I pause the file for several minutes then continue later it seems
ffmpeg's connection times out and the next call into av_read_frame returns
an error. My code is (currently) still the same that I use for local
playback, so I was wondering what would be required to change in order to
affect that. Is there a way to tell it to keep the connection alive? Or do
I have to make sure in my player that at least at a regular interval I keep
reading another packet with av_read_frame, and stuffing it into a buffer?
(Normally when I pause I keep reading packets until the packet queues are
full, then the next av_read_frame will only happen after some packets have
been taken out for processing).

2. sometimes playback can be a bit jerky, esp for example when I seek
somewhere into the stream, and I am on a slower connection, then even
though I wait until I have a few frames ready before continuing playback,
however it still seems that I am rendering them faster than I can get them
from the stream. Is there some way of knowing when enough data is ready for
me to continue playback? (I mean inside the ffmpeg libraries, or some
callbacks I can set or flags to monitor or sth) Or do I have to write my
own logic to see of the rate of consumption is bigger than the rate I can
get the packets out of the stream?

Are there any recommended practices or guidelines or documents on how to
handle that?

Mostly the code that I use for local playback works fine for online as
well, just the pausing issue is really troublesome, and the
buffering behavior on slower connections.

thanks and best regards,
Bjoern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130424/f8cde955/attachment.html>


More information about the Libav-user mailing list