=encoding utf8 =head1 NAME ffmpeg-utils - FFmpeg utilities =head1 DESCRIPTION This document describes some generic features and utilities provided by the libavutil library. =head1 SYNTAX This section documents the syntax and formats employed by the FFmpeg libraries and tools. =head2 Quoting and escaping FFmpeg adopts the following quoting and escaping mechanism, unless explicitly specified. The following rules are applied: =over 4 =item * B<'> and B<\> 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. =item * A special character is escaped by prefixing it with a B<\>. =item * All characters enclosed between B<''> are included literally in the parsed string. The quote character B<'> itself cannot be quoted, so you may need to close the quote and escape it. =item * Leading and trailing whitespaces, unless escaped or quoted, are removed from the parsed string. =back 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 C defined in F can be used to parse a token quoted or escaped according to the rules defined above. The tool F in the FFmpeg source tree can be used to automatically quote or escape a string in a script. =head3 Examples =over 4 =item * Escape the string C containing the C<'> special character: Crime d\'Amour =item * The string above contains a quote, so the C<'> needs to be escaped when quoting it: 'Crime d'\''Amour' =item * Include leading or trailing whitespaces using quoting: ' this string starts and ends with whitespaces ' =item * Escaping and quoting can be mixed together: ' The string '\'string\'' is a string ' =item * To include a literal B<\> you can use either escaping or quoting: 'c:\foo' can be written as c:\\foo =back =head2 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. =head2 Time duration There are two accepted syntaxes for expressing time duration. [-][:]:[....] I expresses the number of hours, I the number of minutes for a maximum of 2 digits, and I the number of seconds for a maximum of 2 digits. The I at the end expresses decimal value for I. I [-]+[....] I expresses the number of seconds, with the optional decimal part I. In both expressions, the optional B<-> indicates negative duration. =head3 Examples The following examples are all valid time duration: =over 4 =item B<55> 55 seconds =item B<12:03:45> 12 hours, 03 minutes and 45 seconds =item B<23.189> 23.189 seconds =back =head2 Video size Specify the size of the sourced video, it may be a string of the form IxI, or the name of a size abbreviation. The following abbreviations are recognized: =over 4 =item B 720x480 =item B 720x576 =item B 352x240 =item B 352x288 =item B 640x480 =item B 768x576 =item B 352x240 =item B 352x240 =item B 128x96 =item B 176x144 =item B 352x288 =item B<4cif> 704x576 =item B<16cif> 1408x1152 =item B 160x120 =item B 320x240 =item B 640x480 =item B 800x600 =item B 1024x768 =item B 1600x1200 =item B 2048x1536 =item B 1280x1024 =item B 2560x2048 =item B 5120x4096 =item B 852x480 =item B 1366x768 =item B 1600x1024 =item B 1920x1200 =item B 2560x1600 =item B 3200x2048 =item B 3840x2400 =item B 6400x4096 =item B 7680x4800 =item B 320x200 =item B 640x350 =item B 852x480 =item B 1280x720 =item B 1920x1080 =item B<2k> 2048x1080 =item B<2kflat> 1998x1080 =item B<2kscope> 2048x858 =item B<4k> 4096x2160 =item B<4kflat> 3996x2160 =item B<4kscope> 4096x1716 =item B 640x360 =item B 240x160 =item B 400x240 =item B 432x240 =item B 480x320 =item B 960x540 =item B<2kdci> 2048x1080 =item B<4kdci> 4096x2160 =item B 3840x2160 =item B 7680x4320 =back =head2 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 I/I, an integer number, a float number or a valid video frame rate abbreviation. The following abbreviations are recognized: =over 4 =item B 30000/1001 =item B 25/1 =item B 30000/1001 =item B 25/1 =item B 30000/1001 =item B 25/1 =item B 24/1 =item B 24000/1001 =back =head2 Ratio A ratio can be expressed as an expression, or in the form I:I. 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. =head2 Color It can be the name of a color as defined below (case insensitive match) or a C<[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 (B<0x00> or B<0.0> means completely transparent, B<0xff> or B<1.0> completely opaque). If the alpha component is not specified then B<0xff> is assumed. The string B will result in a random color. The following names of colors are recognized: =over 4 =item B 0xF0F8FF =item B 0xFAEBD7 =item B 0x00FFFF =item B 0x7FFFD4 =item B 0xF0FFFF =item B 0xF5F5DC =item B 0xFFE4C4 =item B 0x000000 =item B 0xFFEBCD =item B 0x0000FF =item B 0x8A2BE2 =item B 0xA52A2A =item B 0xDEB887 =item B 0x5F9EA0 =item B 0x7FFF00 =item B 0xD2691E =item B 0xFF7F50 =item B 0x6495ED =item B 0xFFF8DC =item B 0xDC143C =item B 0x00FFFF =item B 0x00008B =item B 0x008B8B =item B 0xB8860B =item B 0xA9A9A9 =item B 0x006400 =item B 0xBDB76B =item B 0x8B008B =item B 0x556B2F =item B 0xFF8C00 =item B 0x9932CC =item B 0x8B0000 =item B 0xE9967A =item B 0x8FBC8F =item B 0x483D8B =item B 0x2F4F4F =item B 0x00CED1 =item B 0x9400D3 =item B 0xFF1493 =item B 0x00BFFF =item B 0x696969 =item B 0x1E90FF =item B 0xB22222 =item B 0xFFFAF0 =item B 0x228B22 =item B 0xFF00FF =item B 0xDCDCDC =item B 0xF8F8FF =item B 0xFFD700 =item B 0xDAA520 =item B 0x808080 =item B 0x008000 =item B 0xADFF2F =item B 0xF0FFF0 =item B 0xFF69B4 =item B 0xCD5C5C =item B 0x4B0082 =item B 0xFFFFF0 =item B 0xF0E68C =item B 0xE6E6FA =item B 0xFFF0F5 =item B 0x7CFC00 =item B 0xFFFACD =item B 0xADD8E6 =item B 0xF08080 =item B 0xE0FFFF =item B 0xFAFAD2 =item B 0x90EE90 =item B 0xD3D3D3 =item B 0xFFB6C1 =item B 0xFFA07A =item B 0x20B2AA =item B 0x87CEFA =item B 0x778899 =item B 0xB0C4DE =item B 0xFFFFE0 =item B 0x00FF00 =item B 0x32CD32 =item B 0xFAF0E6 =item B 0xFF00FF =item B 0x800000 =item B 0x66CDAA =item B 0x0000CD =item B 0xBA55D3 =item B 0x9370D8 =item B 0x3CB371 =item B 0x7B68EE =item B 0x00FA9A =item B 0x48D1CC =item B 0xC71585 =item B 0x191970 =item B 0xF5FFFA =item B 0xFFE4E1 =item B 0xFFE4B5 =item B 0xFFDEAD =item B 0x000080 =item B 0xFDF5E6 =item B 0x808000 =item B 0x6B8E23 =item B 0xFFA500 =item B 0xFF4500 =item B 0xDA70D6 =item B 0xEEE8AA =item B 0x98FB98 =item B 0xAFEEEE =item B 0xD87093 =item B 0xFFEFD5 =item B 0xFFDAB9 =item B 0xCD853F =item B 0xFFC0CB =item B 0xDDA0DD =item B 0xB0E0E6 =item B 0x800080 =item B 0xFF0000 =item B 0xBC8F8F =item B 0x4169E1 =item B 0x8B4513 =item B 0xFA8072 =item B 0xF4A460 =item B 0x2E8B57 =item B 0xFFF5EE =item B 0xA0522D =item B 0xC0C0C0 =item B 0x87CEEB =item B 0x6A5ACD =item B 0x708090 =item B 0xFFFAFA =item B 0x00FF7F =item B 0x4682B4 =item B 0xD2B48C =item B 0x008080 =item B 0xD8BFD8 =item B 0xFF6347 =item B 0x40E0D0 =item B 0xEE82EE =item B 0xF5DEB3 =item B 0xFFFFFF =item B 0xF5F5F5 =item B 0xFFFF00 =item B 0x9ACD32 =back =head2 Channel Layout A channel layout specifies the spatial disposition of the channels in a multi-channel audio stream. To specify a channel layout, FFmpeg makes use of a special syntax. Individual channels are identified by an id, as given by the table below: =over 4 =item B front left =item B front right =item B front center =item B low frequency =item B back left =item B
back right =item B front left-of-center =item B front right-of-center =item B back center =item B side left =item B side right =item B top center =item B top front left =item B top front center =item B top front right =item B top back left =item B top back center =item B top back right =item B
downmix left =item B downmix right =item B wide left =item B wide right =item B surround direct left =item B surround direct right =item B low frequency 2 =back Standard channel layout compositions can be specified by using the following identifiers: =over 4 =item B FC =item B FL+FR =item B<2.1> FL+FR+LFE =item B<3.0> FL+FR+FC =item B<3.0(back)> FL+FR+BC =item B<4.0> FL+FR+FC+BC =item B FL+FR+BL+BR =item B FL+FR+SL+SR =item B<3.1> FL+FR+FC+LFE =item B<5.0> FL+FR+FC+BL+BR =item B<5.0(side)> FL+FR+FC+SL+SR =item B<4.1> FL+FR+FC+LFE+BC =item B<5.1> FL+FR+FC+LFE+BL+BR =item B<5.1(side)> FL+FR+FC+LFE+SL+SR =item B<6.0> FL+FR+FC+BC+SL+SR =item B<6.0(front)> FL+FR+FLC+FRC+SL+SR =item B FL+FR+FC+BL+BR+BC =item B<6.1> FL+FR+FC+LFE+BC+SL+SR =item B<6.1> FL+FR+FC+LFE+BL+BR+BC =item B<6.1(front)> FL+FR+LFE+FLC+FRC+SL+SR =item B<7.0> FL+FR+FC+BL+BR+SL+SR =item B<7.0(front)> FL+FR+FC+FLC+FRC+SL+SR =item B<7.1> FL+FR+FC+LFE+BL+BR+SL+SR =item B<7.1(wide)> FL+FR+FC+LFE+BL+BR+FLC+FRC =item B<7.1(wide-side)> FL+FR+FC+LFE+FLC+FRC+SL+SR =item B FL+FR+FC+BL+BR+BC+SL+SR =item B DL+DR =back A custom channel layout can be specified as a sequence of terms, separated by '+' or '|'. Each term can be: =over 4 =item * the name of a standard channel layout (e.g. B, B, B<4.0>, B, B<5.0>, etc.) =item * the name of a single channel (e.g. B, B, B, B, etc.) =item * a number of channels, in decimal, optionally followed by 'c', yielding the default channel layout for that number of channels (see the function C) =item * a channel layout mask, in hexadecimal starting with "0x" (see the C macros in F. =back Starting from libavutil version 53 the trailing character "c" to specify a number of channels will be required, while a channel layout mask could also be specified as a decimal number (if and only if not followed by "c"). See also the function C defined in F. =head1 EXPRESSION EVALUATION When evaluating an arithmetic expression, FFmpeg uses an internal formula evaluator, implemented through the F interface. An expression may contain unary, binary operators, constants, and functions. Two expressions I and I can be combined to form another expression "I;I". I and I are evaluated in turn, and the new expression evaluates to the value of I. The following binary operators are available: C<+>, C<->, C<*>, C, C<^>. The following unary operators are available: C<+>, C<->. The following functions are available: =over 4 =item B Compute absolute value of I. =item B Compute arccosine of I. =item B Compute arcsine of I. =item B Compute arctangent of I. =item B Return 1 if I is greater than or equal to I and lesser than or equal to I, 0 otherwise. =item B =item B Compute bitwise and/or operation on I and I. The results of the evaluation of I and I are converted to integers before executing the bitwise operation. Note that both the conversion to integer and the conversion back to floating point can lose precision. Beware of unexpected results for large numbers (usually 2^53 and larger). =item B Round the value of expression I upwards to the nearest integer. For example, "ceil(1.5)" is "2.0". =item B Return the value of I clipped between I and I. =item B Compute cosine of I. =item B Compute hyperbolic cosine of I. =item B Return 1 if I and I are equivalent, 0 otherwise. =item B Compute exponential of I (with base C, the Euler's number). =item B Round the value of expression I downwards to the nearest integer. For example, "floor(-1.5)" is "-2.0". =item B Compute Gauss function of I, corresponding to C. =item B Return the greatest common divisor of I and I. If both I and I are 0 or either or both are less than zero then behavior is undefined. =item B Return 1 if I is greater than I, 0 otherwise. =item B Return 1 if I is greater than or equal to I, 0 otherwise. =item B This function is similar to the C function with the same name; it returns "sqrt(I*I + I*I)", the length of the hypotenuse of a right triangle with sides of length I and I, or the distance of the point (I, I) from the origin. =item B Evaluate I, and if the result is non-zero return the result of the evaluation of I, return 0 otherwise. =item B Evaluate I, and if the result is non-zero return the evaluation result of I, otherwise the evaluation result of I. =item B Evaluate I, and if the result is zero return the result of the evaluation of I, return 0 otherwise. =item B Evaluate I, and if the result is zero return the evaluation result of I, otherwise the evaluation result of I. =item B Return 1.0 if I is +/-INFINITY, 0.0 otherwise. =item B Return 1.0 if I is NAN, 0.0 otherwise. =item B Load the value of the internal variable with number I, which was previously stored with st(I, I). The function returns the loaded value. =item B Compute natural logarithm of I. =item B Return 1 if I is lesser than I, 0 otherwise. =item B Return 1 if I is lesser than or equal to I, 0 otherwise. =item B Return the maximum between I and I. =item B Return the maximum between I and I. =item B Compute the remainder of division of I by I. =item B Return 1.0 if I is zero, 0.0 otherwise. =item B Compute the power of I elevated I, it is equivalent to "(I)^(I)". =item B =item B Print the value of expression I with loglevel I. If I is not specified then a default log level is used. Returns the value of the expression printed. Prints t with loglevel l =item B Return a pseudo random value between 0.0 and 1.0. I is the index of the internal variable which will be used to save the seed/state. =item B Find an input value for which the function represented by I with argument I is 0 in the interval 0..I. The expression in I must denote a continuous function or the result is undefined. I is used to represent the function input value, which means that the given expression will be evaluated multiple times with various input values that the expression can access through C. When the expression evaluates to 0 then the corresponding input value will be returned. =item B Compute sine of I. =item B Compute hyperbolic sine of I. =item B Compute the square root of I. This is equivalent to "(I)^.5". =item B Compute expression C<1/(1 + exp(4*x))>. =item B Store the value of the expression I in an internal variable. I specifies the number of the variable where to store the value, and it is a value ranging from 0 to 9. The function returns the value stored in the internal variable. Note, Variables are currently not shared between expressions. =item B Compute tangent of I. =item B Compute hyperbolic tangent of I. =item B =item B Evaluate a Taylor series at I, given an expression representing the C-th derivative of a function at 0. When the series does not converge the result is undefined. I is used to represent the derivative order in I, which means that the given expression will be evaluated multiple times with various input values that the expression can access through C. If I is not specified then 0 is assumed. Note, when you have the derivatives at y instead of 0, C can be used. =item B Return the current (wallclock) time in seconds. =item B Round the value of expression I towards zero to the nearest integer. For example, "trunc(-1.5)" is "-1.0". =item B Evaluate expression I while the expression I is non-zero, and returns the value of the last I evaluation, or NAN if I was always false. =back The following constants are available: =over 4 =item B area of the unit disc, approximately 3.14 =item B exp(1) (Euler's number), approximately 2.718 =item B golden ratio (1+sqrt(5))/2, approximately 1.618 =back Assuming that an expression is considered "true" if it has a non-zero value, note that: C<*> works like AND C<+> works like OR For example the construct: if (A AND B) then C is equivalent to: if(A*B, C) In your C code, you can extend the list of unary and binary functions, and define recognized constants, so that they are available for your expressions. The evaluator also recognizes the International System unit prefixes. If 'i' is appended after the prefix, binary prefixes are used, which are based on powers of 1024 instead of powers of 1000. The 'B' postfix multiplies the value by 8, and can be appended after a unit prefix or used alone. This allows using for example 'KB', 'MiB', 'G' and 'B' as number postfix. The list of available International System prefixes follows, with indication of the corresponding powers of 10 and of 2. =over 4 =item B 10^-24 / 2^-80 =item B 10^-21 / 2^-70 =item B 10^-18 / 2^-60 =item B 10^-15 / 2^-50 =item B

10^-12 / 2^-40 =item B 10^-9 / 2^-30 =item B 10^-6 / 2^-20 =item B 10^-3 / 2^-10 =item B 10^-2 =item B 10^-1 =item B 10^2 =item B 10^3 / 2^10 =item B 10^3 / 2^10 =item B 10^6 / 2^20 =item B 10^9 / 2^30 =item B 10^12 / 2^40 =item B

10^15 / 2^40 =item B 10^18 / 2^50 =item B 10^21 / 2^60 =item B 10^24 / 2^70 =back =head1 OPENCL OPTIONS When FFmpeg is configured with C<--enable-opencl>, it is possible to set the options for the global OpenCL context. The list of supported options follows: =over 4 =item B Set build options used to compile the registered kernels. See reference "OpenCL Specification Version: 1.2 chapter 5.6.4". =item B Select the index of the platform to run OpenCL code. The specified index must be one of the indexes in the device list which can be obtained with C or C. =item B Select the index of the device used to run OpenCL code. The specified index must be one of the indexes in the device list which can be obtained with C or C. =back =head1 SEE ALSO ffmpeg(1), ffplay(1), ffprobe(1), ffserver(1), libavutil(3) =head1 AUTHORS The FFmpeg developers. For details about the authorship, see the Git history of the project (git://source.ffmpeg.org/ffmpeg), e.g. by typing the command B in the FFmpeg source directory, or browsing the online repository at EBE. Maintainers for the specific components are listed in the file F in the source code tree.