]> git.sesse.net Git - ffmpeg/blob - doc/protocols.texi
libavformat: Rename the applehttp protocol to hls
[ffmpeg] / doc / protocols.texi
1 @chapter Protocols
2 @c man begin PROTOCOLS
3
4 Protocols are configured elements in Libav which allow to access
5 resources which require the use of a particular protocol.
6
7 When you configure your Libav 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 hls
23
24 Read Apple HTTP Live Streaming compliant segmented stream as
25 a uniform one. The M3U8 playlists describing the segments can be
26 remote HTTP resources or local files, accessed using the standard
27 file protocol.
28 The nested protocol is declared by specifying
29 "+@var{proto}" after the hls URI scheme name, where @var{proto}
30 is either "file" or "http".
31
32 @example
33 hls+http://host/path/to/remote/resource.m3u8
34 hls+file://path/to/local/resource.m3u8
35 @end example
36
37 @section concat
38
39 Physical concatenation protocol.
40
41 Allow to read and seek from many resource in sequence as if they were
42 a unique resource.
43
44 A URL accepted by this protocol has the syntax:
45 @example
46 concat:@var{URL1}|@var{URL2}|...|@var{URLN}
47 @end example
48
49 where @var{URL1}, @var{URL2}, ..., @var{URLN} are the urls of the
50 resource to be concatenated, each one possibly specifying a distinct
51 protocol.
52
53 For example to read a sequence of files @file{split1.mpeg},
54 @file{split2.mpeg}, @file{split3.mpeg} with @file{avplay} use the
55 command:
56 @example
57 avplay concat:split1.mpeg\|split2.mpeg\|split3.mpeg
58 @end example
59
60 Note that you may need to escape the character "|" which is special for
61 many shells.
62
63 @section file
64
65 File access protocol.
66
67 Allow to read from or read to a file.
68
69 For example to read from a file @file{input.mpeg} with @command{avconv}
70 use the command:
71 @example
72 avconv -i file:input.mpeg output.mpeg
73 @end example
74
75 The ff* tools default to the file protocol, that is a resource
76 specified with the name "FILE.mpeg" is interpreted as the URL
77 "file:FILE.mpeg".
78
79 @section gopher
80
81 Gopher protocol.
82
83 @section http
84
85 HTTP (Hyper Text Transfer Protocol).
86
87 @section mmst
88
89 MMS (Microsoft Media Server) protocol over TCP.
90
91 @section mmsh
92
93 MMS (Microsoft Media Server) protocol over HTTP.
94
95 The required syntax is:
96 @example
97 mmsh://@var{server}[:@var{port}][/@var{app}][/@var{playpath}]
98 @end example
99
100 @section md5
101
102 MD5 output protocol.
103
104 Computes the MD5 hash of the data to be written, and on close writes
105 this to the designated output or stdout if none is specified. It can
106 be used to test muxers without writing an actual file.
107
108 Some examples follow.
109 @example
110 # Write the MD5 hash of the encoded AVI file to the file output.avi.md5.
111 avconv -i input.flv -f avi -y md5:output.avi.md5
112
113 # Write the MD5 hash of the encoded AVI file to stdout.
114 avconv -i input.flv -f avi -y md5:
115 @end example
116
117 Note that some formats (typically MOV) require the output protocol to
118 be seekable, so they will fail with the MD5 output protocol.
119
120 @section pipe
121
122 UNIX pipe access protocol.
123
124 Allow to read and write from UNIX pipes.
125
126 The accepted syntax is:
127 @example
128 pipe:[@var{number}]
129 @end example
130
131 @var{number} is the number corresponding to the file descriptor of the
132 pipe (e.g. 0 for stdin, 1 for stdout, 2 for stderr).  If @var{number}
133 is not specified, by default the stdout file descriptor will be used
134 for writing, stdin for reading.
135
136 For example to read from stdin with @command{avconv}:
137 @example
138 cat test.wav | avconv -i pipe:0
139 # ...this is the same as...
140 cat test.wav | avconv -i pipe:
141 @end example
142
143 For writing to stdout with @command{avconv}:
144 @example
145 avconv -i test.wav -f avi pipe:1 | cat > test.avi
146 # ...this is the same as...
147 avconv -i test.wav -f avi pipe: | cat > test.avi
148 @end example
149
150 Note that some formats (typically MOV), require the output protocol to
151 be seekable, so they will fail with the pipe output protocol.
152
153 @section rtmp
154
155 Real-Time Messaging Protocol.
156
157 The Real-Time Messaging Protocol (RTMP) is used for streaming multimedia
158 content across a TCP/IP network.
159
160 The required syntax is:
161 @example
162 rtmp://@var{server}[:@var{port}][/@var{app}][/@var{playpath}]
163 @end example
164
165 The accepted parameters are:
166 @table @option
167
168 @item server
169 The address of the RTMP server.
170
171 @item port
172 The number of the TCP port to use (by default is 1935).
173
174 @item app
175 It is the name of the application to access. It usually corresponds to
176 the path where the application is installed on the RTMP server
177 (e.g. @file{/ondemand/}, @file{/flash/live/}, etc.).
178
179 @item playpath
180 It is the path or name of the resource to play with reference to the
181 application specified in @var{app}, may be prefixed by "mp4:".
182
183 @end table
184
185 For example to read with @file{avplay} a multimedia resource named
186 "sample" from the application "vod" from an RTMP server "myserver":
187 @example
188 avplay rtmp://myserver/vod/sample
189 @end example
190
191 @section rtmp, rtmpe, rtmps, rtmpt, rtmpte
192
193 Real-Time Messaging Protocol and its variants supported through
194 librtmp.
195
196 Requires the presence of the librtmp headers and library during
197 configuration. You need to explicitly configure the build with
198 "--enable-librtmp". If enabled this will replace the native RTMP
199 protocol.
200
201 This protocol provides most client functions and a few server
202 functions needed to support RTMP, RTMP tunneled in HTTP (RTMPT),
203 encrypted RTMP (RTMPE), RTMP over SSL/TLS (RTMPS) and tunneled
204 variants of these encrypted types (RTMPTE, RTMPTS).
205
206 The required syntax is:
207 @example
208 @var{rtmp_proto}://@var{server}[:@var{port}][/@var{app}][/@var{playpath}] @var{options}
209 @end example
210
211 where @var{rtmp_proto} is one of the strings "rtmp", "rtmpt", "rtmpe",
212 "rtmps", "rtmpte", "rtmpts" corresponding to each RTMP variant, and
213 @var{server}, @var{port}, @var{app} and @var{playpath} have the same
214 meaning as specified for the RTMP native protocol.
215 @var{options} contains a list of space-separated options of the form
216 @var{key}=@var{val}.
217
218 See the librtmp manual page (man 3 librtmp) for more information.
219
220 For example, to stream a file in real-time to an RTMP server using
221 @command{avconv}:
222 @example
223 avconv -re -i myfile -f flv rtmp://myserver/live/mystream
224 @end example
225
226 To play the same stream using @file{avplay}:
227 @example
228 avplay "rtmp://myserver/live/mystream live=1"
229 @end example
230
231 @section rtp
232
233 Real-Time Protocol.
234
235 @section rtsp
236
237 RTSP is not technically a protocol handler in libavformat, it is a demuxer
238 and muxer. The demuxer supports both normal RTSP (with data transferred
239 over RTP; this is used by e.g. Apple and Microsoft) and Real-RTSP (with
240 data transferred over RDT).
241
242 The muxer can be used to send a stream using RTSP ANNOUNCE to a server
243 supporting it (currently Darwin Streaming Server and Mischa Spiegelmock's
244 @uref{http://github.com/revmischa/rtsp-server, RTSP server}).
245
246 The required syntax for a RTSP url is:
247 @example
248 rtsp://@var{hostname}[:@var{port}]/@var{path}
249 @end example
250
251 The following options (set on the @command{avconv}/@file{avplay} command
252 line, or set in code via @code{AVOption}s or in @code{avformat_open_input}),
253 are supported:
254
255 Flags for @code{rtsp_transport}:
256
257 @table @option
258
259 @item udp
260 Use UDP as lower transport protocol.
261
262 @item tcp
263 Use TCP (interleaving within the RTSP control channel) as lower
264 transport protocol.
265
266 @item udp_multicast
267 Use UDP multicast as lower transport protocol.
268
269 @item http
270 Use HTTP tunneling as lower transport protocol, which is useful for
271 passing proxies.
272 @end table
273
274 Multiple lower transport protocols may be specified, in that case they are
275 tried one at a time (if the setup of one fails, the next one is tried).
276 For the muxer, only the @code{tcp} and @code{udp} options are supported.
277
278 Flags for @code{rtsp_flags}:
279
280 @table @option
281 @item filter_src
282 Accept packets only from negotiated peer address and port.
283 @end table
284
285 When receiving data over UDP, the demuxer tries to reorder received packets
286 (since they may arrive out of order, or packets may get lost totally). In
287 order for this to be enabled, a maximum delay must be specified in the
288 @code{max_delay} field of AVFormatContext.
289
290 When watching multi-bitrate Real-RTSP streams with @file{avplay}, the
291 streams to display can be chosen with @code{-vst} @var{n} and
292 @code{-ast} @var{n} for video and audio respectively, and can be switched
293 on the fly by pressing @code{v} and @code{a}.
294
295 Example command lines:
296
297 To watch a stream over UDP, with a max reordering delay of 0.5 seconds:
298
299 @example
300 avplay -max_delay 500000 -rtsp_transport udp rtsp://server/video.mp4
301 @end example
302
303 To watch a stream tunneled over HTTP:
304
305 @example
306 avplay -rtsp_transport http rtsp://server/video.mp4
307 @end example
308
309 To send a stream in realtime to a RTSP server, for others to watch:
310
311 @example
312 avconv -re -i @var{input} -f rtsp -muxdelay 0.1 rtsp://server/live.sdp
313 @end example
314
315 @section sap
316
317 Session Announcement Protocol (RFC 2974). This is not technically a
318 protocol handler in libavformat, it is a muxer and demuxer.
319 It is used for signalling of RTP streams, by announcing the SDP for the
320 streams regularly on a separate port.
321
322 @subsection Muxer
323
324 The syntax for a SAP url given to the muxer is:
325 @example
326 sap://@var{destination}[:@var{port}][?@var{options}]
327 @end example
328
329 The RTP packets are sent to @var{destination} on port @var{port},
330 or to port 5004 if no port is specified.
331 @var{options} is a @code{&}-separated list. The following options
332 are supported:
333
334 @table @option
335
336 @item announce_addr=@var{address}
337 Specify the destination IP address for sending the announcements to.
338 If omitted, the announcements are sent to the commonly used SAP
339 announcement multicast address 224.2.127.254 (sap.mcast.net), or
340 ff0e::2:7ffe if @var{destination} is an IPv6 address.
341
342 @item announce_port=@var{port}
343 Specify the port to send the announcements on, defaults to
344 9875 if not specified.
345
346 @item ttl=@var{ttl}
347 Specify the time to live value for the announcements and RTP packets,
348 defaults to 255.
349
350 @item same_port=@var{0|1}
351 If set to 1, send all RTP streams on the same port pair. If zero (the
352 default), all streams are sent on unique ports, with each stream on a
353 port 2 numbers higher than the previous.
354 VLC/Live555 requires this to be set to 1, to be able to receive the stream.
355 The RTP stack in libavformat for receiving requires all streams to be sent
356 on unique ports.
357 @end table
358
359 Example command lines follow.
360
361 To broadcast a stream on the local subnet, for watching in VLC:
362
363 @example
364 avconv -re -i @var{input} -f sap sap://224.0.0.255?same_port=1
365 @end example
366
367 Similarly, for watching in avplay:
368
369 @example
370 avconv -re -i @var{input} -f sap sap://224.0.0.255
371 @end example
372
373 And for watching in avplay, over IPv6:
374
375 @example
376 avconv -re -i @var{input} -f sap sap://[ff0e::1:2:3:4]
377 @end example
378
379 @subsection Demuxer
380
381 The syntax for a SAP url given to the demuxer is:
382 @example
383 sap://[@var{address}][:@var{port}]
384 @end example
385
386 @var{address} is the multicast address to listen for announcements on,
387 if omitted, the default 224.2.127.254 (sap.mcast.net) is used. @var{port}
388 is the port that is listened on, 9875 if omitted.
389
390 The demuxers listens for announcements on the given address and port.
391 Once an announcement is received, it tries to receive that particular stream.
392
393 Example command lines follow.
394
395 To play back the first stream announced on the normal SAP multicast address:
396
397 @example
398 avplay sap://
399 @end example
400
401 To play back the first stream announced on one the default IPv6 SAP multicast address:
402
403 @example
404 avplay sap://[ff0e::2:7ffe]
405 @end example
406
407 @section tcp
408
409 Trasmission Control Protocol.
410
411 The required syntax for a TCP url is:
412 @example
413 tcp://@var{hostname}:@var{port}[?@var{options}]
414 @end example
415
416 @table @option
417
418 @item listen
419 Listen for an incoming connection
420
421 @example
422 avconv -i @var{input} -f @var{format} tcp://@var{hostname}:@var{port}?listen
423 avplay tcp://@var{hostname}:@var{port}
424 @end example
425
426 @end table
427
428 @section udp
429
430 User Datagram Protocol.
431
432 The required syntax for a UDP url is:
433 @example
434 udp://@var{hostname}:@var{port}[?@var{options}]
435 @end example
436
437 @var{options} contains a list of &-seperated options of the form @var{key}=@var{val}.
438 Follow the list of supported options.
439
440 @table @option
441
442 @item buffer_size=@var{size}
443 set the UDP buffer size in bytes
444
445 @item localport=@var{port}
446 override the local UDP port to bind with
447
448 @item localaddr=@var{addr}
449 Choose the local IP address. This is useful e.g. if sending multicast
450 and the host has multiple interfaces, where the user can choose
451 which interface to send on by specifying the IP address of that interface.
452
453 @item pkt_size=@var{size}
454 set the size in bytes of UDP packets
455
456 @item reuse=@var{1|0}
457 explicitly allow or disallow reusing UDP sockets
458
459 @item ttl=@var{ttl}
460 set the time to live value (for multicast only)
461
462 @item connect=@var{1|0}
463 Initialize the UDP socket with @code{connect()}. In this case, the
464 destination address can't be changed with ff_udp_set_remote_url later.
465 If the destination address isn't known at the start, this option can
466 be specified in ff_udp_set_remote_url, too.
467 This allows finding out the source address for the packets with getsockname,
468 and makes writes return with AVERROR(ECONNREFUSED) if "destination
469 unreachable" is received.
470 For receiving, this gives the benefit of only receiving packets from
471 the specified peer address/port.
472 @end table
473
474 Some usage examples of the udp protocol with @command{avconv} follow.
475
476 To stream over UDP to a remote endpoint:
477 @example
478 avconv -i @var{input} -f @var{format} udp://@var{hostname}:@var{port}
479 @end example
480
481 To stream in mpegts format over UDP using 188 sized UDP packets, using a large input buffer:
482 @example
483 avconv -i @var{input} -f mpegts udp://@var{hostname}:@var{port}?pkt_size=188&buffer_size=65535
484 @end example
485
486 To receive over UDP from a remote endpoint:
487 @example
488 avconv -i udp://[@var{multicast-address}]:@var{port}
489 @end example
490
491 @c man end PROTOCOLS