# 1. Syntax

This section documents the syntax and formats employed by the FFmpeg libraries and tools.

## 1.1 Quoting and escaping

FFmpeg adopts the following quoting and escaping mechanism, unless explicitly specified. The following rules are applied:

- `'` and `\` are special characters (respectively used for quoting and escaping). In addition to them, there might be other special characters depending on the specific syntax where the escaping and quoting are employed.
- A special character is escaped by prefixing it with a ’\’.
- All characters enclosed between ” are included literally in the parsed string. The quote character `'` itself cannot be quoted, so you may need to close the quote and escape it.
- Leading and trailing whitespaces, unless escaped or quoted, are removed from the parsed string.

Note that you may need to add a second level of escaping when using the command line or a script, which depends on the syntax of the adopted shell language.

The function `av_get_token` defined in ‘`libavutil/avstring.h`’ can be used to parse a token quoted or escaped according to the rules defined above.

The tool ‘`tools/ffescape`’ in the FFmpeg source tree can be used to automatically quote or escape a string in a script.

### 1.1.1 Examples

- Escape the string `Crime d'Amour` containing the `'` special character:

      Crime d\'Amour

- The string above contains a quote, so the `'` needs to be escaped when quoting it:

      'Crime d'\''Amour'

- Include leading or trailing whitespaces using quoting:

      '  this string starts and ends with whitespaces  '

- Escaping and quoting can be mixed together:

      ' The string '\'string\'' is a string '

- To include a literal `\` you can use either escaping or quoting:

      'c:\foo' can be written as c:\\foo

## 1.2 Date

The accepted syntax is:

    [(YYYY-MM-DD|YYYYMMDD)[T|t| ]]((HH:MM:SS[.m...]]])|(HHMMSS[.m...]]]))[Z]
    now

If the value is "now" it takes the current time.

Time is local time unless Z is appended, in which case it is interpreted as UTC. If the year-month-day part is not specified it takes the current year-month-day.

## 1.3 Time duration

The accepted syntax is:

    [-]HH:MM:SS[.m...]
    [-]S+[.m...]

HH expresses the number of hours, MM the number a of minutes and SS the number of seconds.

## 1.4 Video size

Specify the size of the sourced video, it may be a string of the form widthxheight, or the name of a size abbreviation.

The following abbreviations are recognized:

‘`sqcif`’

  128x96

‘`qcif`’

  176x144

‘`cif`’

  352x288

‘`4cif`’

  704x576

‘`16cif`’

  1408x1152

‘`qqvga`’

  160x120

‘`qvga`’

  320x240

‘`vga`’

  640x480

‘`svga`’

  800x600

‘`xga`’

  1024x768

‘`uxga`’

  1600x1200

‘`qxga`’

  2048x1536

‘`sxga`’

  1280x1024

‘`qsxga`’

  2560x2048

‘`hsxga`’

  5120x4096

‘`wvga`’

  852x480

‘`wxga`’

  1366x768

‘`wsxga`’

  1600x1024

‘`wuxga`’

  1920x1200

‘`woxga`’

  2560x1600

‘`wqsxga`’

  3200x2048

‘`wquxga`’

  3840x2400

‘`whsxga`’

  6400x4096

‘`whuxga`’

  7680x4800

‘`cga`’

  320x200

‘`ega`’

  640x350

‘`hd480`’

  852x480

‘`hd720`’

  1280x720

‘`hd1080`’

  1920x1080

## 1.5 Video rate

Specify the frame rate of a video, expressed as the number of frames generated per second. It has to be a string in the format frame_rate_num/frame_rate_den, an integer number, a float number or a valid video frame rate abbreviation.

The following abbreviations are recognized:

‘`ntsc`’

  30000/1001

‘`pal`’

  25/1

‘`qntsc`’

  30000/1

‘`qpal`’

  25/1

‘`sntsc`’

  30000/1

‘`spal`’

  25/1

‘`film`’

  24/1

‘`ntsc-film`’

  24000/1

## 1.6 Ratio

A ratio can be expressed as an expression, or in the form numerator:denominator.

Note that a ratio with infinite (1/0) or negative value is considered valid, so you should check on the returned value if you want to exclude those values.

The undefined value can be expressed using the "0:0" string.

## 1.7 Color

It can be the name of a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence, possibly followed by "@" and a string representing the alpha component.

The alpha component may be a string composed by "0x" followed by an hexadecimal number or a decimal number between 0.0 and 1.0, which represents the opacity value (0x00/0.0 means completely transparent, 0xff/1.0 completely opaque). If the alpha component is not specified then 0xff is assumed.

The string "random" will result in a random color.