Created
December 6, 2021 07:55
-
-
Save slhck/7ca145663f5898b2a9018106cc0b0d6a to your computer and use it in GitHub Desktop.
FFmpeg Filter Grammar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Work in progress! Does not handle escapes within filter arguments. | |
FilterGraph = | |
head: FilterChain | |
tail:(";" @FilterChain)* | |
{ return [head, ...tail]; } | |
FilterChain = | |
head: Filter | |
tail:("," @Filter)* | |
{ | |
return { | |
"filters": [head, ...tail], | |
} | |
} | |
Name = [a-zA-Z_0-9:]+ | |
FilterLabel = | |
_ "[" _ name:Name _ "]" _ | |
{ return name.join(""); } | |
FilterArg = | |
arg:[a-zA-Z1-9=]+ | |
{ return arg.join(""); } | |
FilterArgs = | |
head: FilterArg | |
tail:(":" @FilterArg)* | |
{ return [head, ...tail]; } | |
Filter = | |
inLabels:FilterLabel* | |
name:Name("@"Name)? // TODO capture ID | |
args:( | |
"=" | |
FilterArgs | |
)? | |
outLabels:FilterLabel* | |
{ | |
return { | |
"inLabels": inLabels, | |
"name": name.join(""), | |
"args": args === null ? [] : args[1], | |
"outLabels": inLabels, | |
}; | |
} | |
_ "whitespace" | |
= [ \t\n\r]* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment