[Libav-user] Why is HTTP streaming so slow?

Michael Bradshaw mbradshaw at sorensonmedia.com
Thu May 24 21:07:58 CEST 2012


I've written a plugin for a program that uses FFmpeg to read and
decode a video file, and then passes the decoded frames to an encoder
(not FFmpeg) that consumes them. A big motivation for this plugin is
FFmpeg's ability to stream videos over HTTP. However, I've found this
to be incredibly slow, and I'm wondering if I'm doing things right.

The sample video file can be downloaded through my web browser in
about 2 minutes (at a rate of about 3.5-4MB per second), and
transcoded (using my FFmpeg reader for decoding) in about 12 minutes
(using about 80% of my CPU), for ~14 minutes in total. However, if I
use the URL in the reader (and stream the video over HTTP), it
downloads at a rate of about 80KB per second, and the transcode was
only ~15% done after 14 minutes (and only used 5-10% of my CPU). I'm
quite sure the bottleneck is my decoder not downloading the video fast
enough, so it doesn't decode and feed frames to the encoder fast
either (hence my low CPU usage).

Why is downloading the file and then transcoding it so much faster
than streaming it while transcoding? Are there any quirks I need to be
aware of when streaming, or any flags I need to set in order to
increase the streaming rate? Right now my code is pretty straight
forward, and is semi-similar to ffplay (i.e. nothing fancy) (ffplay
can't play it back fast enough either, and streams it at the same rate
as my plugin decoder).

Is there a particular reason FFmpeg streams so slowly?

Thanks,

Michael


More information about the Libav-user mailing list