You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

497 lines
14KB

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