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.

527 lines
14KB

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