[FFmpeg-user] Any way to get better use of the cpu?

Roger Pack rogerdpack2 at gmail.com
Sat Jan 30 01:46:01 CET 2016


Hello.
I'm attempting to decode and "re encode" live TV.
I noticed that when I attempt to transcode say, 6 streams at a time,
ffmpeg seems to end up using "at most" 50% of the cpu available on the
given box.

The basic syntax I'm using is

ffmpeg -i input.ts -map 0:p:1344 1344.mp4 -map 0:p:1345 1345.mp4 -map
0:p:1346 1346.mp4

So multiple outputs that come from different parts of the same input
(it's not a file, its a live TS capture in this particular case).

I've noticed that the speed indicator ends up, in my instance, saying
something like

frame=  696 fps= 16 q=-1.0 Lq=-1.0 q=-1.0 q=-1.0 q=-1.0 q=-1.0 q=-1.0
size=N/A time=00:00:27.84 bitrate=N/A dup=217 drop=0 speed=0.645x

(full command line and somewhat cleaned up console output:
https://gist.github.com/rdp/51448985bfa48a1f72a2 )

However, if I look at cpu utilization, it hovers right around 50%
consistently (two cores out of 4 basically), regardless of "-threads"
setting applied.

I'm able to capture the incoming stream "fast enough" (for instance,
if I only transocde a few substreams, everything comes in fine, speed
keeps up), and if I test "decode only" (all streams), it handles it
fine speed=3.5x.

Is there any tricks to get more cpu "utilization" here or is this more
of something to be implemented in a google summer of code or what not
(assuming some speedup is possible)?

In trying to create a reproducible sample, I came up with this (not
sure if its the same problem or not):

https://trac.ffmpeg.org/raw-attachment/ticket/3025/sbs.2.5M.ts

run this, you'll see that it uses around 200% cpu regardless of cores available:

./ffmpeg_g -ignore_unknown -y -i <(while cat sbs.2.5M.ts; do :; done)
  -map 0:p:817 -c:v libx264 -preset ultrafast -sn 817.mp4   -map
0:p:818 -c:v libx264 -preset ultrafast -sn 818.mp4   -map 0:p:820 -c:v
libx264 -preset ultrafast -sn 820.mp4  -map 0:p:821 -c:v libx264
-preset ultrafast -qp 0 -sn 821.mp4    -map 0:p:830 -c:v libx264
-preset ultrafast -sn 830.mp4  -map 0:p:832 -c:v libx264 -preset
ultrafast -qp 0 -sn 832.mp4  -map 0:p:819 -c:v libx264 -preset
ultrafast -qp 0 -sn 819.mp4   -ignore_unknown -loglevel info

Here's a smaller example, possibly related, uses 600% (out of 800%) on
a different box:

./ffmpeg -i <(while cat sbs.2.5M.ts; do :; done) -map p:817 -y -sn
817.mp4 -ignore_unknown

Any theories out there as to why it ends up using just 200% cpu? Or
any ideas/workarounds to be able to transcode multiple at the same
time from the same source and use all the cpu available?

Thanks!
-roger-


More information about the ffmpeg-user mailing list