| | 189 | == Scripting Filters from a File == |
| | 190 | |
| | 191 | Suppose you want to change some filter parameters based on an input file. Some filters support the option to receive commands via [https://ffmpeg.org/ffmpeg-filters.html#sendcmd_002c-asendcmd `sendcmd`]. Run `ffmpeg -filters` and check the `C` column – if it is present, a filter supports receiving input this way. |
| | 192 | |
| | 193 | For example, if you want to rotate the input at seconds 0, 1, and 2, create a file called `cmd.txt` with the content: |
| | 194 | |
| | 195 | {{{ |
| | 196 | 0 rotate angle '45*PI/180'; |
| | 197 | 1 rotate angle '90*PI/180'; |
| | 198 | 2 rotate angle '180*PI/180'; |
| | 199 | }}} |
| | 200 | |
| | 201 | Now run an example stream: |
| | 202 | |
| | 203 | {{{ |
| | 204 | ffmpeg -f lavfi -i testsrc -filter_complex "[0:v]sendcmd=f=cmd.txt,rotate" -f matroska - | ffplay - |
| | 205 | }}} |
| | 206 | |
| | 207 | Some examples of this technique can be seen [https://stackoverflow.com/a/49600924/435093 here]. |
| | 208 | |