[FFmpeg-devel] Escaping from the escaping madness

Nicolas George nicolas.george at normalesup.org
Thu Nov 15 19:43:10 CET 2012


Le quintidi 25 brumaire, an CCXXI, Michael Niedermayer a écrit :
> Maybe we should make a list of typical cases where escaping is needed
> and then look at how they would look with alternatives.

If I take the example of the drawtext filter and the new expansion options I
am adding, which is probably one of the worst, that would look like that:

Format string:           %H:%M
Expansion function call: %{localtime:%H\:%M} or %{localtime:'%H:%M'}
drawtext argument:       text=%{lt\:%H\\\:%M} or text=%{lt\:\'%H\:%M}
filter graph:            dt=t=%{lt\\:%H\\\\\\:%M} or dt=t=%{lt\\:\\\'%H\\:%M}
command-line (shell):    'dt=t=%{lt\\:%H\\\\\\:%M}' or
                         "dt=t=%{lt\\\\:\\\\\\'%H\\\\:%M}"

Trying with balanced quotes:

Format string:           %H:%M
Expansion function call: %{localtime:“%H:%M”}
drawtext argument:       text=“%{localtime:“%H:%M”}”
filter graph:            drawtext=“text=“%{localtime:“%H:%M”}””
command-line (shell):    'drawtext=“text=“%{localtime:“%H:%M”}””'

Same with only ASCII, $[...] used for quoting:

Format string:           %H:%M
Expansion function call: %{localtime:$[%H:%M]}
drawtext argument:       text=$[%{localtime:$[%H:%M]}]
filter graph:            drawtext=$[text=$[%{localtime:$[%H:%M]}]]
command-line (shell):    'drawtext=$[text=$[%{localtime:$[%H:%M]}]]'

The version with “...” looks quite nice, but there are valid reason to want
to stick to "extended-ASCII".

The $[...] version is something I came up after my first mail. We could get
$ to recognize all pairs of balanced ASCII delimiters: $(...), $<...>,
$[...], ${...}: the user could choose whichever is less painful. If it is
only recognized for the whole string, it should not cause a lot of
backward-compatibility issues.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121115/72abf518/attachment.asc>


More information about the ffmpeg-devel mailing list