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.

605 lines
14KB

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