#3253(avfilter:new): drawtext filter: problems with text expansions
#3253: drawtext filter: problems with text expansions ----------------------------------+--------------------------------------- Reporter: Krieger | Type: defect Status: new | Priority: normal Component: avfilter | Version: unspecified Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ----------------------------------+--------------------------------------- Summary of the bug: Text expansion seem to be not working. How to reproduce: {{{ $ ffmpeg -re -f lavfi -i testsrc -filter:v 'drawtext=text=%{expr:t}:fontfile=/usr/share/fonts/corefonts/verdana.ttf:fontsize=50:fontcolor=red' -y ~/netdisk/tmp/tmp.ts ffmpeg version N-59414-g8a0d446 Copyright (c) 2000-2013 the FFmpeg developers built on Dec 29 2013 16:17:21 with gcc 4.6.3 (Gentoo 4.6.3 p1.13, pie-0.5.2) configuration: --enable-gpl --enable-libx264 --enable-encoder=libx264 --disable-stripping --enable-debug --extra-cflags='-O0 -g -ggdb' --enable- libopus --enable-libvpx --enable-x11grab --enable-libfreetype --enable- filter=drawtext libavutil 52. 59.100 / 52. 59.100 libavcodec 55. 47.100 / 55. 47.100 libavformat 55. 22.100 / 55. 22.100 libavdevice 55. 5.102 / 55. 5.102 libavfilter 4. 0.103 / 4. 0.103 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 Input #0, lavfi, from 'testsrc': Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc Output #0, mpegts, to '/home/krieger/netdisk/tmp/tmp.ts': Metadata: encoder : Lavf55.22.100 Stream #0:0: Video: mpeg2video, yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 25 tbc Stream mapping: Stream #0:0 -> #0:0 (rawvideo -> mpeg2video) Press [q] to stop, [?] for help frame= 35 fps= 26 q=2.0 Lsize= 75kB time=00:00:01.36 bitrate= 451.2kbits/s video:65kB audio:0kB subtitle:0 global headers:0kB muxing overhead 15.131411% Received signal 2: terminating. }}} The desired effect is printing of timestamp in seconds (see t variable in drawtext doc section). This way we have printed text "t}", which is nonsense. If we swap the order of filter params "text" and "fontfile", it fails to start. Tried both escaping and not escaping semicolon in expansion block. {{{ $ ffmpeg -re -f lavfi -i testsrc -filter:v 'drawtext=fontfile=/usr/share/fonts/corefonts/verdana.ttf:text=%{e: t}:fontsize=50:fontcolor=red' -y ~/netdisk/tmp/tmp.ts ffmpeg version N-59414-g8a0d446 Copyright (c) 2000-2013 the FFmpeg developers built on Dec 29 2013 16:17:21 with gcc 4.6.3 (Gentoo 4.6.3 p1.13, pie-0.5.2) configuration: --enable-gpl --enable-libx264 --enable-encoder=libx264 --disable-stripping --enable-debug --extra-cflags='-O0 -g -ggdb' --enable- libopus --enable-libvpx --enable-x11grab --enable-libfreetype --enable- filter=drawtext libavutil 52. 59.100 / 52. 59.100 libavcodec 55. 47.100 / 55. 47.100 libavformat 55. 22.100 / 55. 22.100 libavdevice 55. 5.102 / 55. 5.102 libavfilter 4. 0.103 / 4. 0.103 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 Input #0, lavfi, from 'testsrc': Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc [Parsed_drawtext_0 @ 0x24cd8a0] Could not load font "t}": cannot open resource [AVFilterGraph @ 0x24d47e0] Error initializing filter 'drawtext' with args 'fontfile=/usr/share/fonts/corefonts/verdana.ttf:text=%{e: t}:fontsize=50:fontcolor=red' Error opening filters! [ERR] 16:56:12krieger@zver /usr/local/src/ffmpeg $ ffmpeg -re -f lavfi -i testsrc -filter:v 'drawtext=fontfile=/usr/share/fonts/corefonts/verdana.ttf:text=%{e\: t}:fontsize=50:fontcolor=red' -y ~/netdisk/tmp/tmp.ts ffmpeg version N-59414-g8a0d446 Copyright (c) 2000-2013 the FFmpeg developers built on Dec 29 2013 16:17:21 with gcc 4.6.3 (Gentoo 4.6.3 p1.13, pie-0.5.2) configuration: --enable-gpl --enable-libx264 --enable-encoder=libx264 --disable-stripping --enable-debug --extra-cflags='-O0 -g -ggdb' --enable- libopus --enable-libvpx --enable-x11grab --enable-libfreetype --enable- filter=drawtext libavutil 52. 59.100 / 52. 59.100 libavcodec 55. 47.100 / 55. 47.100 libavformat 55. 22.100 / 55. 22.100 libavdevice 55. 5.102 / 55. 5.102 libavfilter 4. 0.103 / 4. 0.103 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 Input #0, lavfi, from 'testsrc': Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc [Parsed_drawtext_0 @ 0x1dc28a0] Could not load font "t}": cannot open resource [AVFilterGraph @ 0x1dc97e0] Error initializing filter 'drawtext' with args 'fontfile=/usr/share/fonts/corefonts/verdana.ttf:text=%{e: t}:fontsize=50:fontcolor=red' Error opening filters! [ERR] }}} -- Ticket URL: <https://trac.ffmpeg.org/ticket/3253> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3253: drawtext filter: problems with text expansions -------------------------------------+------------------------------------ Reporter: Krieger | Owner: Type: defect | Status: new Priority: normal | Component: avfilter Version: unspecified | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------ Comment (by Krieger): The example from documentation does not work, too: {{{ text=%{localtime:%a %b %d %Y} }}} -- Ticket URL: <https://trac.ffmpeg.org/ticket/3253#comment:1> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3253: drawtext filter: problems with text expansions -------------------------------------+------------------------------------ Reporter: Krieger | Owner: Type: defect | Status: new Priority: normal | Component: avfilter Version: unspecified | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------ Comment (by Cigaes): You probably need to escape the {{{:}}} used in the expansion, to prevent it from delimiting options. Not getting an error is strange though. -- Ticket URL: <https://trac.ffmpeg.org/ticket/3253#comment:2> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
You probably need to escape the {{{:}}} used in the expansion, to
#3253: drawtext filter: problems with text expansions -------------------------------------+------------------------------------ Reporter: Krieger | Owner: Type: defect | Status: new Priority: normal | Component: avfilter Version: unspecified | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------ Comment (by Krieger): Replying to [comment:2 Cigaes]: prevent it from delimiting options. Not getting an error is strange though. text=%{expr\:t} works same way and prints "t}". -- Ticket URL: <https://trac.ffmpeg.org/ticket/3253#comment:3> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
Replying to [comment:2 Cigaes]:
You probably need to escape the {{{:}}} used in the expansion, to
#3253: drawtext filter: problems with text expansions -------------------------------------+------------------------------------ Reporter: Krieger | Owner: Type: defect | Status: new Priority: normal | Component: avfilter Version: unspecified | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 0 | -------------------------------------+------------------------------------ Changes (by beastd): * reproduced: 0 => 1 Comment: Replying to [comment:3 Krieger]: prevent it from delimiting options. Not getting an error is strange though.
text=%{expr\:t} works same way and prints "t}".
I cannot exactly explain how all this works together, but it seems that you need to deal with another layer of escaping or in other words add another \ . Then it works as expected here. -- Ticket URL: <https://trac.ffmpeg.org/ticket/3253#comment:4> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3253: drawtext filter: problems with text expansions -------------------------------------+------------------------------------ Reporter: Krieger | Owner: Type: defect | Status: new Priority: normal | Component: avfilter Version: unspecified | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 0 | -------------------------------------+------------------------------------ Comment (by Krieger): Replying to [comment:4 beastd]:
I cannot exactly explain how all this works together, but it seems that you need to deal with another layer of escaping or in other words add another \ . Then it works as expected here.
Share the full working command line, please. -- Ticket URL: <https://trac.ffmpeg.org/ticket/3253#comment:5> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
Replying to [comment:4 beastd]:
I cannot exactly explain how all this works together, but it seems
#3253: drawtext filter: problems with text expansions -------------------------------------+------------------------------------ Reporter: Krieger | Owner: Type: defect | Status: new Priority: normal | Component: avfilter Version: unspecified | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 0 | -------------------------------------+------------------------------------ Comment (by beastd): Replying to [comment:5 Krieger]: that you need to deal with another layer of escaping or in other words add another \ . Then it works as expected here.
Share the full working command line, please.
{{{ ./ffmpeg -re -f lavfi -i testsrc -filter:v 'drawtext=text=%{expr\\:t}:fontfile=/usr/share/fonts/TTF/DejaVuSans.ttf:fontsize=50:fontcolor=red' -y tmp.ts }}} -- Ticket URL: <https://trac.ffmpeg.org/ticket/3253#comment:6> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3253: drawtext filter: problems with text expansions -------------------------------------+------------------------------------ Reporter: Krieger | Owner: Type: defect | Status: new Priority: normal | Component: avfilter Version: unspecified | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 0 | -------------------------------------+------------------------------------ Comment (by Cigaes): Replying to [comment:4 beastd]:
I cannot exactly explain how all this works together, but it seems that you need to deal with another layer of escaping or in other words add another \ . Then it works as expected here.
You escape once for the {{{drawtext=...}}} option and the parsing until the comma, and a second time for the {{{text=...}}} value and the parsing until the colon before fontfile. -- Ticket URL: <https://trac.ffmpeg.org/ticket/3253#comment:7> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
Replying to [comment:4 beastd]:
I cannot exactly explain how all this works together, but it seems
#3253: drawtext filter: problems with text expansions -------------------------------------+------------------------------------ Reporter: Krieger | Owner: Type: defect | Status: closed Priority: normal | Component: avfilter Version: unspecified | Resolution: Keywords: | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 0 | -------------------------------------+------------------------------------ Changes (by beastd): * status: new => closed Comment: Replying to [comment:7 Cigaes]: that you need to deal with another layer of escaping or in other words add another \ . Then it works as expected here.
You escape once for the {{{drawtext=...}}} option and the parsing until
the comma, and a second time for the {{{text=...}}} value and the parsing until the colon before fontfile. Yes, that should be correct. So it can be concluded that drawtext function evaluation has nothing to do with this. To examine this exact example: The single quotes take the shell out of the game (assuming you use a POSIX-ish shell; I do). So I will omit them and the additional parameters below. Now we have this: {{{ drawtext=text=%{expr:t}, }}} It won't work because the drawtext filter's arguments are parsed and the colon will be seen as delimiter. {{{ drawtext=text=%{expr\:t}, }}} This looks like it would do the trick and escape the colon, but it fails because the backslash is removed on the first pass. The second pass again interprets the colon as a delimiter and things go wrong. {{{ drawtext=text=%{expr\\:t}, }}} works because at the first pass the double backslash is substituted with a single backslash and that single backslash escapes the colon on the second pass which parses the drawtext filter's arguments. Therefore I close this ticket now. Please re-open if suggested solution does not work for you. -- Ticket URL: <https://trac.ffmpeg.org/ticket/3253#comment:8> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#3253: drawtext filter: problems with text expansions -------------------------------------+------------------------------------ Reporter: Krieger | Owner: Type: defect | Status: closed Priority: normal | Component: avfilter Version: unspecified | Resolution: invalid Keywords: | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 0 | -------------------------------------+------------------------------------ Changes (by cehoyos): * resolution: => invalid -- Ticket URL: <https://trac.ffmpeg.org/ticket/3253#comment:9> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
participants (1)
-
FFmpeg