You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

633 lines
15KB

  1. @chapter Syntax
  2. @c man begin SYNTAX
  3. This section documents the syntax and formats employed by the FFmpeg
  4. libraries and tools.
  5. @anchor{quoting_and_escaping}
  6. @section Quoting and escaping
  7. FFmpeg adopts the following quoting and escaping mechanism, unless
  8. explicitly specified. The following rules are applied:
  9. @itemize
  10. @item
  11. @code{'} and @code{\} are special characters (respectively used for
  12. quoting and escaping). In addition to them, there might be other
  13. special characters depending on the specific syntax where the escaping
  14. and quoting are employed.
  15. @item
  16. A special character is escaped by prefixing it with a '\'.
  17. @item
  18. All characters enclosed between '' are included literally in the
  19. parsed string. The quote character @code{'} itself cannot be quoted,
  20. so you may need to close the quote and escape it.
  21. @item
  22. Leading and trailing whitespaces, unless escaped or quoted, are
  23. removed from the parsed string.
  24. @end itemize
  25. Note that you may need to add a second level of escaping when using
  26. the command line or a script, which depends on the syntax of the
  27. adopted shell language.
  28. The function @code{av_get_token} defined in
  29. @file{libavutil/avstring.h} can be used to parse a token quoted or
  30. escaped according to the rules defined above.
  31. The tool @file{tools/ffescape} in the FFmpeg source tree can be used
  32. to automatically quote or escape a string in a script.
  33. @subsection Examples
  34. @itemize
  35. @item
  36. Escape the string @code{Crime d'Amour} containing the @code{'} special
  37. character:
  38. @example
  39. Crime d\'Amour
  40. @end example
  41. @item
  42. The string above contains a quote, so the @code{'} needs to be escaped
  43. when quoting it:
  44. @example
  45. 'Crime d'\''Amour'
  46. @end example
  47. @item
  48. Include leading or trailing whitespaces using quoting:
  49. @example
  50. ' this string starts and ends with whitespaces '
  51. @end example
  52. @item
  53. Escaping and quoting can be mixed together:
  54. @example
  55. ' The string '\'string\'' is a string '
  56. @end example
  57. @item
  58. To include a literal @code{\} you can use either escaping or quoting:
  59. @example
  60. 'c:\foo' can be written as c:\\foo
  61. @end example
  62. @end itemize
  63. @anchor{date syntax}
  64. @section Date
  65. The accepted syntax is:
  66. @example
  67. [(YYYY-MM-DD|YYYYMMDD)[T|t| ]]((HH:MM:SS[.m...]]])|(HHMMSS[.m...]]]))[Z]
  68. now
  69. @end example
  70. If the value is "now" it takes the current time.
  71. Time is local time unless Z is appended, in which case it is
  72. interpreted as UTC.
  73. If the year-month-day part is not specified it takes the current
  74. year-month-day.
  75. @anchor{time duration syntax}
  76. @section Time duration
  77. There are two accepted syntaxes for expressing time duration.
  78. @example
  79. [-][@var{HH}:]@var{MM}:@var{SS}[.@var{m}...]
  80. @end example
  81. @var{HH} expresses the number of hours, @var{MM} the number of minutes
  82. for a maximum of 2 digits, and @var{SS} the number of seconds for a
  83. maximum of 2 digits. The @var{m} at the end expresses decimal value for
  84. @var{SS}.
  85. @emph{or}
  86. @example
  87. [-]@var{S}+[.@var{m}...]
  88. @end example
  89. @var{S} expresses the number of seconds, with the optional decimal part
  90. @var{m}.
  91. In both expressions, the optional @samp{-} indicates negative duration.
  92. @subsection Examples
  93. The following examples are all valid time duration:
  94. @table @samp
  95. @item 55
  96. 55 seconds
  97. @item 12:03:45
  98. 12 hours, 03 minutes and 45 seconds
  99. @item 23.189
  100. 23.189 seconds
  101. @end table
  102. @anchor{video size syntax}
  103. @section Video size
  104. Specify the size of the sourced video, it may be a string of the form
  105. @var{width}x@var{height}, or the name of a size abbreviation.
  106. The following abbreviations are recognized:
  107. @table @samp
  108. @item ntsc
  109. 720x480
  110. @item pal
  111. 720x576
  112. @item qntsc
  113. 352x240
  114. @item qpal
  115. 352x288
  116. @item sntsc
  117. 640x480
  118. @item spal
  119. 768x576
  120. @item film
  121. 352x240
  122. @item ntsc-film
  123. 352x240
  124. @item sqcif
  125. 128x96
  126. @item qcif
  127. 176x144
  128. @item cif
  129. 352x288
  130. @item 4cif
  131. 704x576
  132. @item 16cif
  133. 1408x1152
  134. @item qqvga
  135. 160x120
  136. @item qvga
  137. 320x240
  138. @item vga
  139. 640x480
  140. @item svga
  141. 800x600
  142. @item xga
  143. 1024x768
  144. @item uxga
  145. 1600x1200
  146. @item qxga
  147. 2048x1536
  148. @item sxga
  149. 1280x1024
  150. @item qsxga
  151. 2560x2048
  152. @item hsxga
  153. 5120x4096
  154. @item wvga
  155. 852x480
  156. @item wxga
  157. 1366x768
  158. @item wsxga
  159. 1600x1024
  160. @item wuxga
  161. 1920x1200
  162. @item woxga
  163. 2560x1600
  164. @item wqsxga
  165. 3200x2048
  166. @item wquxga
  167. 3840x2400
  168. @item whsxga
  169. 6400x4096
  170. @item whuxga
  171. 7680x4800
  172. @item cga
  173. 320x200
  174. @item ega
  175. 640x350
  176. @item hd480
  177. 852x480
  178. @item hd720
  179. 1280x720
  180. @item hd1080
  181. 1920x1080
  182. @item 2k
  183. 2048x1080
  184. @item 2kflat
  185. 1998x1080
  186. @item 2kscope
  187. 2048x858
  188. @item 4k
  189. 4096x2160
  190. @item 4kflat
  191. 3996x2160
  192. @item 4kscope
  193. 4096x1716
  194. @item nhd
  195. 640x360
  196. @item hqvga
  197. 240x160
  198. @item wqvga
  199. 400x240
  200. @item fwqvga
  201. 432x240
  202. @item hvga
  203. 480x320
  204. @item qhd
  205. 960x540
  206. @end table
  207. @anchor{video rate syntax}
  208. @section Video rate
  209. Specify the frame rate of a video, expressed as the number of frames
  210. generated per second. It has to be a string in the format
  211. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  212. number or a valid video frame rate abbreviation.
  213. The following abbreviations are recognized:
  214. @table @samp
  215. @item ntsc
  216. 30000/1001
  217. @item pal
  218. 25/1
  219. @item qntsc
  220. 30000/1001
  221. @item qpal
  222. 25/1
  223. @item sntsc
  224. 30000/1001
  225. @item spal
  226. 25/1
  227. @item film
  228. 24/1
  229. @item ntsc-film
  230. 24000/1001
  231. @end table
  232. @anchor{ratio syntax}
  233. @section Ratio
  234. A ratio can be expressed as an expression, or in the form
  235. @var{numerator}:@var{denominator}.
  236. Note that a ratio with infinite (1/0) or negative value is
  237. considered valid, so you should check on the returned value if you
  238. want to exclude those values.
  239. The undefined value can be expressed using the "0:0" string.
  240. @anchor{color syntax}
  241. @section Color
  242. It can be the name of a color (case insensitive match) or a
  243. [0x|#]RRGGBB[AA] sequence, possibly followed by "@@" and a string
  244. representing the alpha component.
  245. The alpha component may be a string composed by "0x" followed by an
  246. hexadecimal number or a decimal number between 0.0 and 1.0, which
  247. represents the opacity value (0x00/0.0 means completely transparent,
  248. 0xff/1.0 completely opaque).
  249. If the alpha component is not specified then 0xff is assumed.
  250. The string "random" will result in a random color.
  251. @c man end SYNTAX
  252. @chapter Expression Evaluation
  253. @c man begin EXPRESSION EVALUATION
  254. When evaluating an arithmetic expression, FFmpeg uses an internal
  255. formula evaluator, implemented through the @file{libavutil/eval.h}
  256. interface.
  257. An expression may contain unary, binary operators, constants, and
  258. functions.
  259. Two expressions @var{expr1} and @var{expr2} can be combined to form
  260. another expression "@var{expr1};@var{expr2}".
  261. @var{expr1} and @var{expr2} are evaluated in turn, and the new
  262. expression evaluates to the value of @var{expr2}.
  263. The following binary operators are available: @code{+}, @code{-},
  264. @code{*}, @code{/}, @code{^}.
  265. The following unary operators are available: @code{+}, @code{-}.
  266. The following functions are available:
  267. @table @option
  268. @item abs(x)
  269. Compute absolute value of @var{x}.
  270. @item acos(x)
  271. Compute arccosine of @var{x}.
  272. @item asin(x)
  273. Compute arcsine of @var{x}.
  274. @item atan(x)
  275. Compute arctangent of @var{x}.
  276. @item between(x, min, max)
  277. Return 1 if @var{x} is greater than or equal to @var{min} and lesser than or
  278. equal to @var{max}, 0 otherwise.
  279. @item bitand(x, y)
  280. @item bitor(x, y)
  281. Compute bitwise and/or operation on @var{x} and @var{y}.
  282. The results of the evaluation of @var{x} and @var{y} are converted to
  283. integers before executing the bitwise operation.
  284. Note that both the conversion to integer and the conversion back to
  285. floating point can lose precision. Beware of unexpected results for
  286. large numbers (usually 2^53 and larger).
  287. @item ceil(expr)
  288. Round the value of expression @var{expr} upwards to the nearest
  289. integer. For example, "ceil(1.5)" is "2.0".
  290. @item cos(x)
  291. Compute cosine of @var{x}.
  292. @item cosh(x)
  293. Compute hyperbolic cosine of @var{x}.
  294. @item eq(x, y)
  295. Return 1 if @var{x} and @var{y} are equivalent, 0 otherwise.
  296. @item exp(x)
  297. Compute exponential of @var{x} (with base @code{e}, the Euler's number).
  298. @item floor(expr)
  299. Round the value of expression @var{expr} downwards to the nearest
  300. integer. For example, "floor(-1.5)" is "-2.0".
  301. @item gauss(x)
  302. Compute Gauss function of @var{x}, corresponding to
  303. @code{exp(-x*x/2) / sqrt(2*PI)}.
  304. @item gcd(x, y)
  305. Return the greatest common divisor of @var{x} and @var{y}. If both @var{x} and
  306. @var{y} are 0 or either or both are less than zero then behavior is undefined.
  307. @item gt(x, y)
  308. Return 1 if @var{x} is greater than @var{y}, 0 otherwise.
  309. @item gte(x, y)
  310. Return 1 if @var{x} is greater than or equal to @var{y}, 0 otherwise.
  311. @item hypot(x, y)
  312. This function is similar to the C function with the same name; it returns
  313. "sqrt(@var{x}*@var{x} + @var{y}*@var{y})", the length of the hypotenuse of a
  314. right triangle with sides of length @var{x} and @var{y}, or the distance of the
  315. point (@var{x}, @var{y}) from the origin.
  316. @item if(x, y)
  317. Evaluate @var{x}, and if the result is non-zero return the result of
  318. the evaluation of @var{y}, return 0 otherwise.
  319. @item if(x, y, z)
  320. Evaluate @var{x}, and if the result is non-zero return the evaluation
  321. result of @var{y}, otherwise the evaluation result of @var{z}.
  322. @item ifnot(x, y)
  323. Evaluate @var{x}, and if the result is zero return the result of the
  324. evaluation of @var{y}, return 0 otherwise.
  325. @item ifnot(x, y, z)
  326. Evaluate @var{x}, and if the result is zero return the evaluation
  327. result of @var{y}, otherwise the evaluation result of @var{z}.
  328. @item isinf(x)
  329. Return 1.0 if @var{x} is +/-INFINITY, 0.0 otherwise.
  330. @item isnan(x)
  331. Return 1.0 if @var{x} is NAN, 0.0 otherwise.
  332. @item ld(var)
  333. Allow to load the value of the internal variable with number
  334. @var{var}, which was previously stored with st(@var{var}, @var{expr}).
  335. The function returns the loaded value.
  336. @item log(x)
  337. Compute natural logarithm of @var{x}.
  338. @item lt(x, y)
  339. Return 1 if @var{x} is lesser than @var{y}, 0 otherwise.
  340. @item lte(x, y)
  341. Return 1 if @var{x} is lesser than or equal to @var{y}, 0 otherwise.
  342. @item max(x, y)
  343. Return the maximum between @var{x} and @var{y}.
  344. @item min(x, y)
  345. Return the maximum between @var{x} and @var{y}.
  346. @item mod(x, y)
  347. Compute the remainder of division of @var{x} by @var{y}.
  348. @item not(expr)
  349. Return 1.0 if @var{expr} is zero, 0.0 otherwise.
  350. @item pow(x, y)
  351. Compute the power of @var{x} elevated @var{y}, it is equivalent to
  352. "(@var{x})^(@var{y})".
  353. @item print(t)
  354. @item print(t, l)
  355. Print the value of expression @var{t} with loglevel @var{l}. If
  356. @var{l} is not specified then a default log level is used.
  357. Returns the value of the expression printed.
  358. Prints t with loglevel l
  359. @item random(x)
  360. Return a pseudo random value between 0.0 and 1.0. @var{x} is the index of the
  361. internal variable which will be used to save the seed/state.
  362. @item root(expr, max)
  363. Find an input value for which the function represented by @var{expr}
  364. with argument @var{ld(0)} is 0 in the interval 0..@var{max}.
  365. The expression in @var{expr} must denote a continuous function or the
  366. result is undefined.
  367. @var{ld(0)} is used to represent the function input value, which means
  368. that the given expression will be evaluated multiple times with
  369. various input values that the expression can access through
  370. @code{ld(0)}. When the expression evaluates to 0 then the
  371. corresponding input value will be returned.
  372. @item sin(x)
  373. Compute sine of @var{x}.
  374. @item sinh(x)
  375. Compute hyperbolic sine of @var{x}.
  376. @item sqrt(expr)
  377. Compute the square root of @var{expr}. This is equivalent to
  378. "(@var{expr})^.5".
  379. @item squish(x)
  380. Compute expression @code{1/(1 + exp(4*x))}.
  381. @item st(var, expr)
  382. Allow to store the value of the expression @var{expr} in an internal
  383. variable. @var{var} specifies the number of the variable where to
  384. store the value, and it is a value ranging from 0 to 9. The function
  385. returns the value stored in the internal variable.
  386. Note, Variables are currently not shared between expressions.
  387. @item tan(x)
  388. Compute tangent of @var{x}.
  389. @item tanh(x)
  390. Compute hyperbolic tangent of @var{x}.
  391. @item taylor(expr, x)
  392. @item taylor(expr, x, id)
  393. Evaluate a Taylor series at @var{x}, given an expression representing
  394. the @code{ld(id)}-th derivative of a function at 0.
  395. When the series does not converge the result is undefined.
  396. @var{ld(id)} is used to represent the derivative order in @var{expr},
  397. which means that the given expression will be evaluated multiple times
  398. with various input values that the expression can access through
  399. @code{ld(id)}. If @var{id} is not specified then 0 is assumed.
  400. Note, when you have the derivatives at y instead of 0,
  401. @code{taylor(expr, x-y)} can be used.
  402. @item time(0)
  403. Return the current (wallclock) time in seconds.
  404. @item trunc(expr)
  405. Round the value of expression @var{expr} towards zero to the nearest
  406. integer. For example, "trunc(-1.5)" is "-1.0".
  407. @item while(cond, expr)
  408. Evaluate expression @var{expr} while the expression @var{cond} is
  409. non-zero, and returns the value of the last @var{expr} evaluation, or
  410. NAN if @var{cond} was always false.
  411. @end table
  412. The following constants are available:
  413. @table @option
  414. @item PI
  415. area of the unit disc, approximately 3.14
  416. @item E
  417. exp(1) (Euler's number), approximately 2.718
  418. @item PHI
  419. golden ratio (1+sqrt(5))/2, approximately 1.618
  420. @end table
  421. Assuming that an expression is considered "true" if it has a non-zero
  422. value, note that:
  423. @code{*} works like AND
  424. @code{+} works like OR
  425. For example the construct:
  426. @example
  427. if (A AND B) then C
  428. @end example
  429. is equivalent to:
  430. @example
  431. if(A*B, C)
  432. @end example
  433. In your C code, you can extend the list of unary and binary functions,
  434. and define recognized constants, so that they are available for your
  435. expressions.
  436. The evaluator also recognizes the International System unit prefixes.
  437. If 'i' is appended after the prefix, binary prefixes are used, which
  438. are based on powers of 1024 instead of powers of 1000.
  439. The 'B' postfix multiplies the value by 8, and can be appended after a
  440. unit prefix or used alone. This allows using for example 'KB', 'MiB',
  441. 'G' and 'B' as number postfix.
  442. The list of available International System prefixes follows, with
  443. indication of the corresponding powers of 10 and of 2.
  444. @table @option
  445. @item y
  446. 10^-24 / 2^-80
  447. @item z
  448. 10^-21 / 2^-70
  449. @item a
  450. 10^-18 / 2^-60
  451. @item f
  452. 10^-15 / 2^-50
  453. @item p
  454. 10^-12 / 2^-40
  455. @item n
  456. 10^-9 / 2^-30
  457. @item u
  458. 10^-6 / 2^-20
  459. @item m
  460. 10^-3 / 2^-10
  461. @item c
  462. 10^-2
  463. @item d
  464. 10^-1
  465. @item h
  466. 10^2
  467. @item k
  468. 10^3 / 2^10
  469. @item K
  470. 10^3 / 2^10
  471. @item M
  472. 10^6 / 2^20
  473. @item G
  474. 10^9 / 2^30
  475. @item T
  476. 10^12 / 2^40
  477. @item P
  478. 10^15 / 2^40
  479. @item E
  480. 10^18 / 2^50
  481. @item Z
  482. 10^21 / 2^60
  483. @item Y
  484. 10^24 / 2^70
  485. @end table
  486. @c man end
  487. @chapter OpenCL Options
  488. @c man begin OPENCL OPTIONS
  489. When FFmpeg is configured with @code{--enable-opencl}, it is possible
  490. to set the options for the global OpenCL context.
  491. The list of supported options follows:
  492. @table @option
  493. @item build_options
  494. Set build options used to compile the registered kernels.
  495. See reference "OpenCL Specification Version: 1.2 chapter 5.6.4".
  496. @item platform_idx
  497. Select the index of the platform to run OpenCL code.
  498. The specified index must be one of the indexes in the device list
  499. which can be obtained with @code{av_opencl_get_device_list()}.
  500. @item device_idx
  501. Select the index of the device used to run OpenCL code.
  502. The specifed index must be one of the indexes in the device list which
  503. can be obtained with @code{av_opencl_get_device_list()}.
  504. @end table
  505. @c man end OPENCL OPTIONS