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.

464 lines
13KB

  1. @chapter Protocols
  2. @c man begin PROTOCOLS
  3. Protocols are configured elements in FFmpeg which allow to access
  4. resources which require the use of a particular protocol.
  5. When you configure your FFmpeg 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 applehttp
  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. HTTP is default, specific protocol can be declared using the "+"
  22. specifier.
  23. @example
  24. applehttp://host/path/to/remote/resource.m3u8
  25. applehttp+http://host/path/to/remote/resource.m3u8
  26. applehttp+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{ffplay} use the
  41. command:
  42. @example
  43. ffplay 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 @file{ffmpeg}
  51. use the command:
  52. @example
  53. ffmpeg -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. ffmpeg -i input.flv -f avi -y md5:output.avi.md5
  79. # Write the MD5 hash of the encoded AVI file to stdout.
  80. ffmpeg -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 @file{ffmpeg}:
  96. @example
  97. cat test.wav | ffmpeg -i pipe:0
  98. # ...this is the same as...
  99. cat test.wav | ffmpeg -i pipe:
  100. @end example
  101. For writing to stdout with @file{ffmpeg}:
  102. @example
  103. ffmpeg -i test.wav -f avi pipe:1 | cat > test.avi
  104. # ...this is the same as...
  105. ffmpeg -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 multime‐
  112. dia 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{ffplay} a multimedia resource named
  132. "sample" from the application "vod" from an RTMP server "myserver":
  133. @example
  134. ffplay 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 explicitely 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. @file{ffmpeg}:
  160. @example
  161. ffmpeg -re -i myfile -f flv rtmp://myserver/live/mystream
  162. @end example
  163. To play the same stream using @file{ffplay}:
  164. @example
  165. ffplay "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. RTSP server, @url{http://github.com/revmischa/rtsp-server}).
  177. The required syntax for a RTSP url is:
  178. @example
  179. rtsp://@var{hostname}[:@var{port}]/@var{path}[?@var{options}]
  180. @end example
  181. @var{options} is a @code{&}-separated list. The following options
  182. are supported:
  183. @table @option
  184. @item udp
  185. Use UDP as lower transport protocol.
  186. @item tcp
  187. Use TCP (interleaving within the RTSP control channel) as lower
  188. transport protocol.
  189. @item multicast
  190. Use UDP multicast as lower transport protocol.
  191. @item http
  192. Use HTTP tunneling as lower transport protocol, which is useful for
  193. passing proxies.
  194. @item filter_src
  195. Accept packets only from negotiated peer address and port.
  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. When receiving data over UDP, the demuxer tries to reorder received packets
  201. (since they may arrive out of order, or packets may get lost totally). In
  202. order for this to be enabled, a maximum delay must be specified in the
  203. @code{max_delay} field of AVFormatContext.
  204. When watching multi-bitrate Real-RTSP streams with @file{ffplay}, the
  205. streams to display can be chosen with @code{-vst} @var{n} and
  206. @code{-ast} @var{n} for video and audio respectively, and can be switched
  207. on the fly by pressing @code{v} and @code{a}.
  208. Example command lines:
  209. To watch a stream over UDP, with a max reordering delay of 0.5 seconds:
  210. @example
  211. ffplay -max_delay 500000 rtsp://server/video.mp4?udp
  212. @end example
  213. To watch a stream tunneled over HTTP:
  214. @example
  215. ffplay rtsp://server/video.mp4?http
  216. @end example
  217. To send a stream in realtime to a RTSP server, for others to watch:
  218. @example
  219. ffmpeg -re -i @var{input} -f rtsp -muxdelay 0.1 rtsp://server/live.sdp
  220. @end example
  221. @section sap
  222. Session Announcement Protocol (RFC 2974). This is not technically a
  223. protocol handler in libavformat, it is a muxer and demuxer.
  224. It is used for signalling of RTP streams, by announcing the SDP for the
  225. streams regularly on a separate port.
  226. @subsection Muxer
  227. The syntax for a SAP url given to the muxer is:
  228. @example
  229. sap://@var{destination}[:@var{port}][?@var{options}]
  230. @end example
  231. The RTP packets are sent to @var{destination} on port @var{port},
  232. or to port 5004 if no port is specified.
  233. @var{options} is a @code{&}-separated list. The following options
  234. are supported:
  235. @table @option
  236. @item announce_addr=@var{address}
  237. Specify the destination IP address for sending the announcements to.
  238. If omitted, the announcements are sent to the commonly used SAP
  239. announcement multicast address 224.2.127.254 (sap.mcast.net), or
  240. ff0e::2:7ffe if @var{destination} is an IPv6 address.
  241. @item announce_port=@var{port}
  242. Specify the port to send the announcements on, defaults to
  243. 9875 if not specified.
  244. @item ttl=@var{ttl}
  245. Specify the time to live value for the announcements and RTP packets,
  246. defaults to 255.
  247. @item same_port=@var{0|1}
  248. If set to 1, send all RTP streams on the same port pair. If zero (the
  249. default), all streams are sent on unique ports, with each stream on a
  250. port 2 numbers higher than the previous.
  251. VLC/Live555 requires this to be set to 1, to be able to receive the stream.
  252. The RTP stack in libavformat for receiving requires all streams to be sent
  253. on unique ports.
  254. @end table
  255. Example command lines follow.
  256. To broadcast a stream on the local subnet, for watching in VLC:
  257. @example
  258. ffmpeg -re -i @var{input} -f sap sap://224.0.0.255?same_port=1
  259. @end example
  260. Similarly, for watching in ffplay:
  261. @example
  262. ffmpeg -re -i @var{input} -f sap sap://224.0.0.255
  263. @end example
  264. And for watching in ffplay, over IPv6:
  265. @example
  266. ffmpeg -re -i @var{input} -f sap sap://[ff0e::1:2:3:4]
  267. @end example
  268. @subsection Demuxer
  269. The syntax for a SAP url given to the demuxer is:
  270. @example
  271. sap://[@var{address}][:@var{port}]
  272. @end example
  273. @var{address} is the multicast address to listen for announcements on,
  274. if omitted, the default 224.2.127.254 (sap.mcast.net) is used. @var{port}
  275. is the port that is listened on, 9875 if omitted.
  276. The demuxers listens for announcements on the given address and port.
  277. Once an announcement is received, it tries to receive that particular stream.
  278. Example command lines follow.
  279. To play back the first stream announced on the normal SAP multicast address:
  280. @example
  281. ffplay sap://
  282. @end example
  283. To play back the first stream announced on one the default IPv6 SAP multicast address:
  284. @example
  285. ffplay sap://[ff0e::2:7ffe]
  286. @end example
  287. @section tcp
  288. Trasmission Control Protocol.
  289. @section udp
  290. User Datagram Protocol.
  291. The required syntax for a UDP url is:
  292. @example
  293. udp://@var{hostname}:@var{port}[?@var{options}]
  294. @end example
  295. @var{options} contains a list of &-seperated options of the form @var{key}=@var{val}.
  296. Follow the list of supported options.
  297. @table @option
  298. @item buffer_size=@var{size}
  299. set the UDP buffer size in bytes
  300. @item localport=@var{port}
  301. override the local UDP port to bind with
  302. @item pkt_size=@var{size}
  303. set the size in bytes of UDP packets
  304. @item reuse=@var{1|0}
  305. explicitly allow or disallow reusing UDP sockets
  306. @item ttl=@var{ttl}
  307. set the time to live value (for multicast only)
  308. @item connect=@var{1|0}
  309. Initialize the UDP socket with @code{connect()}. In this case, the
  310. destination address can't be changed with udp_set_remote_url later.
  311. If the destination address isn't known at the start, this option can
  312. be specified in udp_set_remote_url, too.
  313. This allows finding out the source address for the packets with getsockname,
  314. and makes writes return with AVERROR(ECONNREFUSED) if "destination
  315. unreachable" is received.
  316. For receiving, this gives the benefit of only receiving packets from
  317. the specified peer address/port.
  318. @end table
  319. Some usage examples of the udp protocol with @file{ffmpeg} follow.
  320. To stream over UDP to a remote endpoint:
  321. @example
  322. ffmpeg -i @var{input} -f @var{format} udp://@var{hostname}:@var{port}
  323. @end example
  324. To stream in mpegts format over UDP using 188 sized UDP packets, using a large input buffer:
  325. @example
  326. ffmpeg -i @var{input} -f mpegts udp://@var{hostname}:@var{port}?pkt_size=188&buffer_size=65535
  327. @end example
  328. To receive over UDP from a remote endpoint:
  329. @example
  330. ffmpeg -i udp://[@var{multicast-address}]:@var{port}
  331. @end example
  332. @c man end PROTOCOLS