| | 28 | Whilst a full filtergraph description can be complicated, it is possible to simplify it for simpler graphs provided ambiguity is avoided. |
| | 29 | |
| | 30 | Remembering that filters in a chain are separated by commas "." chains by a semicolon ";" and that if an input or output is not specified it is assumed to come from the preceding or sent to the following item in the chain. |
| | 31 | |
| | 32 | The following are equivalent:- |
| | 33 | {{{ |
| | 34 | ffmpeg -i input -vf [in]scale=iw/2:-1[out] output |
| | 35 | ffmpeg -i input -vf scale=iw/2:-1 output # the input and output are implied without ambiguity |
| | 36 | }}} |
| | 37 | |
| | 38 | As are:- |
| | 39 | {{{ |
| | 40 | ffmpeg -i input -vf [in]yadif=0:0:0[middle];[middle]scale=iw/2:-1[out] output # 2 chains form, one filter per chain, chains linked by the [middle] pad |
| | 41 | ffmpeg -i input -vf [in]yadif=0:0:0,scale=iw/2:-1[out] output # 1 chain form, with 2 filters in the chain, linking implied |
| | 42 | ffmpeg -i input -vf yadif=0:0:0,scale=iw/2:-1 output # the input and output are implied without ambiguity |
| | 43 | }}} |
| | 44 | |
| | 45 | === Escaping characters === |
| | 46 | As described in the documentation, it can be necessary to escape commas "," that need to appear in some arguments, for example the select filter:- |
| | 47 | {{{ |
| | 48 | ffmpeg -i input -vf select='eq(pict_type\,I)' output #to select only I frames |
| | 49 | }}} |
| | 50 | |
| | 51 | However an alternative, which also allows for white space within the filtergraph, and which may assist in clarity of reading complex graphs, is to enclose the whole filtergraph within double quotes " " thus:- |
| | 52 | {{{ |
| | 53 | ffmpeg -i input -vf "select=eq(pict_type,I)" output #to select only I frames |
| | 54 | ffmpeg -i input -vf "yadif=0:-1:0, scale=iw/2:-1" output # deinterlace then resize |
| | 55 | }}} |
| | 56 | Note that the examples given in the documentation mix and match the use of "full quoting" and "\" escaping, and that use of unusual shells may upset escaping. |