[Libav-user] Sendcmd command to change filter args during runtime is not understood when send from STDIN but is when send from zeromq

Martti desinformatsioon at gmail.com
Fri May 1 09:51:16 EEST 2020


I'm trying to change filter arguments (text value) during runtime with
sendcmd commands but I'm having trouble sendcmd and drawtext understanding
sent input. Same thing works when sent from zmq filter.

ffmpeg is started as:
```
ffmpeg -stdin -dumpgraph 1 -y -fflags nobuffer -f lavfi -re \
  -i
"testsrc=size=1280x720:rate=25[x];[x]drawtext=fontsize=30:text=hello:x=(w-text_w)/2:y=(h-text_h)/2"
\
  -an -c:v libx264 -r 25 -crf 30 -preset fast -pix_fmt yuv420p -flags +cgop
-g 50 \
  -f hls  -segment_list_flags live \
  -hls_flags delete_segments+append_list \
  -hls_time 2  \
  -hls_list_size 5  \
  -hls_delete_threshold 5  \
  -hls_wrap 5  \
  -hls_segment_filename /var/www/html/stream/%d.ts \
  /var/www/html/stream/index.m3u8
```

Filter that I want to change during runtime is `Parsed_drawtext_1`

So I press ```C``` and copy/paste into window ```Parsed_drawtext_1 -1
reinit text='test'```

and it instead of changing text displayed I see
```
Enter command: <target>|all <time>|-1 <command>[ <argument>]
Parsed_drawtext_1 -1 reinit text='test'^M
Command reply for stream 0: ret:-38 res:
```

So far looking at code I assume sendcmd finds filter and sends to drawtext
filter, but drawtext returns exit code 38 (not implemented)

What I'm doing wrong? This filter can be changed when I send with ZeroMq
`Parsed_drawtext_1 reinit text='test'` and ZeroMq filter uses pretty much
same code as sendcmd.


ffmpeg executable stdin handling:
https://github.com/FFmpeg/FFmpeg/blob/b577968cabae4a0927adcf5d7c24fca5a7a8385d/fftools/ffmpeg.c#L3942

sendcmd code:

1. find matching filter
https://github.com/FFmpeg/FFmpeg/blob/b577968cabae4a0927adcf5d7c24fca5a7a8385d/libavfilter/avfiltergraph.c#L1297
2. calls 'process_command' on filter
https://github.com/FFmpeg/FFmpeg/blob/b577968cabae4a0927adcf5d7c24fca5a7a8385d/libavfilter/avfilter.c#L555
3. drawtext command
https://github.com/FFmpeg/FFmpeg/blob/b577968cabae4a0927adcf5d7c24fca5a7a8385d/libavfilter/vf_drawtext.c#L877

vs
zmq filter code:
https://github.com/FFmpeg/FFmpeg/blob/master/libavfilter/f_zmq.c#L177


Full Program output:
```
user at user:~/$ ffmpeg -stdin -dumpgraph 1 -y -fflags nobuffer -f lavfi -re
-i
"testsrc=size=1280x720:rate=25[x];[x]drawtext=fontsize=30:text=hello:x=(w-text_w)/2:y=(h-text_h)/2"
  -an -c:v libx264 -r 25 -crf 30 -preset fast -pix_fmt yuv420p -flags +cgop
-g 50   -f hls  -segment_list_flags live   -hls_flags
delete_segments+append_list   -hls_time 2    -hls_list_size 5
 -hls_delete_threshold 5    -hls_wrap 5    -hls_segment_filename
/var/www/html/stream/%d.ts   /var/www/html/stream/index.m3u8
ffmpeg version 4.1.4-1build2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.2.1-4ubuntu1)
  configuration: --prefix=/usr --extra-version=1build2 --toolchain=hardened
--libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu
--arch=amd64 --enable-gpl --disable-stripping --enable-avresample
--disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa
--enable-libaom --enable-libass --enable-libbluray --enable-libbs2b
--enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame
--enable-libmysofa --enable-libopenjpeg --enable-libopenmpt
--enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband
--enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex
--enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp
--enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq
--enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl
--enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883
--enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[Parsed_drawtext_1 @ 0x55e4e3337e40] Using
"/usr/share/fonts/truetype/noto/NotoSans-Regular.ttf"
+------------------+
| Parsed_testsrc_0 |default--[1280x720 1:1 rgb24]--Parsed_drawtext_1:default
|    (testsrc)     |
+------------------+

                                                       +-------------------+
Parsed_testsrc_0:default--[1280x720 1:1 rgb24]--default| Parsed_drawtext_1
|default--[1280x720 1:1 rgb24]--out:default
                                                       |    (drawtext)     |
                                                       +-------------------+

                                                        +--------------+
Parsed_drawtext_1:default--[1280x720 1:1 rgb24]--default|     out      |
                                                        | (buffersink) |
                                                        +--------------+

Input #0, lavfi, from
'testsrc=size=1280x720:rate=25[x];[x]drawtext=fontsize=30:text=hello:x=(w-text_w)/2:y=(h-text_h)/2':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1280x720
[SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x55e4e33947c0] using SAR=1/1
[libx264 @ 0x55e4e33947c0] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55e4e33947c0] profile High, level 3.1
[libx264 @ 0x55e4e33947c0] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC
codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options:
cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 psy=1
psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1
cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=9
lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1
b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=50 keyint_min=5
scenecut=40 intra_refresh=0 rc_lookahead=30 rc=crf mbtree=1 crf=30.0
qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[hls @ 0x55e4e333d040] Opening '/var/www/html/stream/1.ts' for writing
Output #0, hls, to '/var/www/html/stream/index.m3u8':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (libx264), yuv420p, 1280x720 [SAR 1:1 DAR
16:9], q=-1--1, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.35.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=   63 fps= 25 q=35.0 size=N/A time=00:00:00.76 bitrate=N/A
speed=0.301x
Enter command: <target>|all <time>|-1 <command>[ <argument>]
Parsed_drawtext_1 -1 reinit text='test'^M
Command reply for stream 0: ret:-38 res:
[hls muxer @ 0x55e4e3399800] Duplicated segment filename detected:
1.ts0.204x
[hls @ 0x55e4e333d040] Opening '/var/www/html/stream/2.ts' for writing
[hls @ 0x55e4e333d040] Cannot use rename on non file protocol, this may
lead to races and temporary partial files
[hls muxer @ 0x55e4e3399800] Duplicated segment filename detected: 2.ts
[hls @ 0x55e4e333d040] Opening '/var/www/html/stream/3.ts' for writing
[hls muxer @ 0x55e4e3399800] Duplicated segment filename detected:
3.ts0.768x
[hls @ 0x55e4e333d040] Opening '/var/www/html/stream/4.ts' for writing
[hls muxer @ 0x55e4e3399800] Duplicated segment filename detected:
4.ts0.78x
[hls @ 0x55e4e333d040] Opening '/var/www/html/stream/0.ts' for writing
[hls muxer @ 0x55e4e3399800] Duplicated segment filename detected: 0.ts
frame=  209 fps= 25 q=-1.0 Lsize=N/A time=00:00:08.32 bitrate=N/A
speed=0.982x
video:106kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: unknown
[libx264 @ 0x55e4e33947c0] frame I:5     Avg QP:17.10  size:  6972
[libx264 @ 0x55e4e33947c0] frame P:54    Avg QP:21.75  size:   656
[libx264 @ 0x55e4e33947c0] frame B:150   Avg QP:22.64  size:   252
[libx264 @ 0x55e4e33947c0] consecutive B-frames:  4.3%  0.0%  0.0% 95.7%
[libx264 @ 0x55e4e33947c0] mb I  I16..4: 77.5% 18.6%  3.8%
[libx264 @ 0x55e4e33947c0] mb P  I16..4:  2.7%  0.3%  0.1%  P16..4:  5.5%
 0.2%  0.0%  0.0%  0.0%    skip:91.2%
[libx264 @ 0x55e4e33947c0] mb B  I16..4:  1.3%  0.2%  0.0%  B16..8:  1.1%
 0.0%  0.0%  direct: 0.8%  skip:96.7%  L0:49.6% L1:43.8% BI: 6.5%
[libx264 @ 0x55e4e33947c0] 8x8 transform intra:15.0% inter:77.8%
[libx264 @ 0x55e4e33947c0] coded y,uvDC,uvAC intra: 2.2% 18.6% 7.3% inter:
0.0% 1.0% 0.0%
[libx264 @ 0x55e4e33947c0] i16 v,h,dc,p: 84% 11%  2%  2%
[libx264 @ 0x55e4e33947c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 54% 13% 32%  0%
 0%  0%  0%  0%  0%
[libx264 @ 0x55e4e33947c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 30% 28%  3%
 2%  3%  0%  3%  0%
[libx264 @ 0x55e4e33947c0] i8c dc,h,v,p: 45% 12% 37%  6%
[libx264 @ 0x55e4e33947c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x55e4e33947c0] ref P L0: 47.7% 52.3%
[libx264 @ 0x55e4e33947c0] ref B L0: 60.3% 39.7%
[libx264 @ 0x55e4e33947c0] ref B L1: 90.8%  9.2%
[libx264 @ 0x55e4e33947c0] kb/s:103.41
Exiting normally, received signal 2.
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20200501/efd888e5/attachment.html>


More information about the Libav-user mailing list