[FFmpeg-user] drawbox: text subpixel rendering (IO bootleneck)

Nikita Zlobin nick87720z at gmail.com
Tue Jan 25 02:58:04 EET 2022

I managed to get it working with overlay, using tee & named fifo.

In first attempt I had two ffmpeg instance:
1 - creating new image, merging with accumulator image and sending to
tee, which makes split job, redirecting it to second ffmpeg.
2 - takes output from ffmpeg-1 and shifts, preparing for new merge, and
feeds it to fifo, where ffmpeg-1 reads it again. But before ffmpeg-2
starts, ffmpeg-1 is seeded by null "starter" frame, generated by awk, so
that loop can start (I tried - it will not without initial seed).

That was able to reach 1150 fps.

I expected, that doing all job in one ffmpeg would give better speed.
Actual ffmpeg command:

stdbuf -o0 ffmpeg -nostdin -v verbose \
  -vcodec rawvideo -f rawvideo -pix_fmt gray -s 1x1    -i pipe:0 \
  -vcodec rawvideo -f rawvideo -pix_fmt gray -s ${w}x${h}        \
  -i "${loop_src}" -filter_complex "
      scale = iw : 128 : flags = neighbor,
      geq = lum='
        if( gt(Y, H - p(X,Y) * H / 255 ),
      scale = iw : $h : flags = bicubic,
      format = gray
      convolution = 0 0 1 : 0mode = row,
      format = gray
  [acc_out] [new]
      overlay = W-1 : 0,
      format = gray
" -vcodec rawvideo -f rawvideo - | stdbuf -o0 tee "${loop_src}"

and seed command:

stdbuf -o0 awk 'BEGIN { 
  for (i = 0; i < ('$w'*'$h'); i++)
    printf "\0"
}' > "${loop_src}" &

(as for loop_sink - it was used for second loop).

But instead - strange bootleneck appeared, keeping fps between 200 and
100. However, it's not cpu load - I can barely notice it. Suspecting IO
problem. At least during start - visible graphic movement speed
erratically increased, but otherwise was constrained.

I tried to change stdbuf -o to have buffer with size just to
hold output frame, but it did not make a difference.

Is it possible to reduce it without second ffmpeg instance?

More information about the ffmpeg-user mailing list