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