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