]> git.sesse.net Git - ffmpeg/blob - doc/protocols.texi
Merge commit 'd60c2d5216930ef98c7d4d6837d6229b37e0dcb3'
[ffmpeg] / doc / protocols.texi
1 @chapter Protocol Options
2 @c man begin PROTOCOL OPTIONS
3
4 The libavformat library provides some generic global options, which
5 can be set on all the protocols. In addition each protocol may support
6 so-called private options, which are specific for that component.
7
8 The list of supported options follows:
9
10 @table @option
11 @item protocol_whitelist @var{list} (@emph{input})
12 Set a ","-separated list of allowed protocols. "ALL" matches all protocols. Protocols
13 prefixed by "-" are disabled.
14 All protocols are allowed by default but protocols used by an another
15 protocol (nested protocols) are restricted to a per protocol subset.
16 @end table
17
18 @c man end PROTOCOL OPTIONS
19
20 @chapter Protocols
21 @c man begin PROTOCOLS
22
23 Protocols are configured elements in FFmpeg that enable access to
24 resources that require specific protocols.
25
26 When you configure your FFmpeg build, all the supported protocols are
27 enabled by default. You can list all available ones using the
28 configure option "--list-protocols".
29
30 You can disable all the protocols using the configure option
31 "--disable-protocols", and selectively enable a protocol using the
32 option "--enable-protocol=@var{PROTOCOL}", or you can disable a
33 particular protocol using the option
34 "--disable-protocol=@var{PROTOCOL}".
35
36 The option "-protocols" of the ff* tools will display the list of
37 supported protocols.
38
39 All protocols accept the following options:
40
41 @table @option
42 @item rw_timeout
43 Maximum time to wait for (network) read/write operations to complete,
44 in microseconds.
45 @end table
46
47 A description of the currently available protocols follows.
48
49 @section async
50
51 Asynchronous data filling wrapper for input stream.
52
53 Fill data in a background thread, to decouple I/O operation from demux thread.
54
55 @example
56 async:@var{URL}
57 async:http://host/resource
58 async:cache:http://host/resource
59 @end example
60
61 @section bluray
62
63 Read BluRay playlist.
64
65 The accepted options are:
66 @table @option
67
68 @item angle
69 BluRay angle
70
71 @item chapter
72 Start chapter (1...N)
73
74 @item playlist
75 Playlist to read (BDMV/PLAYLIST/?????.mpls)
76
77 @end table
78
79 Examples:
80
81 Read longest playlist from BluRay mounted to /mnt/bluray:
82 @example
83 bluray:/mnt/bluray
84 @end example
85
86 Read angle 2 of playlist 4 from BluRay mounted to /mnt/bluray, start from chapter 2:
87 @example
88 -playlist 4 -angle 2 -chapter 2 bluray:/mnt/bluray
89 @end example
90
91 @section cache
92
93 Caching wrapper for input stream.
94
95 Cache the input stream to temporary file. It brings seeking capability to live streams.
96
97 @example
98 cache:@var{URL}
99 @end example
100
101 @section concat
102
103 Physical concatenation protocol.
104
105 Read and seek from many resources in sequence as if they were
106 a unique resource.
107
108 A URL accepted by this protocol has the syntax:
109 @example
110 concat:@var{URL1}|@var{URL2}|...|@var{URLN}
111 @end example
112
113 where @var{URL1}, @var{URL2}, ..., @var{URLN} are the urls of the
114 resource to be concatenated, each one possibly specifying a distinct
115 protocol.
116
117 For example to read a sequence of files @file{split1.mpeg},
118 @file{split2.mpeg}, @file{split3.mpeg} with @command{ffplay} use the
119 command:
120 @example
121 ffplay concat:split1.mpeg\|split2.mpeg\|split3.mpeg
122 @end example
123
124 Note that you may need to escape the character "|" which is special for
125 many shells.
126
127 @section crypto
128
129 AES-encrypted stream reading protocol.
130
131 The accepted options are:
132 @table @option
133 @item key
134 Set the AES decryption key binary block from given hexadecimal representation.
135
136 @item iv
137 Set the AES decryption initialization vector binary block from given hexadecimal representation.
138 @end table
139
140 Accepted URL formats:
141 @example
142 crypto:@var{URL}
143 crypto+@var{URL}
144 @end example
145
146 @section data
147
148 Data in-line in the URI. See @url{http://en.wikipedia.org/wiki/Data_URI_scheme}.
149
150 For example, to convert a GIF file given inline with @command{ffmpeg}:
151 @example
152 ffmpeg -i "data:image/gif;base64,R0lGODdhCAAIAMIEAAAAAAAA//8AAP//AP///////////////ywAAAAACAAIAAADF0gEDLojDgdGiJdJqUX02iB4E8Q9jUMkADs=" smiley.png
153 @end example
154
155 @section file
156
157 File access protocol.
158
159 Read from or write to a file.
160
161 A file URL can have the form:
162 @example
163 file:@var{filename}
164 @end example
165
166 where @var{filename} is the path of the file to read.
167
168 An URL that does not have a protocol prefix will be assumed to be a
169 file URL. Depending on the build, an URL that looks like a Windows
170 path with the drive letter at the beginning will also be assumed to be
171 a file URL (usually not the case in builds for unix-like systems).
172
173 For example to read from a file @file{input.mpeg} with @command{ffmpeg}
174 use the command:
175 @example
176 ffmpeg -i file:input.mpeg output.mpeg
177 @end example
178
179 This protocol accepts the following options:
180
181 @table @option
182 @item truncate
183 Truncate existing files on write, if set to 1. A value of 0 prevents
184 truncating. Default value is 1.
185
186 @item blocksize
187 Set I/O operation maximum block size, in bytes. Default value is
188 @code{INT_MAX}, which results in not limiting the requested block size.
189 Setting this value reasonably low improves user termination request reaction
190 time, which is valuable for files on slow medium.
191 @end table
192
193 @section ftp
194
195 FTP (File Transfer Protocol).
196
197 Read from or write to remote resources using FTP protocol.
198
199 Following syntax is required.
200 @example
201 ftp://[user[:password]@@]server[:port]/path/to/remote/resource.mpeg
202 @end example
203
204 This protocol accepts the following options.
205
206 @table @option
207 @item timeout
208 Set timeout in microseconds of socket I/O operations used by the underlying low level
209 operation. By default it is set to -1, which means that the timeout is
210 not specified.
211
212 @item ftp-anonymous-password
213 Password used when login as anonymous user. Typically an e-mail address
214 should be used.
215
216 @item ftp-write-seekable
217 Control seekability of connection during encoding. If set to 1 the
218 resource is supposed to be seekable, if set to 0 it is assumed not
219 to be seekable. Default value is 0.
220 @end table
221
222 NOTE: Protocol can be used as output, but it is recommended to not do
223 it, unless special care is taken (tests, customized server configuration
224 etc.). Different FTP servers behave in different way during seek
225 operation. ff* tools may produce incomplete content due to server limitations.
226
227 This protocol accepts the following options:
228
229 @table @option
230 @item follow
231 If set to 1, the protocol will retry reading at the end of the file, allowing
232 reading files that still are being written. In order for this to terminate,
233 you either need to use the rw_timeout option, or use the interrupt callback
234 (for API users).
235
236 @end table
237
238 @section gopher
239
240 Gopher protocol.
241
242 @section hls
243
244 Read Apple HTTP Live Streaming compliant segmented stream as
245 a uniform one. The M3U8 playlists describing the segments can be
246 remote HTTP resources or local files, accessed using the standard
247 file protocol.
248 The nested protocol is declared by specifying
249 "+@var{proto}" after the hls URI scheme name, where @var{proto}
250 is either "file" or "http".
251
252 @example
253 hls+http://host/path/to/remote/resource.m3u8
254 hls+file://path/to/local/resource.m3u8
255 @end example
256
257 Using this protocol is discouraged - the hls demuxer should work
258 just as well (if not, please report the issues) and is more complete.
259 To use the hls demuxer instead, simply use the direct URLs to the
260 m3u8 files.
261
262 @section http
263
264 HTTP (Hyper Text Transfer Protocol).
265
266 This protocol accepts the following options:
267
268 @table @option
269 @item seekable
270 Control seekability of connection. If set to 1 the resource is
271 supposed to be seekable, if set to 0 it is assumed not to be seekable,
272 if set to -1 it will try to autodetect if it is seekable. Default
273 value is -1.
274
275 @item chunked_post
276 If set to 1 use chunked Transfer-Encoding for posts, default is 1.
277
278 @item content_type
279 Set a specific content type for the POST messages or for listen mode.
280
281 @item http_proxy
282 set HTTP proxy to tunnel through e.g. http://example.com:1234
283
284 @item headers
285 Set custom HTTP headers, can override built in default headers. The
286 value must be a string encoding the headers.
287
288 @item multiple_requests
289 Use persistent connections if set to 1, default is 0.
290
291 @item post_data
292 Set custom HTTP post data.
293
294 @item user_agent
295 Override the User-Agent header. If not specified the protocol will use a
296 string describing the libavformat build. ("Lavf/<version>")
297
298 @item user-agent
299 This is a deprecated option, you can use user_agent instead it.
300
301 @item timeout
302 Set timeout in microseconds of socket I/O operations used by the underlying low level
303 operation. By default it is set to -1, which means that the timeout is
304 not specified.
305
306 @item reconnect_at_eof
307 If set then eof is treated like an error and causes reconnection, this is useful
308 for live / endless streams.
309
310 @item reconnect_streamed
311 If set then even streamed/non seekable streams will be reconnected on errors.
312
313 @item reconnect_delay_max
314 Sets the maximum delay in seconds after which to give up reconnecting
315
316 @item mime_type
317 Export the MIME type.
318
319 @item icy
320 If set to 1 request ICY (SHOUTcast) metadata from the server. If the server
321 supports this, the metadata has to be retrieved by the application by reading
322 the @option{icy_metadata_headers} and @option{icy_metadata_packet} options.
323 The default is 1.
324
325 @item icy_metadata_headers
326 If the server supports ICY metadata, this contains the ICY-specific HTTP reply
327 headers, separated by newline characters.
328
329 @item icy_metadata_packet
330 If the server supports ICY metadata, and @option{icy} was set to 1, this
331 contains the last non-empty metadata packet sent by the server. It should be
332 polled in regular intervals by applications interested in mid-stream metadata
333 updates.
334
335 @item cookies
336 Set the cookies to be sent in future requests. The format of each cookie is the
337 same as the value of a Set-Cookie HTTP response field. Multiple cookies can be
338 delimited by a newline character.
339
340 @item offset
341 Set initial byte offset.
342
343 @item end_offset
344 Try to limit the request to bytes preceding this offset.
345
346 @item method
347 When used as a client option it sets the HTTP method for the request.
348
349 When used as a server option it sets the HTTP method that is going to be
350 expected from the client(s).
351 If the expected and the received HTTP method do not match the client will
352 be given a Bad Request response.
353 When unset the HTTP method is not checked for now. This will be replaced by
354 autodetection in the future.
355
356 @item listen
357 If set to 1 enables experimental HTTP server. This can be used to send data when
358 used as an output option, or read data from a client with HTTP POST when used as
359 an input option.
360 If set to 2 enables experimental multi-client HTTP server. This is not yet implemented
361 in ffmpeg.c or ffserver.c and thus must not be used as a command line option.
362 @example
363 # Server side (sending):
364 ffmpeg -i somefile.ogg -c copy -listen 1 -f ogg http://@var{server}:@var{port}
365
366 # Client side (receiving):
367 ffmpeg -i http://@var{server}:@var{port} -c copy somefile.ogg
368
369 # Client can also be done with wget:
370 wget http://@var{server}:@var{port} -O somefile.ogg
371
372 # Server side (receiving):
373 ffmpeg -listen 1 -i http://@var{server}:@var{port} -c copy somefile.ogg
374
375 # Client side (sending):
376 ffmpeg -i somefile.ogg -chunked_post 0 -c copy -f ogg http://@var{server}:@var{port}
377
378 # Client can also be done with wget:
379 wget --post-file=somefile.ogg http://@var{server}:@var{port}
380 @end example
381
382 @end table
383
384 @subsection HTTP Cookies
385
386 Some HTTP requests will be denied unless cookie values are passed in with the
387 request. The @option{cookies} option allows these cookies to be specified. At
388 the very least, each cookie must specify a value along with a path and domain.
389 HTTP requests that match both the domain and path will automatically include the
390 cookie value in the HTTP Cookie header field. Multiple cookies can be delimited
391 by a newline.
392
393 The required syntax to play a stream specifying a cookie is:
394 @example
395 ffplay -cookies "nlqptid=nltid=tsn; path=/; domain=somedomain.com;" http://somedomain.com/somestream.m3u8
396 @end example
397
398 @section Icecast
399
400 Icecast protocol (stream to Icecast servers)
401
402 This protocol accepts the following options:
403
404 @table @option
405 @item ice_genre
406 Set the stream genre.
407
408 @item ice_name
409 Set the stream name.
410
411 @item ice_description
412 Set the stream description.
413
414 @item ice_url
415 Set the stream website URL.
416
417 @item ice_public
418 Set if the stream should be public.
419 The default is 0 (not public).
420
421 @item user_agent
422 Override the User-Agent header. If not specified a string of the form
423 "Lavf/<version>" will be used.
424
425 @item password
426 Set the Icecast mountpoint password.
427
428 @item content_type
429 Set the stream content type. This must be set if it is different from
430 audio/mpeg.
431
432 @item legacy_icecast
433 This enables support for Icecast versions < 2.4.0, that do not support the
434 HTTP PUT method but the SOURCE method.
435
436 @end table
437
438 @example
439 icecast://[@var{username}[:@var{password}]@@]@var{server}:@var{port}/@var{mountpoint}
440 @end example
441
442 @section mmst
443
444 MMS (Microsoft Media Server) protocol over TCP.
445
446 @section mmsh
447
448 MMS (Microsoft Media Server) protocol over HTTP.
449
450 The required syntax is:
451 @example
452 mmsh://@var{server}[:@var{port}][/@var{app}][/@var{playpath}]
453 @end example
454
455 @section md5
456
457 MD5 output protocol.
458
459 Computes the MD5 hash of the data to be written, and on close writes
460 this to the designated output or stdout if none is specified. It can
461 be used to test muxers without writing an actual file.
462
463 Some examples follow.
464 @example
465 # Write the MD5 hash of the encoded AVI file to the file output.avi.md5.
466 ffmpeg -i input.flv -f avi -y md5:output.avi.md5
467
468 # Write the MD5 hash of the encoded AVI file to stdout.
469 ffmpeg -i input.flv -f avi -y md5:
470 @end example
471
472 Note that some formats (typically MOV) require the output protocol to
473 be seekable, so they will fail with the MD5 output protocol.
474
475 @section pipe
476
477 UNIX pipe access protocol.
478
479 Read and write from UNIX pipes.
480
481 The accepted syntax is:
482 @example
483 pipe:[@var{number}]
484 @end example
485
486 @var{number} is the number corresponding to the file descriptor of the
487 pipe (e.g. 0 for stdin, 1 for stdout, 2 for stderr).  If @var{number}
488 is not specified, by default the stdout file descriptor will be used
489 for writing, stdin for reading.
490
491 For example to read from stdin with @command{ffmpeg}:
492 @example
493 cat test.wav | ffmpeg -i pipe:0
494 # ...this is the same as...
495 cat test.wav | ffmpeg -i pipe:
496 @end example
497
498 For writing to stdout with @command{ffmpeg}:
499 @example
500 ffmpeg -i test.wav -f avi pipe:1 | cat > test.avi
501 # ...this is the same as...
502 ffmpeg -i test.wav -f avi pipe: | cat > test.avi
503 @end example
504
505 This protocol accepts the following options:
506
507 @table @option
508 @item blocksize
509 Set I/O operation maximum block size, in bytes. Default value is
510 @code{INT_MAX}, which results in not limiting the requested block size.
511 Setting this value reasonably low improves user termination request reaction
512 time, which is valuable if data transmission is slow.
513 @end table
514
515 Note that some formats (typically MOV), require the output protocol to
516 be seekable, so they will fail with the pipe output protocol.
517
518 @section prompeg
519
520 Pro-MPEG Code of Practice #3 Release 2 FEC protocol.
521
522 The Pro-MPEG CoP#3 FEC is a 2D parity-check forward error correction mechanism
523 for MPEG-2 Transport Streams sent over RTP.
524
525 This protocol must be used in conjunction with the @code{rtp_mpegts} muxer and
526 the @code{rtp} protocol.
527
528 The required syntax is:
529 @example
530 -f rtp_mpegts -fec prompeg=@var{option}=@var{val}... rtp://@var{hostname}:@var{port}
531 @end example
532
533 The destination UDP ports are @code{port + 2} for the column FEC stream
534 and @code{port + 4} for the row FEC stream.
535
536 This protocol accepts the following options:
537 @table @option
538
539 @item l=@var{n}
540 The number of columns (4-20, LxD <= 100)
541
542 @item d=@var{n}
543 The number of rows (4-20, LxD <= 100)
544
545 @end table
546
547 Example usage:
548
549 @example
550 -f rtp_mpegts -fec prompeg=l=8:d=4 rtp://@var{hostname}:@var{port}
551 @end example
552
553 @section rtmp
554
555 Real-Time Messaging Protocol.
556
557 The Real-Time Messaging Protocol (RTMP) is used for streaming multimedia
558 content across a TCP/IP network.
559
560 The required syntax is:
561 @example
562 rtmp://[@var{username}:@var{password}@@]@var{server}[:@var{port}][/@var{app}][/@var{instance}][/@var{playpath}]
563 @end example
564
565 The accepted parameters are:
566 @table @option
567
568 @item username
569 An optional username (mostly for publishing).
570
571 @item password
572 An optional password (mostly for publishing).
573
574 @item server
575 The address of the RTMP server.
576
577 @item port
578 The number of the TCP port to use (by default is 1935).
579
580 @item app
581 It is the name of the application to access. It usually corresponds to
582 the path where the application is installed on the RTMP server
583 (e.g. @file{/ondemand/}, @file{/flash/live/}, etc.). You can override
584 the value parsed from the URI through the @code{rtmp_app} option, too.
585
586 @item playpath
587 It is the path or name of the resource to play with reference to the
588 application specified in @var{app}, may be prefixed by "mp4:". You
589 can override the value parsed from the URI through the @code{rtmp_playpath}
590 option, too.
591
592 @item listen
593 Act as a server, listening for an incoming connection.
594
595 @item timeout
596 Maximum time to wait for the incoming connection. Implies listen.
597 @end table
598
599 Additionally, the following parameters can be set via command line options
600 (or in code via @code{AVOption}s):
601 @table @option
602
603 @item rtmp_app
604 Name of application to connect on the RTMP server. This option
605 overrides the parameter specified in the URI.
606
607 @item rtmp_buffer
608 Set the client buffer time in milliseconds. The default is 3000.
609
610 @item rtmp_conn
611 Extra arbitrary AMF connection parameters, parsed from a string,
612 e.g. like @code{B:1 S:authMe O:1 NN:code:1.23 NS:flag:ok O:0}.
613 Each value is prefixed by a single character denoting the type,
614 B for Boolean, N for number, S for string, O for object, or Z for null,
615 followed by a colon. For Booleans the data must be either 0 or 1 for
616 FALSE or TRUE, respectively.  Likewise for Objects the data must be 0 or
617 1 to end or begin an object, respectively. Data items in subobjects may
618 be named, by prefixing the type with 'N' and specifying the name before
619 the value (i.e. @code{NB:myFlag:1}). This option may be used multiple
620 times to construct arbitrary AMF sequences.
621
622 @item rtmp_flashver
623 Version of the Flash plugin used to run the SWF player. The default
624 is LNX 9,0,124,2. (When publishing, the default is FMLE/3.0 (compatible;
625 <libavformat version>).)
626
627 @item rtmp_flush_interval
628 Number of packets flushed in the same request (RTMPT only). The default
629 is 10.
630
631 @item rtmp_live
632 Specify that the media is a live stream. No resuming or seeking in
633 live streams is possible. The default value is @code{any}, which means the
634 subscriber first tries to play the live stream specified in the
635 playpath. If a live stream of that name is not found, it plays the
636 recorded stream. The other possible values are @code{live} and
637 @code{recorded}.
638
639 @item rtmp_pageurl
640 URL of the web page in which the media was embedded. By default no
641 value will be sent.
642
643 @item rtmp_playpath
644 Stream identifier to play or to publish. This option overrides the
645 parameter specified in the URI.
646
647 @item rtmp_subscribe
648 Name of live stream to subscribe to. By default no value will be sent.
649 It is only sent if the option is specified or if rtmp_live
650 is set to live.
651
652 @item rtmp_swfhash
653 SHA256 hash of the decompressed SWF file (32 bytes).
654
655 @item rtmp_swfsize
656 Size of the decompressed SWF file, required for SWFVerification.
657
658 @item rtmp_swfurl
659 URL of the SWF player for the media. By default no value will be sent.
660
661 @item rtmp_swfverify
662 URL to player swf file, compute hash/size automatically.
663
664 @item rtmp_tcurl
665 URL of the target stream. Defaults to proto://host[:port]/app.
666
667 @end table
668
669 For example to read with @command{ffplay} a multimedia resource named
670 "sample" from the application "vod" from an RTMP server "myserver":
671 @example
672 ffplay rtmp://myserver/vod/sample
673 @end example
674
675 To publish to a password protected server, passing the playpath and
676 app names separately:
677 @example
678 ffmpeg -re -i <input> -f flv -rtmp_playpath some/long/path -rtmp_app long/app/name rtmp://username:password@@myserver/
679 @end example
680
681 @section rtmpe
682
683 Encrypted Real-Time Messaging Protocol.
684
685 The Encrypted Real-Time Messaging Protocol (RTMPE) is used for
686 streaming multimedia content within standard cryptographic primitives,
687 consisting of Diffie-Hellman key exchange and HMACSHA256, generating
688 a pair of RC4 keys.
689
690 @section rtmps
691
692 Real-Time Messaging Protocol over a secure SSL connection.
693
694 The Real-Time Messaging Protocol (RTMPS) is used for streaming
695 multimedia content across an encrypted connection.
696
697 @section rtmpt
698
699 Real-Time Messaging Protocol tunneled through HTTP.
700
701 The Real-Time Messaging Protocol tunneled through HTTP (RTMPT) is used
702 for streaming multimedia content within HTTP requests to traverse
703 firewalls.
704
705 @section rtmpte
706
707 Encrypted Real-Time Messaging Protocol tunneled through HTTP.
708
709 The Encrypted Real-Time Messaging Protocol tunneled through HTTP (RTMPTE)
710 is used for streaming multimedia content within HTTP requests to traverse
711 firewalls.
712
713 @section rtmpts
714
715 Real-Time Messaging Protocol tunneled through HTTPS.
716
717 The Real-Time Messaging Protocol tunneled through HTTPS (RTMPTS) is used
718 for streaming multimedia content within HTTPS requests to traverse
719 firewalls.
720
721 @section libsmbclient
722
723 libsmbclient permits one to manipulate CIFS/SMB network resources.
724
725 Following syntax is required.
726
727 @example
728 smb://[[domain:]user[:password@@]]server[/share[/path[/file]]]
729 @end example
730
731 This protocol accepts the following options.
732
733 @table @option
734 @item timeout
735 Set timeout in milliseconds of socket I/O operations used by the underlying
736 low level operation. By default it is set to -1, which means that the timeout
737 is not specified.
738
739 @item truncate
740 Truncate existing files on write, if set to 1. A value of 0 prevents
741 truncating. Default value is 1.
742
743 @item workgroup
744 Set the workgroup used for making connections. By default workgroup is not specified.
745
746 @end table
747
748 For more information see: @url{http://www.samba.org/}.
749
750 @section libssh
751
752 Secure File Transfer Protocol via libssh
753
754 Read from or write to remote resources using SFTP protocol.
755
756 Following syntax is required.
757
758 @example
759 sftp://[user[:password]@@]server[:port]/path/to/remote/resource.mpeg
760 @end example
761
762 This protocol accepts the following options.
763
764 @table @option
765 @item timeout
766 Set timeout of socket I/O operations used by the underlying low level
767 operation. By default it is set to -1, which means that the timeout
768 is not specified.
769
770 @item truncate
771 Truncate existing files on write, if set to 1. A value of 0 prevents
772 truncating. Default value is 1.
773
774 @item private_key
775 Specify the path of the file containing private key to use during authorization.
776 By default libssh searches for keys in the @file{~/.ssh/} directory.
777
778 @end table
779
780 Example: Play a file stored on remote server.
781
782 @example
783 ffplay sftp://user:password@@server_address:22/home/user/resource.mpeg
784 @end example
785
786 @section librtmp rtmp, rtmpe, rtmps, rtmpt, rtmpte
787
788 Real-Time Messaging Protocol and its variants supported through
789 librtmp.
790
791 Requires the presence of the librtmp headers and library during
792 configuration. You need to explicitly configure the build with
793 "--enable-librtmp". If enabled this will replace the native RTMP
794 protocol.
795
796 This protocol provides most client functions and a few server
797 functions needed to support RTMP, RTMP tunneled in HTTP (RTMPT),
798 encrypted RTMP (RTMPE), RTMP over SSL/TLS (RTMPS) and tunneled
799 variants of these encrypted types (RTMPTE, RTMPTS).
800
801 The required syntax is:
802 @example
803 @var{rtmp_proto}://@var{server}[:@var{port}][/@var{app}][/@var{playpath}] @var{options}
804 @end example
805
806 where @var{rtmp_proto} is one of the strings "rtmp", "rtmpt", "rtmpe",
807 "rtmps", "rtmpte", "rtmpts" corresponding to each RTMP variant, and
808 @var{server}, @var{port}, @var{app} and @var{playpath} have the same
809 meaning as specified for the RTMP native protocol.
810 @var{options} contains a list of space-separated options of the form
811 @var{key}=@var{val}.
812
813 See the librtmp manual page (man 3 librtmp) for more information.
814
815 For example, to stream a file in real-time to an RTMP server using
816 @command{ffmpeg}:
817 @example
818 ffmpeg -re -i myfile -f flv rtmp://myserver/live/mystream
819 @end example
820
821 To play the same stream using @command{ffplay}:
822 @example
823 ffplay "rtmp://myserver/live/mystream live=1"
824 @end example
825
826 @section rtp
827
828 Real-time Transport Protocol.
829
830 The required syntax for an RTP URL is:
831 rtp://@var{hostname}[:@var{port}][?@var{option}=@var{val}...]
832
833 @var{port} specifies the RTP port to use.
834
835 The following URL options are supported:
836
837 @table @option
838
839 @item ttl=@var{n}
840 Set the TTL (Time-To-Live) value (for multicast only).
841
842 @item rtcpport=@var{n}
843 Set the remote RTCP port to @var{n}.
844
845 @item localrtpport=@var{n}
846 Set the local RTP port to @var{n}.
847
848 @item localrtcpport=@var{n}'
849 Set the local RTCP port to @var{n}.
850
851 @item pkt_size=@var{n}
852 Set max packet size (in bytes) to @var{n}.
853
854 @item connect=0|1
855 Do a @code{connect()} on the UDP socket (if set to 1) or not (if set
856 to 0).
857
858 @item sources=@var{ip}[,@var{ip}]
859 List allowed source IP addresses.
860
861 @item block=@var{ip}[,@var{ip}]
862 List disallowed (blocked) source IP addresses.
863
864 @item write_to_source=0|1
865 Send packets to the source address of the latest received packet (if
866 set to 1) or to a default remote address (if set to 0).
867
868 @item localport=@var{n}
869 Set the local RTP port to @var{n}.
870
871 This is a deprecated option. Instead, @option{localrtpport} should be
872 used.
873
874 @end table
875
876 Important notes:
877
878 @enumerate
879
880 @item
881 If @option{rtcpport} is not set the RTCP port will be set to the RTP
882 port value plus 1.
883
884 @item
885 If @option{localrtpport} (the local RTP port) is not set any available
886 port will be used for the local RTP and RTCP ports.
887
888 @item
889 If @option{localrtcpport} (the local RTCP port) is not set it will be
890 set to the local RTP port value plus 1.
891 @end enumerate
892
893 @section rtsp
894
895 Real-Time Streaming Protocol.
896
897 RTSP is not technically a protocol handler in libavformat, it is a demuxer
898 and muxer. The demuxer supports both normal RTSP (with data transferred
899 over RTP; this is used by e.g. Apple and Microsoft) and Real-RTSP (with
900 data transferred over RDT).
901
902 The muxer can be used to send a stream using RTSP ANNOUNCE to a server
903 supporting it (currently Darwin Streaming Server and Mischa Spiegelmock's
904 @uref{https://github.com/revmischa/rtsp-server, RTSP server}).
905
906 The required syntax for a RTSP url is:
907 @example
908 rtsp://@var{hostname}[:@var{port}]/@var{path}
909 @end example
910
911 Options can be set on the @command{ffmpeg}/@command{ffplay} command
912 line, or set in code via @code{AVOption}s or in
913 @code{avformat_open_input}.
914
915 The following options are supported.
916
917 @table @option
918 @item initial_pause
919 Do not start playing the stream immediately if set to 1. Default value
920 is 0.
921
922 @item rtsp_transport
923 Set RTSP transport protocols.
924
925 It accepts the following values:
926 @table @samp
927 @item udp
928 Use UDP as lower transport protocol.
929
930 @item tcp
931 Use TCP (interleaving within the RTSP control channel) as lower
932 transport protocol.
933
934 @item udp_multicast
935 Use UDP multicast as lower transport protocol.
936
937 @item http
938 Use HTTP tunneling as lower transport protocol, which is useful for
939 passing proxies.
940 @end table
941
942 Multiple lower transport protocols may be specified, in that case they are
943 tried one at a time (if the setup of one fails, the next one is tried).
944 For the muxer, only the @samp{tcp} and @samp{udp} options are supported.
945
946 @item rtsp_flags
947 Set RTSP flags.
948
949 The following values are accepted:
950 @table @samp
951 @item filter_src
952 Accept packets only from negotiated peer address and port.
953 @item listen
954 Act as a server, listening for an incoming connection.
955 @item prefer_tcp
956 Try TCP for RTP transport first, if TCP is available as RTSP RTP transport.
957 @end table
958
959 Default value is @samp{none}.
960
961 @item allowed_media_types
962 Set media types to accept from the server.
963
964 The following flags are accepted:
965 @table @samp
966 @item video
967 @item audio
968 @item data
969 @end table
970
971 By default it accepts all media types.
972
973 @item min_port
974 Set minimum local UDP port. Default value is 5000.
975
976 @item max_port
977 Set maximum local UDP port. Default value is 65000.
978
979 @item timeout
980 Set maximum timeout (in seconds) to wait for incoming connections.
981
982 A value of -1 means infinite (default). This option implies the
983 @option{rtsp_flags} set to @samp{listen}.
984
985 @item reorder_queue_size
986 Set number of packets to buffer for handling of reordered packets.
987
988 @item stimeout
989 Set socket TCP I/O timeout in microseconds.
990
991 @item user-agent
992 Override User-Agent header. If not specified, it defaults to the
993 libavformat identifier string.
994 @end table
995
996 When receiving data over UDP, the demuxer tries to reorder received packets
997 (since they may arrive out of order, or packets may get lost totally). This
998 can be disabled by setting the maximum demuxing delay to zero (via
999 the @code{max_delay} field of AVFormatContext).
1000
1001 When watching multi-bitrate Real-RTSP streams with @command{ffplay}, the
1002 streams to display can be chosen with @code{-vst} @var{n} and
1003 @code{-ast} @var{n} for video and audio respectively, and can be switched
1004 on the fly by pressing @code{v} and @code{a}.
1005
1006 @subsection Examples
1007
1008 The following examples all make use of the @command{ffplay} and
1009 @command{ffmpeg} tools.
1010
1011 @itemize
1012 @item
1013 Watch a stream over UDP, with a max reordering delay of 0.5 seconds:
1014 @example
1015 ffplay -max_delay 500000 -rtsp_transport udp rtsp://server/video.mp4
1016 @end example
1017
1018 @item
1019 Watch a stream tunneled over HTTP:
1020 @example
1021 ffplay -rtsp_transport http rtsp://server/video.mp4
1022 @end example
1023
1024 @item
1025 Send a stream in realtime to a RTSP server, for others to watch:
1026 @example
1027 ffmpeg -re -i @var{input} -f rtsp -muxdelay 0.1 rtsp://server/live.sdp
1028 @end example
1029
1030 @item
1031 Receive a stream in realtime:
1032 @example
1033 ffmpeg -rtsp_flags listen -i rtsp://ownaddress/live.sdp @var{output}
1034 @end example
1035 @end itemize
1036
1037 @section sap
1038
1039 Session Announcement Protocol (RFC 2974). This is not technically a
1040 protocol handler in libavformat, it is a muxer and demuxer.
1041 It is used for signalling of RTP streams, by announcing the SDP for the
1042 streams regularly on a separate port.
1043
1044 @subsection Muxer
1045
1046 The syntax for a SAP url given to the muxer is:
1047 @example
1048 sap://@var{destination}[:@var{port}][?@var{options}]
1049 @end example
1050
1051 The RTP packets are sent to @var{destination} on port @var{port},
1052 or to port 5004 if no port is specified.
1053 @var{options} is a @code{&}-separated list. The following options
1054 are supported:
1055
1056 @table @option
1057
1058 @item announce_addr=@var{address}
1059 Specify the destination IP address for sending the announcements to.
1060 If omitted, the announcements are sent to the commonly used SAP
1061 announcement multicast address 224.2.127.254 (sap.mcast.net), or
1062 ff0e::2:7ffe if @var{destination} is an IPv6 address.
1063
1064 @item announce_port=@var{port}
1065 Specify the port to send the announcements on, defaults to
1066 9875 if not specified.
1067
1068 @item ttl=@var{ttl}
1069 Specify the time to live value for the announcements and RTP packets,
1070 defaults to 255.
1071
1072 @item same_port=@var{0|1}
1073 If set to 1, send all RTP streams on the same port pair. If zero (the
1074 default), all streams are sent on unique ports, with each stream on a
1075 port 2 numbers higher than the previous.
1076 VLC/Live555 requires this to be set to 1, to be able to receive the stream.
1077 The RTP stack in libavformat for receiving requires all streams to be sent
1078 on unique ports.
1079 @end table
1080
1081 Example command lines follow.
1082
1083 To broadcast a stream on the local subnet, for watching in VLC:
1084
1085 @example
1086 ffmpeg -re -i @var{input} -f sap sap://224.0.0.255?same_port=1
1087 @end example
1088
1089 Similarly, for watching in @command{ffplay}:
1090
1091 @example
1092 ffmpeg -re -i @var{input} -f sap sap://224.0.0.255
1093 @end example
1094
1095 And for watching in @command{ffplay}, over IPv6:
1096
1097 @example
1098 ffmpeg -re -i @var{input} -f sap sap://[ff0e::1:2:3:4]
1099 @end example
1100
1101 @subsection Demuxer
1102
1103 The syntax for a SAP url given to the demuxer is:
1104 @example
1105 sap://[@var{address}][:@var{port}]
1106 @end example
1107
1108 @var{address} is the multicast address to listen for announcements on,
1109 if omitted, the default 224.2.127.254 (sap.mcast.net) is used. @var{port}
1110 is the port that is listened on, 9875 if omitted.
1111
1112 The demuxers listens for announcements on the given address and port.
1113 Once an announcement is received, it tries to receive that particular stream.
1114
1115 Example command lines follow.
1116
1117 To play back the first stream announced on the normal SAP multicast address:
1118
1119 @example
1120 ffplay sap://
1121 @end example
1122
1123 To play back the first stream announced on one the default IPv6 SAP multicast address:
1124
1125 @example
1126 ffplay sap://[ff0e::2:7ffe]
1127 @end example
1128
1129 @section sctp
1130
1131 Stream Control Transmission Protocol.
1132
1133 The accepted URL syntax is:
1134 @example
1135 sctp://@var{host}:@var{port}[?@var{options}]
1136 @end example
1137
1138 The protocol accepts the following options:
1139 @table @option
1140 @item listen
1141 If set to any value, listen for an incoming connection. Outgoing connection is done by default.
1142
1143 @item max_streams
1144 Set the maximum number of streams. By default no limit is set.
1145 @end table
1146
1147 @section srtp
1148
1149 Secure Real-time Transport Protocol.
1150
1151 The accepted options are:
1152 @table @option
1153 @item srtp_in_suite
1154 @item srtp_out_suite
1155 Select input and output encoding suites.
1156
1157 Supported values:
1158 @table @samp
1159 @item AES_CM_128_HMAC_SHA1_80
1160 @item SRTP_AES128_CM_HMAC_SHA1_80
1161 @item AES_CM_128_HMAC_SHA1_32
1162 @item SRTP_AES128_CM_HMAC_SHA1_32
1163 @end table
1164
1165 @item srtp_in_params
1166 @item srtp_out_params
1167 Set input and output encoding parameters, which are expressed by a
1168 base64-encoded representation of a binary block. The first 16 bytes of
1169 this binary block are used as master key, the following 14 bytes are
1170 used as master salt.
1171 @end table
1172
1173 @section subfile
1174
1175 Virtually extract a segment of a file or another stream.
1176 The underlying stream must be seekable.
1177
1178 Accepted options:
1179 @table @option
1180 @item start
1181 Start offset of the extracted segment, in bytes.
1182 @item end
1183 End offset of the extracted segment, in bytes.
1184 @end table
1185
1186 Examples:
1187
1188 Extract a chapter from a DVD VOB file (start and end sectors obtained
1189 externally and multiplied by 2048):
1190 @example
1191 subfile,,start,153391104,end,268142592,,:/media/dvd/VIDEO_TS/VTS_08_1.VOB
1192 @end example
1193
1194 Play an AVI file directly from a TAR archive:
1195 @example
1196 subfile,,start,183241728,end,366490624,,:archive.tar
1197 @end example
1198
1199 @section tee
1200
1201 Writes the output to multiple protocols. The individual outputs are separated
1202 by |
1203
1204 @example
1205 tee:file://path/to/local/this.avi|file://path/to/local/that.avi
1206 @end example
1207
1208 @section tcp
1209
1210 Transmission Control Protocol.
1211
1212 The required syntax for a TCP url is:
1213 @example
1214 tcp://@var{hostname}:@var{port}[?@var{options}]
1215 @end example
1216
1217 @var{options} contains a list of &-separated options of the form
1218 @var{key}=@var{val}.
1219
1220 The list of supported options follows.
1221
1222 @table @option
1223 @item listen=@var{1|0}
1224 Listen for an incoming connection. Default value is 0.
1225
1226 @item timeout=@var{microseconds}
1227 Set raise error timeout, expressed in microseconds.
1228
1229 This option is only relevant in read mode: if no data arrived in more
1230 than this time interval, raise error.
1231
1232 @item listen_timeout=@var{milliseconds}
1233 Set listen timeout, expressed in milliseconds.
1234
1235 @item recv_buffer_size=@var{bytes}
1236 Set receive buffer size, expressed bytes.
1237
1238 @item send_buffer_size=@var{bytes}
1239 Set send buffer size, expressed bytes.
1240 @end table
1241
1242 The following example shows how to setup a listening TCP connection
1243 with @command{ffmpeg}, which is then accessed with @command{ffplay}:
1244 @example
1245 ffmpeg -i @var{input} -f @var{format} tcp://@var{hostname}:@var{port}?listen
1246 ffplay tcp://@var{hostname}:@var{port}
1247 @end example
1248
1249 @section tls
1250
1251 Transport Layer Security (TLS) / Secure Sockets Layer (SSL)
1252
1253 The required syntax for a TLS/SSL url is:
1254 @example
1255 tls://@var{hostname}:@var{port}[?@var{options}]
1256 @end example
1257
1258 The following parameters can be set via command line options
1259 (or in code via @code{AVOption}s):
1260
1261 @table @option
1262
1263 @item ca_file, cafile=@var{filename}
1264 A file containing certificate authority (CA) root certificates to treat
1265 as trusted. If the linked TLS library contains a default this might not
1266 need to be specified for verification to work, but not all libraries and
1267 setups have defaults built in.
1268 The file must be in OpenSSL PEM format.
1269
1270 @item tls_verify=@var{1|0}
1271 If enabled, try to verify the peer that we are communicating with.
1272 Note, if using OpenSSL, this currently only makes sure that the
1273 peer certificate is signed by one of the root certificates in the CA
1274 database, but it does not validate that the certificate actually
1275 matches the host name we are trying to connect to. (With GnuTLS,
1276 the host name is validated as well.)
1277
1278 This is disabled by default since it requires a CA database to be
1279 provided by the caller in many cases.
1280
1281 @item cert_file, cert=@var{filename}
1282 A file containing a certificate to use in the handshake with the peer.
1283 (When operating as server, in listen mode, this is more often required
1284 by the peer, while client certificates only are mandated in certain
1285 setups.)
1286
1287 @item key_file, key=@var{filename}
1288 A file containing the private key for the certificate.
1289
1290 @item listen=@var{1|0}
1291 If enabled, listen for connections on the provided port, and assume
1292 the server role in the handshake instead of the client role.
1293
1294 @end table
1295
1296 Example command lines:
1297
1298 To create a TLS/SSL server that serves an input stream.
1299
1300 @example
1301 ffmpeg -i @var{input} -f @var{format} tls://@var{hostname}:@var{port}?listen&cert=@var{server.crt}&key=@var{server.key}
1302 @end example
1303
1304 To play back a stream from the TLS/SSL server using @command{ffplay}:
1305
1306 @example
1307 ffplay tls://@var{hostname}:@var{port}
1308 @end example
1309
1310 @section udp
1311
1312 User Datagram Protocol.
1313
1314 The required syntax for an UDP URL is:
1315 @example
1316 udp://@var{hostname}:@var{port}[?@var{options}]
1317 @end example
1318
1319 @var{options} contains a list of &-separated options of the form @var{key}=@var{val}.
1320
1321 In case threading is enabled on the system, a circular buffer is used
1322 to store the incoming data, which allows one to reduce loss of data due to
1323 UDP socket buffer overruns. The @var{fifo_size} and
1324 @var{overrun_nonfatal} options are related to this buffer.
1325
1326 The list of supported options follows.
1327
1328 @table @option
1329 @item buffer_size=@var{size}
1330 Set the UDP maximum socket buffer size in bytes. This is used to set either
1331 the receive or send buffer size, depending on what the socket is used for.
1332 Default is 64KB.  See also @var{fifo_size}.
1333
1334 @item bitrate=@var{bitrate}
1335 If set to nonzero, the output will have the specified constant bitrate if the
1336 input has enough packets to sustain it.
1337
1338 @item burst_bits=@var{bits}
1339 When using @var{bitrate} this specifies the maximum number of bits in
1340 packet bursts.
1341
1342 @item localport=@var{port}
1343 Override the local UDP port to bind with.
1344
1345 @item localaddr=@var{addr}
1346 Choose the local IP address. This is useful e.g. if sending multicast
1347 and the host has multiple interfaces, where the user can choose
1348 which interface to send on by specifying the IP address of that interface.
1349
1350 @item pkt_size=@var{size}
1351 Set the size in bytes of UDP packets.
1352
1353 @item reuse=@var{1|0}
1354 Explicitly allow or disallow reusing UDP sockets.
1355
1356 @item ttl=@var{ttl}
1357 Set the time to live value (for multicast only).
1358
1359 @item connect=@var{1|0}
1360 Initialize the UDP socket with @code{connect()}. In this case, the
1361 destination address can't be changed with ff_udp_set_remote_url later.
1362 If the destination address isn't known at the start, this option can
1363 be specified in ff_udp_set_remote_url, too.
1364 This allows finding out the source address for the packets with getsockname,
1365 and makes writes return with AVERROR(ECONNREFUSED) if "destination
1366 unreachable" is received.
1367 For receiving, this gives the benefit of only receiving packets from
1368 the specified peer address/port.
1369
1370 @item sources=@var{address}[,@var{address}]
1371 Only receive packets sent to the multicast group from one of the
1372 specified sender IP addresses.
1373
1374 @item block=@var{address}[,@var{address}]
1375 Ignore packets sent to the multicast group from the specified
1376 sender IP addresses.
1377
1378 @item fifo_size=@var{units}
1379 Set the UDP receiving circular buffer size, expressed as a number of
1380 packets with size of 188 bytes. If not specified defaults to 7*4096.
1381
1382 @item overrun_nonfatal=@var{1|0}
1383 Survive in case of UDP receiving circular buffer overrun. Default
1384 value is 0.
1385
1386 @item timeout=@var{microseconds}
1387 Set raise error timeout, expressed in microseconds.
1388
1389 This option is only relevant in read mode: if no data arrived in more
1390 than this time interval, raise error.
1391
1392 @item broadcast=@var{1|0}
1393 Explicitly allow or disallow UDP broadcasting.
1394
1395 Note that broadcasting may not work properly on networks having
1396 a broadcast storm protection.
1397 @end table
1398
1399 @subsection Examples
1400
1401 @itemize
1402 @item
1403 Use @command{ffmpeg} to stream over UDP to a remote endpoint:
1404 @example
1405 ffmpeg -i @var{input} -f @var{format} udp://@var{hostname}:@var{port}
1406 @end example
1407
1408 @item
1409 Use @command{ffmpeg} to stream in mpegts format over UDP using 188
1410 sized UDP packets, using a large input buffer:
1411 @example
1412 ffmpeg -i @var{input} -f mpegts udp://@var{hostname}:@var{port}?pkt_size=188&buffer_size=65535
1413 @end example
1414
1415 @item
1416 Use @command{ffmpeg} to receive over UDP from a remote endpoint:
1417 @example
1418 ffmpeg -i udp://[@var{multicast-address}]:@var{port} ...
1419 @end example
1420 @end itemize
1421
1422 @section unix
1423
1424 Unix local socket
1425
1426 The required syntax for a Unix socket URL is:
1427
1428 @example
1429 unix://@var{filepath}
1430 @end example
1431
1432 The following parameters can be set via command line options
1433 (or in code via @code{AVOption}s):
1434
1435 @table @option
1436 @item timeout
1437 Timeout in ms.
1438 @item listen
1439 Create the Unix socket in listening mode.
1440 @end table
1441
1442 @c man end PROTOCOLS