[FFmpeg-devel] [PATCH 1/2] Audio Video Filtering using threads & semaphores

Manjunath Siddaiah msiddaiah at rgbnetworks.com
Tue Jun 19 18:53:11 CEST 2012


Hi,

The Audio/video decoded output pass through filter graph before proceeding to their respective encoders.

Since filters operates on raw input/output , filtering is computationally expensive.
And if we have multistep transcoding the filtering happens sequentially for all the steps , thereby decreasing the overall transcode performance.

So if we do filtering using threads for each step, thereby parallelizing the filtering for all the steps and increase the transcoder performance.
As decoder output goes to the filter, semaphores are posted for all the required filtering steps and
encoders waits on semaphore for the filtering job to complete to take it's input.

The changes are in 2 files:

1.       ffmpeg.c

2.       Configure: for configuring the build

For a sample ts file to file transcoding with and without threads shows the transcoder performance improvements for 8 steps. The input is 720p and output video is 480p for all the steps. So for all the steps required video scalar filter.

Command line:

time ./ffmpeg -threads 8 -loglevel fatal -y -i ./geiger720p.m2t -sws_flags bicubic -b 1500000 -s 720x480 -r 30.000  -bt 1500000 -vcodec mpeg2video -sc_threshold 50 -qmin 1 -qmax 51 -g 60 -keyint_min 6 -acodec mp2 -ab 128000 -ar 44100  -f mpegts /dev/null -sws_flags bicubic -b 1500000 -s 720x480 -r 30.000  -bt 1500000 -vcodec mpeg2video -sc_threshold 50 -qmin 1 -qmax 51 -g 60 -keyint_min 6 -acodec mp2 -ab 128000 -ar 44100  -f mpegts /dev/null -sws_flags bicubic -b 1500000 -s 720x480 -r 30.000  -bt 1500000 -vcodec mpeg2video -sc_threshold 50 -qmin 1 -qmax 51 -g 60 -keyint_min 6 -acodec mp2 -ab 128000 -ar 44100  -f mpegts /dev/null -sws_flags bicubic -b 1500000 -s 720x480 -r 30.000  -bt 1500000 -vcodec mpeg2video -sc_threshold 50 -qmin 1 -qmax 51 -g 60 -keyint_min 6 -acodec mp2 -ab 128000 -ar 44100  -f mpegts /dev/null -sws_flags bicubic -b 1500000 -s 720x480 -r 30.000  -bt 1500000 -vcodec mpeg2video -sc_threshold 50 -qmin 1 -qmax 51 -g 60 -keyint_min 6 -acodec mp2 -ab 128000 -ar 44100  -f mpegts /dev/null -sws_flags bicubic -b 1500000 -s 720x480 -r 30.000  -bt 1500000 -vcodec mpeg2video -sc_threshold 50 -qmin 1 -qmax 51 -g 60 -keyint_min 6 -acodec mp2 -ab 128000 -ar 44100  -f mpegts /dev/null -sws_flags bicubic -b 1500000 -s 720x480 -r 30.000  -bt 1500000 -vcodec mpeg2video -sc_threshold 50 -qmin 1 -qmax 51 -g 60 -keyint_min 6 -acodec mp2 -ab 128000 -ar 44100  -f mpegts /dev/null -sws_flags bicubic -b 1500000 -s 720x480 -r 30.000  -bt 1500000 -vcodec mpeg2video -sc_threshold 50 -qmin 1 -qmax 51 -g 60 -keyint_min 6 -acodec mp2 -ab 128000 -ar 44100  -f mpegts /dev/null

without threads:
real time : 5m28.182s
fps            : 28

with threads:
real time : 2m52.623s
fps            : 53

Tested enough to see that, there are no problems using threading for filtering job.

Manjunath
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: avfilter_threads1.txt
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120619/01ef3111/attachment.txt>


More information about the ffmpeg-devel mailing list