[Libav-user] Why is HTTP streaming so slow?
Michael Bradshaw
mbradshaw at sorensonmedia.com
Fri May 25 16:28:43 CEST 2012
On Thu, May 24, 2012 at 10:21 PM, Kalileo <kalileo at universalx.net> wrote:
>
> On May 25, 2012, at 04:35 , Michael Bradshaw wrote:
>
>> On Thu, May 24, 2012 at 2:05 PM, Andrey Utkin
>> <andrey.krieger.utkin at gmail.com> wrote:
>>>> Is there a particular reason FFmpeg streams so slowly?
>>>
>>> Coz while you decode, you don't fetch, and while you fetch, you don't
>>> decode. That's what switching overhead and lack of parallelism in your app
>>> result in.
>>
>> Hmmm... that seems like it would make sense, but I just ran a simple
>> test program that simply loops and calls av_read_frame() (no decoding)
>> and I get the same results (uses <5% of the CPU, so it doesn't look
>> like the network is waiting on the CPU). Here's what I've found (and
>> these numbers seem pretty consistent on my machine):
>
> There is no reason why FFMPEG would not stream fast enough. However, a lot depends on your code.
In a small, separate test program I made, I just opened the file and
looped calling av_read_frame() (without decoding the packets), and it
streamed at the same rate. I can't see why simply looping and calling
av_read_frame() downloads the video at a fraction of the rate my web
browser (or QuickTime Player) does, either, but that's the behavior I
keep seeing.
> If you run decoding and streaming in different threads there should be no reason why streaming would be slower than required.
You mean av_read_frame() in one thread and
avcodec_decode_video2/audio4() in another, right? Because eliminating
avcodec_decode_video2/audio4() doesn't seem to help, which I thought
it would have.
> You talk about passing the decoded frames to a separate encoder, then you talk about using FFMPEG for streaming over HTTP, I don't really see how that fits together.
Open and stream file over HTTP -> decode frames -> pass frames to
encoder. I'm using FFmpeg for the first two parts.
Maybe I'll have to do some profiling... I'll post back if I find anything.
Thanks,
Michael
More information about the Libav-user
mailing list