[Libav-user] Issues when playing files from http

Bjoern Drabeck bjoern.drabeck at gmail.com
Fri Apr 26 08:01:32 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).
>

Upon further investigation I found that after pausing a file (that I
am streaming from http) for a while, then continue playback,
av_read_frame starts to return with AVERROR_INVALIDDATA ("Invalid data
found when processing input ") usually for several packets. While in
itself this is not a major problem (except that the resulting frames
will be corrupted), I am wondering if this is caused by me (maybe
lacking to set some flags or something upon opening the file), or if
this would indicate a problem on the http layer of ffmpeg?

Anyone else experience anything similar, or know anything about this issue?


> 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,
Bjoern


More information about the Libav-user mailing list