[FFmpeg-user] Undefined or zero frame size in the loop, are cyclic filtergraphs ever usable?

Nikita Zlobin nick87720z at gmail.com
Mon Jan 24 20:57:49 EET 2022


This filter graph is expected to have loop, whose purpose is to
accumulate output from first graph part. Initial part has format of
1-column (1xH) image, while accumulator image has multiple columns.
Loop:
- Initial image is overlaid to right accumulator column,
- entire accumulator is shifted to left

However, it seems, now I don't even understand, how to set size for
accumulator. When I used blend filter instead of overlay (though it's
not right choice for sources with different size), source from loop had
0x0 size according to blend error output.

When I inserted scale, in hope to get right size before it's first used
as base, it itself was dissatisfied due to srcw and srch = 0.

When I replaced blend with overlay, it was ok with 0x0 frames, but than
other filters after split told about 0x0 frames.

There's my last attempt:

####################################
w=480; h=64
stdbuf -o0 yes | LANG=C stdbuf -o0 awk '{
    v = v + 0.01
    printf "%c", int((sin(v) + 1)/2 * 255)
}' \
| stdbuf -o0 ffmpeg -nostdin -v verbose \
-f rawvideo -pixel_format gray -video_size 1x1 -codec:v rawvideo -i - \
  -vf "
      scale at in = 1 : 255 : flags = neighbor,
      geq at bar = lum =' if( gt(Y, H - p(X,Y)), 80 ) ',
      scale at bar = 0 : $h
  [new];

  [accum_in]
      convolution = 1 0 0 : 0mode = row
  [accum_out];

  [accum_out] [new]
      overlay = W-1 : shortest = true,
      scale = $w : $h : flags = neighbor,
      split = 2
  [accum_in] [sink];

  [sink] scale at sink = flags = neighbor, format = gray
" -vcodec rawvideo -f rawvideo - \
| SDL_AUDIODRIVER=alsa ffplay -v quiet -s ${w}x${h} -pix_fmt gray
-vcodec rawvideo -f rawvideo -framerate 20000 -
####################################

Output:

####################################
Input #0, rawvideo, from 'pipe:':
  Duration: N/A, start: 0.000000, bitrate: 0 kb/s
  Stream #0:0: Video: rawvideo, 1 reference frame (Y800 / 0x30303859),
gray, 1x1, 0 kb/s, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
[scale at in @ 0x56062520d9a0] w:1 h:255 flags:'neighbor' interl:0
[scale at bar @ 0x560625283e40] w:0 h:64 flags:'bicubic' interl:0
[scale at sink @ 0x5606252857a0] w:iw h:ih flags:'neighbor' interl:0
[graph 0 input from stream 0:0 @ 0x560625285fb0] w:1 h:1 pixfmt:gray
tb:1/25 fr:25/1 sar:0/1
[Parsed_split_5 @ 0x560625284ba0] circular filter chain detected
[scale at in @ 0x56062520d9a0] w:1 h:1 fmt:gray sar:0/1 -> w:1 h:255
fmt:gray sar:0/1 flags:0x10
[scale at bar @ 0x560625283e40] w:1 h:255 fmt:gray sar:0/1 -> w:1 h:64
fmt:yuva420p sar:0/1 flags:0x4
[Parsed_overlay_4 @ 0x560625284cf0] main w:0 h:0 fmt:yuva420p overlay
w:1 h:64 fmt:yuva420p
[Parsed_overlay_4 @ 0x560625284cf0] [framesync @ 0x560625284dc8]
Selected 1/25 time base
[Parsed_overlay_4 @ 0x560625284cf0] [framesync @ 0x560625284dc8] Sync
level 2
[swscaler @ 0x5606252ae2d0] Value 0.000000 for parameter 'srcw' out of
range [1 - 2.14748e+09]
[swscaler @ 0x5606252ae2d0] Value 0.000000 for parameter 'srch' out of
range [1 - 2.14748e+09]
[swscaler @ 0x5606252ae2d0] Value 0.000000 for parameter 'dstw' out of
range [1 - 2.14748e+09]
[swscaler @ 0x5606252ae2d0] Value 0.000000 for parameter 'dsth' out of
range [1 - 2.14748e+09]
[scale at sink @ 0x5606252857a0] w:0 h:0 fmt:yuva420p sar:0/0 -> w:0 h:0
fmt:gray sar:0/0 flags:0x10
[Parsed_convolution_3 @ 0x5606252845d0] [IMGUTILS @ 0x7ffe3b0646c0]
Picture size 0x0 is invalid
Error reinitializing filters!
####################################

Btw, one good reason to use ffplay for display instead of ffmpeg cmd
ending with -f opengl, is that it allowes to do benchmarks by setting
unreachable framemates.

It only can run if I inserd ", nullsink, nullsrc = ${w}x${h}" after
convolver, so this really forces accumulator frame size for overlay,
though yet makes accumulator noop. However, it works - with given size
it makes 1670fps.

In comparison - version, where all history is fed by awk, with geq
forced to process all 480 columns, it only could do 70fps.

ffmpeg manual states, that cyclic graphs are possible. Well, at least
it doesn't refuse to proceed after "circular filter chain detected" :)

So, is there way to set accumulator size (after convolution) before it's
used in overlay? (just for overlay, before first loop iteration)


More information about the ffmpeg-user mailing list