[Libav-user] investigating runtime demux performance

bsenftner at earthlink.net bsenftner at earthlink.net
Mon May 11 21:15:49 EEST 2020

I have an ffmpeg / libav based video playback library which is tuned for
computer vision use: 

it discards any non-video packets, and attempts to deliver video as quickly
as possible while only consuming 1 thread per video stream.


For USB and IP streams, video frames are delivered as soon as they are
received, and media files playback as fast as the disk can deliver frames.


Other than discarding non-video packets and playing as fast as possible, my
player library supports monitoring USB & IP stream dropping - typically
someone tripping over or disconnecting the wire. 

For the added support of my library's stream monitoring, I need to recompile


Between ffmpeg versions 3.2.2 and 4.2.2 I am seeing a fairly significant
difference in playback performance. 

The new version is noticeably slower.

Case in point, decompressing 3000 frames ASAP without any display:

Version 3.2.2: 0.002319 seconds per frame (measured using boost

Version 4.2.2: 0.004250 seconds per frame


In a computer vision context, this increase in processing for version 4.2.2
triggers a need for significantly faster hardware to maintain the same
computer vision application performance. 

So I am investigating to learn if it is possible to get better performance
out of version 4.2.2.  


Between the two ffmpeg versions, my player library requires slightly
different setup to play a stream, but the playback code handling receiving
of packets, conversion to video frames, delivery to the player library, and
final presentation is unmodified.


Other than the change of getting libav from ffmpeg 3.2.2 to getting libav
from ffmpeg version 4.2.2, I have these differences between my video player
library versions: 

*	The 3.2.2 version was created by cross compiling with the Zeranoe
build script (back when 3.2.2 was "new") after I added the USB/IP stream
dropping support to the source code
*	The 3.2.2 version is used as dlls, while the 4.2.2 libav libraries
are static builds, requiring no libav dlls by the final executable. 
*	The 4.2.2 version is created by native compiling using Visual
Studio's build tools via a Msys2 shell launched from a "VS2015 x64 Native
Tools Command Prompt" and this confiture line:

*	./configure --prefix="./ffmpeg_build"  --toolchain=msvc
--arch=x86_64 --target-os=win64 --extra-cflags=-MT --extra-cxxflags=-MT
--optflags=-O2 --enable-x86asm --enable-asm --enable-static --disable-shared
--disable-debug --enable-gpl --disable-w32threads
*	The "--optflags=-O2" Is an experiment to see if I get any faster
demux processing - it results in slightly different size for a few of the
libraries. But no noticeable difference other than that. 


Does anyone have any ideas why demuxing frames with the new version requires
so much more CPU? 

Is anyone seeing better performance from the 4.2 series than the 3.2 series?

Any ideas on this topic? 


Blake Senftner

Sr. Software Scientist | CyberExtruder

1401 Valley Road, Wayne, New Jersey 07470

cel: 213 400 6424 (pacific daylight savings timezone)

 <mailto:bsenftner at cyberextruder.com> bsenftner at cyberextruder.com


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20200511/b6189db7/attachment.html>

More information about the Libav-user mailing list