Skip to content

Commit

Permalink
Allow strings for variable names in ffmpeg encoder.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Feb 29, 2020
1 parent f8a9536 commit f51f080
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion doc/content/encoding_formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ The encoder should support all the options for `ffmpeg`'s [muxers](https://ffmpe
```liquidsoap
%ffmpeg(format="mpegts",
%audio(codec="ac3",channel_coupling=0),
%video(codec="libx264",b="2600k",preset="ultrafast"))
%video(codec="libx264",b="2600k",
"x264-params"="scenecut=0:open_gop=0:min-keyint=150:keyint=150",
preset="ultrafast"))
```

The full syntax is as follows:
Expand All @@ -161,6 +163,7 @@ Where:

* `<format>` is either a string value (e.g. `"mpegts"`), as returned by the `ffmpeg -formats` command or `none`. When set to `none` or simply no specified, the encoder will try to auto-detect it.
* `<codec>` is either a string value (e.g. `"libmp3lame"`), as returned by the `ffmpeg -codecs` command or `none`. When set to `none`, for audio, `channels` is set to `0` and, for either audio or video, the stream is assumed to have no such content.
* `<option_name>` can be any syntactically valid variable name or string. Strings are typically used when the option name is of the form: `foo-bar`.
* `%audio(..)` is for options specific to the audio codec. Unused options will raise an exception. Any option supported by `ffmpeg` can be passed here.
* `%video(..)` is for options specific to the video codec. Unused options will raise an exception. Any option supported by `ffmpeg` can be passed here.
* Generic options are passed to audio, video and format (container) setup. Unused options will raise an exception. Any option supported by `ffmpeg` can be passed here.
Expand Down
14 changes: 11 additions & 3 deletions src/lang/lang_parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,18 @@ ogg_item:
| FLAC app_opt { Lang_flac.make_ogg $2 }
| top_level_ogg_item { $1 }

ffmpeg_param:
| STRING GETS expr { $1,$3 }
| VAR GETS expr { $1,$3 }
ffmpeg_params:
| { [] }
| ffmpeg_param { [$1] }
| ffmpeg_param COMMA ffmpeg_params { $1::$3 }

ffmpeg_list_elem:
| AUDIO LPAR app_list RPAR { `Audio $3 }
| VIDEO LPAR app_list RPAR { `Video $3 }
| VAR GETS expr { `Option ($1,$3) }
| AUDIO LPAR ffmpeg_params RPAR { `Audio $3 }
| VIDEO LPAR ffmpeg_params RPAR { `Video $3 }
| ffmpeg_param { `Option $1 }
ffmpeg_list:
| { [] }
| ffmpeg_list_elem { [$1] }
Expand Down

0 comments on commit f51f080

Please sign in to comment.