annotate ffmpeg/doc/utils.texi @ 13:844d341cf643 tip

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