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.

585 lines
17KB

  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.). You can override
  151. the value parsed from the URI through the @code{rtmp_app} option, too.
  152. @item playpath
  153. It is the path or name of the resource to play with reference to the
  154. application specified in @var{app}, may be prefixed by "mp4:". You
  155. can override the value parsed from the URI through the @code{rtmp_playpath}
  156. option, too.
  157. @end table
  158. Additionally, the following parameters can be set via command line options
  159. (or in code via @code{AVOption}s):
  160. @table @option
  161. @item rtmp_app
  162. Name of application to connect on the RTMP server. This option
  163. overrides the parameter specified in the URI.
  164. @item rtmp_buffer
  165. Set the client buffer time in milliseconds. The default is 3000.
  166. @item rtmp_conn
  167. Extra arbitrary AMF connection parameters, parsed from a string,
  168. e.g. like @code{B:1 S:authMe O:1 NN:code:1.23 NS:flag:ok O:0}.
  169. Each value is prefixed by a single character denoting the type,
  170. B for Boolean, N for number, S for string, O for object, or Z for null,
  171. followed by a colon. For Booleans the data must be either 0 or 1 for
  172. FALSE or TRUE, respectively. Likewise for Objects the data must be 0 or
  173. 1 to end or begin an object, respectively. Data items in subobjects may
  174. be named, by prefixing the type with 'N' and specifying the name before
  175. the value (i.e. @code{NB:myFlag:1}). This option may be used multiple
  176. times to construct arbitrary AMF sequences.
  177. @item rtmp_flashver
  178. Version of the Flash plugin used to run the SWF player. The default
  179. is LNX 9,0,124,2.
  180. @item rtmp_live
  181. Specify that the media is a live stream. No resuming or seeking in
  182. live streams is possible. The default value is @code{any}, which means the
  183. subscriber first tries to play the live stream specified in the
  184. playpath. If a live stream of that name is not found, it plays the
  185. recorded stream. The other possible values are @code{live} and
  186. @code{recorded}.
  187. @item rtmp_playpath
  188. Stream identifier to play or to publish. This option overrides the
  189. parameter specified in the URI.
  190. @item rtmp_swfurl
  191. URL of the SWF player for the media. By default no value will be sent.
  192. @item rtmp_tcurl
  193. URL of the target stream.
  194. @end table
  195. For example to read with @command{ffplay} a multimedia resource named
  196. "sample" from the application "vod" from an RTMP server "myserver":
  197. @example
  198. ffplay rtmp://myserver/vod/sample
  199. @end example
  200. @section rtmpt
  201. Real-Time Messaging Protocol tunneled through HTTP.
  202. The Real-Time Messaging Protocol tunneled through HTTP (RTMPT) is used
  203. for streaming multimedia content within HTTP requests to traverse
  204. firewalls.
  205. @section rtmp, rtmpe, rtmps, rtmpt, rtmpte
  206. Real-Time Messaging Protocol and its variants supported through
  207. librtmp.
  208. Requires the presence of the librtmp headers and library during
  209. configuration. You need to explicitly configure the build with
  210. "--enable-librtmp". If enabled this will replace the native RTMP
  211. protocol.
  212. This protocol provides most client functions and a few server
  213. functions needed to support RTMP, RTMP tunneled in HTTP (RTMPT),
  214. encrypted RTMP (RTMPE), RTMP over SSL/TLS (RTMPS) and tunneled
  215. variants of these encrypted types (RTMPTE, RTMPTS).
  216. The required syntax is:
  217. @example
  218. @var{rtmp_proto}://@var{server}[:@var{port}][/@var{app}][/@var{playpath}] @var{options}
  219. @end example
  220. where @var{rtmp_proto} is one of the strings "rtmp", "rtmpt", "rtmpe",
  221. "rtmps", "rtmpte", "rtmpts" corresponding to each RTMP variant, and
  222. @var{server}, @var{port}, @var{app} and @var{playpath} have the same
  223. meaning as specified for the RTMP native protocol.
  224. @var{options} contains a list of space-separated options of the form
  225. @var{key}=@var{val}.
  226. See the librtmp manual page (man 3 librtmp) for more information.
  227. For example, to stream a file in real-time to an RTMP server using
  228. @command{ffmpeg}:
  229. @example
  230. ffmpeg -re -i myfile -f flv rtmp://myserver/live/mystream
  231. @end example
  232. To play the same stream using @command{ffplay}:
  233. @example
  234. ffplay "rtmp://myserver/live/mystream live=1"
  235. @end example
  236. @section rtp
  237. Real-Time Protocol.
  238. @section rtsp
  239. RTSP is not technically a protocol handler in libavformat, it is a demuxer
  240. and muxer. The demuxer supports both normal RTSP (with data transferred
  241. over RTP; this is used by e.g. Apple and Microsoft) and Real-RTSP (with
  242. data transferred over RDT).
  243. The muxer can be used to send a stream using RTSP ANNOUNCE to a server
  244. supporting it (currently Darwin Streaming Server and Mischa Spiegelmock's
  245. @uref{http://github.com/revmischa/rtsp-server, RTSP server}).
  246. The required syntax for a RTSP url is:
  247. @example
  248. rtsp://@var{hostname}[:@var{port}]/@var{path}
  249. @end example
  250. The following options (set on the @command{ffmpeg}/@command{ffplay} command
  251. line, or set in code via @code{AVOption}s or in @code{avformat_open_input}),
  252. are supported:
  253. Flags for @code{rtsp_transport}:
  254. @table @option
  255. @item udp
  256. Use UDP as lower transport protocol.
  257. @item tcp
  258. Use TCP (interleaving within the RTSP control channel) as lower
  259. transport protocol.
  260. @item udp_multicast
  261. Use UDP multicast as lower transport protocol.
  262. @item http
  263. Use HTTP tunneling as lower transport protocol, which is useful for
  264. passing proxies.
  265. @end table
  266. Multiple lower transport protocols may be specified, in that case they are
  267. tried one at a time (if the setup of one fails, the next one is tried).
  268. For the muxer, only the @code{tcp} and @code{udp} options are supported.
  269. Flags for @code{rtsp_flags}:
  270. @table @option
  271. @item filter_src
  272. Accept packets only from negotiated peer address and port.
  273. @end table
  274. When receiving data over UDP, the demuxer tries to reorder received packets
  275. (since they may arrive out of order, or packets may get lost totally). This
  276. can be disabled by setting the maximum demuxing delay to zero (via
  277. the @code{max_delay} field of AVFormatContext).
  278. When watching multi-bitrate Real-RTSP streams with @command{ffplay}, the
  279. streams to display can be chosen with @code{-vst} @var{n} and
  280. @code{-ast} @var{n} for video and audio respectively, and can be switched
  281. on the fly by pressing @code{v} and @code{a}.
  282. Example command lines:
  283. To watch a stream over UDP, with a max reordering delay of 0.5 seconds:
  284. @example
  285. ffplay -max_delay 500000 -rtsp_transport udp rtsp://server/video.mp4
  286. @end example
  287. To watch a stream tunneled over HTTP:
  288. @example
  289. ffplay -rtsp_transport http rtsp://server/video.mp4
  290. @end example
  291. To send a stream in realtime to a RTSP server, for others to watch:
  292. @example
  293. ffmpeg -re -i @var{input} -f rtsp -muxdelay 0.1 rtsp://server/live.sdp
  294. @end example
  295. @section sap
  296. Session Announcement Protocol (RFC 2974). This is not technically a
  297. protocol handler in libavformat, it is a muxer and demuxer.
  298. It is used for signalling of RTP streams, by announcing the SDP for the
  299. streams regularly on a separate port.
  300. @subsection Muxer
  301. The syntax for a SAP url given to the muxer is:
  302. @example
  303. sap://@var{destination}[:@var{port}][?@var{options}]
  304. @end example
  305. The RTP packets are sent to @var{destination} on port @var{port},
  306. or to port 5004 if no port is specified.
  307. @var{options} is a @code{&}-separated list. The following options
  308. are supported:
  309. @table @option
  310. @item announce_addr=@var{address}
  311. Specify the destination IP address for sending the announcements to.
  312. If omitted, the announcements are sent to the commonly used SAP
  313. announcement multicast address 224.2.127.254 (sap.mcast.net), or
  314. ff0e::2:7ffe if @var{destination} is an IPv6 address.
  315. @item announce_port=@var{port}
  316. Specify the port to send the announcements on, defaults to
  317. 9875 if not specified.
  318. @item ttl=@var{ttl}
  319. Specify the time to live value for the announcements and RTP packets,
  320. defaults to 255.
  321. @item same_port=@var{0|1}
  322. If set to 1, send all RTP streams on the same port pair. If zero (the
  323. default), all streams are sent on unique ports, with each stream on a
  324. port 2 numbers higher than the previous.
  325. VLC/Live555 requires this to be set to 1, to be able to receive the stream.
  326. The RTP stack in libavformat for receiving requires all streams to be sent
  327. on unique ports.
  328. @end table
  329. Example command lines follow.
  330. To broadcast a stream on the local subnet, for watching in VLC:
  331. @example
  332. ffmpeg -re -i @var{input} -f sap sap://224.0.0.255?same_port=1
  333. @end example
  334. Similarly, for watching in @command{ffplay}:
  335. @example
  336. ffmpeg -re -i @var{input} -f sap sap://224.0.0.255
  337. @end example
  338. And for watching in @command{ffplay}, over IPv6:
  339. @example
  340. ffmpeg -re -i @var{input} -f sap sap://[ff0e::1:2:3:4]
  341. @end example
  342. @subsection Demuxer
  343. The syntax for a SAP url given to the demuxer is:
  344. @example
  345. sap://[@var{address}][:@var{port}]
  346. @end example
  347. @var{address} is the multicast address to listen for announcements on,
  348. if omitted, the default 224.2.127.254 (sap.mcast.net) is used. @var{port}
  349. is the port that is listened on, 9875 if omitted.
  350. The demuxers listens for announcements on the given address and port.
  351. Once an announcement is received, it tries to receive that particular stream.
  352. Example command lines follow.
  353. To play back the first stream announced on the normal SAP multicast address:
  354. @example
  355. ffplay sap://
  356. @end example
  357. To play back the first stream announced on one the default IPv6 SAP multicast address:
  358. @example
  359. ffplay sap://[ff0e::2:7ffe]
  360. @end example
  361. @section tcp
  362. Trasmission Control Protocol.
  363. The required syntax for a TCP url is:
  364. @example
  365. tcp://@var{hostname}:@var{port}[?@var{options}]
  366. @end example
  367. @table @option
  368. @item listen
  369. Listen for an incoming connection
  370. @example
  371. ffmpeg -i @var{input} -f @var{format} tcp://@var{hostname}:@var{port}?listen
  372. ffplay tcp://@var{hostname}:@var{port}
  373. @end example
  374. @end table
  375. @section udp
  376. User Datagram Protocol.
  377. The required syntax for a UDP url is:
  378. @example
  379. udp://@var{hostname}:@var{port}[?@var{options}]
  380. @end example
  381. @var{options} contains a list of &-seperated options of the form @var{key}=@var{val}.
  382. Follow the list of supported options.
  383. @table @option
  384. @item buffer_size=@var{size}
  385. set the UDP buffer size in bytes
  386. @item localport=@var{port}
  387. override the local UDP port to bind with
  388. @item localaddr=@var{addr}
  389. Choose the local IP address. This is useful e.g. if sending multicast
  390. and the host has multiple interfaces, where the user can choose
  391. which interface to send on by specifying the IP address of that interface.
  392. @item pkt_size=@var{size}
  393. set the size in bytes of UDP packets
  394. @item reuse=@var{1|0}
  395. explicitly allow or disallow reusing UDP sockets
  396. @item ttl=@var{ttl}
  397. set the time to live value (for multicast only)
  398. @item connect=@var{1|0}
  399. Initialize the UDP socket with @code{connect()}. In this case, the
  400. destination address can't be changed with ff_udp_set_remote_url later.
  401. If the destination address isn't known at the start, this option can
  402. be specified in ff_udp_set_remote_url, too.
  403. This allows finding out the source address for the packets with getsockname,
  404. and makes writes return with AVERROR(ECONNREFUSED) if "destination
  405. unreachable" is received.
  406. For receiving, this gives the benefit of only receiving packets from
  407. the specified peer address/port.
  408. @end table
  409. Some usage examples of the udp protocol with @command{ffmpeg} follow.
  410. To stream over UDP to a remote endpoint:
  411. @example
  412. ffmpeg -i @var{input} -f @var{format} udp://@var{hostname}:@var{port}
  413. @end example
  414. To stream in mpegts format over UDP using 188 sized UDP packets, using a large input buffer:
  415. @example
  416. ffmpeg -i @var{input} -f mpegts udp://@var{hostname}:@var{port}?pkt_size=188&buffer_size=65535
  417. @end example
  418. To receive over UDP from a remote endpoint:
  419. @example
  420. ffmpeg -i udp://[@var{multicast-address}]:@var{port}
  421. @end example
  422. @c man end PROTOCOLS