FFMPEG-PROTOCOLS(1) FFMPEG-PROTOCOLS(1) NAME ffmpeg-protocols - FFmpeg protocols DESCRIPTION This document describes the input and output protocols provided by the libavformat library. PROTOCOL OPTIONS The libavformat library provides some generic global options, which can be set on all the protocols. In addition each protocol may support so- called private options, which are specific for that component. Options may be set by specifying -option value in the FFmpeg tools, or by setting the value explicitly in the "AVFormatContext" options or using the libavutil/opt.h API for programmatic use. The list of supported options follows: protocol_whitelist list (input) Set a ","-separated list of allowed protocols. "ALL" matches all protocols. Protocols prefixed by "-" are disabled. All protocols are allowed by default but protocols used by an another protocol (nested protocols) are restricted to a per protocol subset. PROTOCOLS Protocols are configured elements in FFmpeg that enable access to resources that require specific protocols. When you configure your FFmpeg build, all the supported protocols are enabled by default. You can list all available ones using the configure option "--list-protocols". You can disable all the protocols using the configure option "--disable-protocols", and selectively enable a protocol using the option "--enable-protocol=PROTOCOL", or you can disable a particular protocol using the option "--disable-protocol=PROTOCOL". The option "-protocols" of the ff* tools will display the list of supported protocols. All protocols accept the following options: rw_timeout Maximum time to wait for (network) read/write operations to complete, in microseconds. A description of the currently available protocols follows. amqp Advanced Message Queueing Protocol (AMQP) version 0-9-1 is a broker based publish-subscribe communication protocol. FFmpeg must be compiled with --enable-librabbitmq to support AMQP. A separate AMQP broker must also be run. An example open-source AMQP broker is RabbitMQ. After starting the broker, an FFmpeg client may stream data to the broker using the command: ffmpeg -re -i input -f mpegts amqp://[[user]:[password]@]hostname[:port][/vhost] Where hostname and port (default is 5672) is the address of the broker. The client may also set a user/password for authentication. The default for both fields is "guest". Name of virtual host on broker can be set with vhost. The default value is "/". Muliple subscribers may stream from the broker using the command: ffplay amqp://[[user]:[password]@]hostname[:port][/vhost] In RabbitMQ all data published to the broker flows through a specific exchange, and each subscribing client has an assigned queue/buffer. When a packet arrives at an exchange, it may be copied to a client's queue depending on the exchange and routing_key fields. The following options are supported: exchange Sets the exchange to use on the broker. RabbitMQ has several predefined exchanges: "amq.direct" is the default exchange, where the publisher and subscriber must have a matching routing_key; "amq.fanout" is the same as a broadcast operation (i.e. the data is forwarded to all queues on the fanout exchange independent of the routing_key); and "amq.topic" is similar to "amq.direct", but allows for more complex pattern matching (refer to the RabbitMQ documentation). routing_key Sets the routing key. The default value is "amqp". The routing key is used on the "amq.direct" and "amq.topic" exchanges to decide whether packets are written to the queue of a subscriber. pkt_size Maximum size of each packet sent/received to the broker. Default is 131072. Minimum is 4096 and max is any large value (representable by an int). When receiving packets, this sets an internal buffer size in FFmpeg. It should be equal to or greater than the size of the published packets to the broker. Otherwise the received message may be truncated causing decoding errors. connection_timeout The timeout in seconds during the initial connection to the broker. The default value is rw_timeout, or 5 seconds if rw_timeout is not set. delivery_mode mode Sets the delivery mode of each message sent to broker. The following values are accepted: persistent Delivery mode set to "persistent" (2). This is the default value. Messages may be written to the broker's disk depending on its setup. non-persistent Delivery mode set to "non-persistent" (1). Messages will stay in broker's memory unless the broker is under memory pressure. async Asynchronous data filling wrapper for input stream. Fill data in a background thread, to decouple I/O operation from demux thread. async: async:http://host/resource async:cache:http://host/resource bluray Read BluRay playlist. The accepted options are: angle BluRay angle chapter Start chapter (1...N) playlist Playlist to read (BDMV/PLAYLIST/?????.mpls) Examples: Read longest playlist from BluRay mounted to /mnt/bluray: bluray:/mnt/bluray Read angle 2 of playlist 4 from BluRay mounted to /mnt/bluray, start from chapter 2: -playlist 4 -angle 2 -chapter 2 bluray:/mnt/bluray cache Caching wrapper for input stream. Cache the input stream to temporary file. It brings seeking capability to live streams. The accepted options are: read_ahead_limit Amount in bytes that may be read ahead when seeking isn't supported. Range is -1 to INT_MAX. -1 for unlimited. Default is 65536. URL Syntax is cache: concat Physical concatenation protocol. Read and seek from many resources in sequence as if they were a unique resource. A URL accepted by this protocol has the syntax: concat:||...| where URL1, URL2, ..., URLN are the urls of the resource to be concatenated, each one possibly specifying a distinct protocol. For example to read a sequence of files split1.mpeg, split2.mpeg, split3.mpeg with ffplay use the command: ffplay concat:split1.mpeg\|split2.mpeg\|split3.mpeg Note that you may need to escape the character "|" which is special for many shells. concatf Physical concatenation protocol using a line break delimited list of resources. Read and seek from many resources in sequence as if they were a unique resource. A URL accepted by this protocol has the syntax: concatf: where URL is the url containing a line break delimited list of resources to be concatenated, each one possibly specifying a distinct protocol. Special characters must be escaped with backslash or single quotes. See the "Quoting and escaping" section in the ffmpeg-utils(1) manual. For example to read a sequence of files split1.mpeg, split2.mpeg, split3.mpeg listed in separate lines within a file split.txt with ffplay use the command: ffplay concatf:split.txt Where split.txt contains the lines: split1.mpeg split2.mpeg split3.mpeg crypto AES-encrypted stream reading protocol. The accepted options are: key Set the AES decryption key binary block from given hexadecimal representation. iv Set the AES decryption initialization vector binary block from given hexadecimal representation. Accepted URL formats: crypto: crypto+ data Data in-line in the URI. See . For example, to convert a GIF file given inline with ffmpeg: ffmpeg -i "data:image/gif;base64,R0lGODdhCAAIAMIEAAAAAAAA//8AAP//AP///////////////ywAAAAACAAIAAADF0gEDLojDgdGiJdJqUX02iB4E8Q9jUMkADs=" smiley.png file File access protocol. Read from or write to a file. A file URL can have the form: file: where filename is the path of the file to read. An URL that does not have a protocol prefix will be assumed to be a file URL. Depending on the build, an URL that looks like a Windows path with the drive letter at the beginning will also be assumed to be a file URL (usually not the case in builds for unix-like systems). For example to read from a file input.mpeg with ffmpeg use the command: ffmpeg -i file:input.mpeg output.mpeg This protocol accepts the following options: truncate Truncate existing files on write, if set to 1. A value of 0 prevents truncating. Default value is 1. blocksize Set I/O operation maximum block size, in bytes. Default value is "INT_MAX", which results in not limiting the requested block size. Setting this value reasonably low improves user termination request reaction time, which is valuable for files on slow medium. follow If set to 1, the protocol will retry reading at the end of the file, allowing reading files that still are being written. In order for this to terminate, you either need to use the rw_timeout option, or use the interrupt callback (for API users). seekable Controls if seekability is advertised on the file. 0 means non- seekable, -1 means auto (seekable for normal files, non-seekable for named pipes). Many demuxers handle seekable and non-seekable resources differently, overriding this might speed up opening certain files at the cost of losing some features (e.g. accurate seeking). ftp FTP (File Transfer Protocol). Read from or write to remote resources using FTP protocol. Following syntax is required. ftp://[user[:password]@]server[:port]/path/to/remote/resource.mpeg This protocol accepts the following options. timeout Set timeout in microseconds of socket I/O operations used by the underlying low level operation. By default it is set to -1, which means that the timeout is not specified. ftp-user Set a user to be used for authenticating to the FTP server. This is overridden by the user in the FTP URL. ftp-password Set a password to be used for authenticating to the FTP server. This is overridden by the password in the FTP URL, or by ftp- anonymous-password if no user is set. ftp-anonymous-password Password used when login as anonymous user. Typically an e-mail address should be used. ftp-write-seekable Control seekability of connection during encoding. If set to 1 the resource is supposed to be seekable, if set to 0 it is assumed not to be seekable. Default value is 0. NOTE: Protocol can be used as output, but it is recommended to not do it, unless special care is taken (tests, customized server configuration etc.). Different FTP servers behave in different way during seek operation. ff* tools may produce incomplete content due to server limitations. gopher Gopher protocol. gophers Gophers protocol. The Gopher protocol with TLS encapsulation. hls Read Apple HTTP Live Streaming compliant segmented stream as a uniform one. The M3U8 playlists describing the segments can be remote HTTP resources or local files, accessed using the standard file protocol. The nested protocol is declared by specifying "+proto" after the hls URI scheme name, where proto is either "file" or "http". hls+http://host/path/to/remote/resource.m3u8 hls+file://path/to/local/resource.m3u8 Using this protocol is discouraged - the hls demuxer should work just as well (if not, please report the issues) and is more complete. To use the hls demuxer instead, simply use the direct URLs to the m3u8 files. http HTTP (Hyper Text Transfer Protocol). This protocol accepts the following options: seekable Control seekability of connection. If set to 1 the resource is supposed to be seekable, if set to 0 it is assumed not to be seekable, if set to -1 it will try to autodetect if it is seekable. Default value is -1. chunked_post If set to 1 use chunked Transfer-Encoding for posts, default is 1. content_type Set a specific content type for the POST messages or for listen mode. http_proxy set HTTP proxy to tunnel through e.g. http://example.com:1234 headers Set custom HTTP headers, can override built in default headers. The value must be a string encoding the headers. multiple_requests Use persistent connections if set to 1, default is 0. post_data Set custom HTTP post data. referer Set the Referer header. Include 'Referer: URL' header in HTTP request. user_agent Override the User-Agent header. If not specified the protocol will use a string describing the libavformat build. ("Lavf/") reconnect_at_eof If set then eof is treated like an error and causes reconnection, this is useful for live / endless streams. reconnect_streamed If set then even streamed/non seekable streams will be reconnected on errors. reconnect_on_network_error Reconnect automatically in case of TCP/TLS errors during connect. reconnect_on_http_error A comma separated list of HTTP status codes to reconnect on. The list can include specific status codes (e.g. '503') or the strings '4xx' / '5xx'. reconnect_delay_max Sets the maximum delay in seconds after which to give up reconnecting mime_type Export the MIME type. http_version Exports the HTTP response version number. Usually "1.0" or "1.1". icy If set to 1 request ICY (SHOUTcast) metadata from the server. If the server supports this, the metadata has to be retrieved by the application by reading the icy_metadata_headers and icy_metadata_packet options. The default is 1. icy_metadata_headers If the server supports ICY metadata, this contains the ICY-specific HTTP reply headers, separated by newline characters. icy_metadata_packet If the server supports ICY metadata, and icy was set to 1, this contains the last non-empty metadata packet sent by the server. It should be polled in regular intervals by applications interested in mid-stream metadata updates. cookies Set the cookies to be sent in future requests. The format of each cookie is the same as the value of a Set-Cookie HTTP response field. Multiple cookies can be delimited by a newline character. offset Set initial byte offset. end_offset Try to limit the request to bytes preceding this offset. method When used as a client option it sets the HTTP method for the request. When used as a server option it sets the HTTP method that is going to be expected from the client(s). If the expected and the received HTTP method do not match the client will be given a Bad Request response. When unset the HTTP method is not checked for now. This will be replaced by autodetection in the future. listen If set to 1 enables experimental HTTP server. This can be used to send data when used as an output option, or read data from a client with HTTP POST when used as an input option. If set to 2 enables experimental multi-client HTTP server. This is not yet implemented in ffmpeg.c and thus must not be used as a command line option. # Server side (sending): ffmpeg -i somefile.ogg -c copy -listen 1 -f ogg http://: # Client side (receiving): ffmpeg -i http://: -c copy somefile.ogg # Client can also be done with wget: wget http://: -O somefile.ogg # Server side (receiving): ffmpeg -listen 1 -i http://: -c copy somefile.ogg # Client side (sending): ffmpeg -i somefile.ogg -chunked_post 0 -c copy -f ogg http://: # Client can also be done with wget: wget --post-file=somefile.ogg http://: send_expect_100 Send an Expect: 100-continue header for POST. If set to 1 it will send, if set to 0 it won't, if set to -1 it will try to send if it is applicable. Default value is -1. auth_type Set HTTP authentication type. No option for Digest, since this method requires getting nonce parameters from the server first and can't be used straight away like Basic. none Choose the HTTP authentication type automatically. This is the default. basic Choose the HTTP basic authentication. Basic authentication sends a Base64-encoded string that contains a user name and password for the client. Base64 is not a form of encryption and should be considered the same as sending the user name and password in clear text (Base64 is a reversible encoding). If a resource needs to be protected, strongly consider using an authentication scheme other than basic authentication. HTTPS/TLS should be used with basic authentication. Without these additional security enhancements, basic authentication should not be used to protect sensitive or valuable information. HTTP Cookies Some HTTP requests will be denied unless cookie values are passed in with the request. The cookies option allows these cookies to be specified. At the very least, each cookie must specify a value along with a path and domain. HTTP requests that match both the domain and path will automatically include the cookie value in the HTTP Cookie header field. Multiple cookies can be delimited by a newline. The required syntax to play a stream specifying a cookie is: ffplay -cookies "nlqptid=nltid=tsn; path=/; domain=somedomain.com;" http://somedomain.com/somestream.m3u8 Icecast Icecast protocol (stream to Icecast servers) This protocol accepts the following options: ice_genre Set the stream genre. ice_name Set the stream name. ice_description Set the stream description. ice_url Set the stream website URL. ice_public Set if the stream should be public. The default is 0 (not public). user_agent Override the User-Agent header. If not specified a string of the form "Lavf/" will be used. password Set the Icecast mountpoint password. content_type Set the stream content type. This must be set if it is different from audio/mpeg. legacy_icecast This enables support for Icecast versions < 2.4.0, that do not support the HTTP PUT method but the SOURCE method. tls Establish a TLS (HTTPS) connection to Icecast. icecast://[[:]@]:/ mmst MMS (Microsoft Media Server) protocol over TCP. mmsh MMS (Microsoft Media Server) protocol over HTTP. The required syntax is: mmsh://[:][/][/] md5 MD5 output protocol. Computes the MD5 hash of the data to be written, and on close writes this to the designated output or stdout if none is specified. It can be used to test muxers without writing an actual file. Some examples follow. # Write the MD5 hash of the encoded AVI file to the file output.avi.md5. ffmpeg -i input.flv -f avi -y md5:output.avi.md5 # Write the MD5 hash of the encoded AVI file to stdout. ffmpeg -i input.flv -f avi -y md5: Note that some formats (typically MOV) require the output protocol to be seekable, so they will fail with the MD5 output protocol. pipe UNIX pipe access protocol. Read and write from UNIX pipes. The accepted syntax is: pipe:[] number is the number corresponding to the file descriptor of the pipe (e.g. 0 for stdin, 1 for stdout, 2 for stderr). If number is not specified, by default the stdout file descriptor will be used for writing, stdin for reading. For example to read from stdin with ffmpeg: cat test.wav | ffmpeg -i pipe:0 # ...this is the same as... cat test.wav | ffmpeg -i pipe: For writing to stdout with ffmpeg: ffmpeg -i test.wav -f avi pipe:1 | cat > test.avi # ...this is the same as... ffmpeg -i test.wav -f avi pipe: | cat > test.avi This protocol accepts the following options: blocksize Set I/O operation maximum block size, in bytes. Default value is "INT_MAX", which results in not limiting the requested block size. Setting this value reasonably low improves user termination request reaction time, which is valuable if data transmission is slow. Note that some formats (typically MOV), require the output protocol to be seekable, so they will fail with the pipe output protocol. prompeg Pro-MPEG Code of Practice #3 Release 2 FEC protocol. The Pro-MPEG CoP#3 FEC is a 2D parity-check forward error correction mechanism for MPEG-2 Transport Streams sent over RTP. This protocol must be used in conjunction with the "rtp_mpegts" muxer and the "rtp" protocol. The required syntax is: -f rtp_mpegts -fec prompeg=