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.

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