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.

734 lines
21KB

  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 data
  56. Data in-line in the URI. See @url{http://en.wikipedia.org/wiki/Data_URI_scheme}.
  57. For example, to convert a GIF file given inline with @command{ffmpeg}:
  58. @example
  59. ffmpeg -i "data:image/gif;base64,R0lGODdhCAAIAMIEAAAAAAAA//8AAP//AP///////////////ywAAAAACAAIAAADF0gEDLojDgdGiJdJqUX02iB4E8Q9jUMkADs=" smiley.png
  60. @end example
  61. @section file
  62. File access protocol.
  63. Allow to read from or read to a file.
  64. For example to read from a file @file{input.mpeg} with @command{ffmpeg}
  65. use the command:
  66. @example
  67. ffmpeg -i file:input.mpeg output.mpeg
  68. @end example
  69. The ff* tools default to the file protocol, that is a resource
  70. specified with the name "FILE.mpeg" is interpreted as the URL
  71. "file:FILE.mpeg".
  72. @section gopher
  73. Gopher protocol.
  74. @section hls
  75. Read Apple HTTP Live Streaming compliant segmented stream as
  76. a uniform one. The M3U8 playlists describing the segments can be
  77. remote HTTP resources or local files, accessed using the standard
  78. file protocol.
  79. The nested protocol is declared by specifying
  80. "+@var{proto}" after the hls URI scheme name, where @var{proto}
  81. is either "file" or "http".
  82. @example
  83. hls+http://host/path/to/remote/resource.m3u8
  84. hls+file://path/to/local/resource.m3u8
  85. @end example
  86. Using this protocol is discouraged - the hls demuxer should work
  87. just as well (if not, please report the issues) and is more complete.
  88. To use the hls demuxer instead, simply use the direct URLs to the
  89. m3u8 files.
  90. @section http
  91. HTTP (Hyper Text Transfer Protocol).
  92. @section mmst
  93. MMS (Microsoft Media Server) protocol over TCP.
  94. @section mmsh
  95. MMS (Microsoft Media Server) protocol over HTTP.
  96. The required syntax is:
  97. @example
  98. mmsh://@var{server}[:@var{port}][/@var{app}][/@var{playpath}]
  99. @end example
  100. @section md5
  101. MD5 output protocol.
  102. Computes the MD5 hash of the data to be written, and on close writes
  103. this to the designated output or stdout if none is specified. It can
  104. be used to test muxers without writing an actual file.
  105. Some examples follow.
  106. @example
  107. # Write the MD5 hash of the encoded AVI file to the file output.avi.md5.
  108. ffmpeg -i input.flv -f avi -y md5:output.avi.md5
  109. # Write the MD5 hash of the encoded AVI file to stdout.
  110. ffmpeg -i input.flv -f avi -y md5:
  111. @end example
  112. Note that some formats (typically MOV) require the output protocol to
  113. be seekable, so they will fail with the MD5 output protocol.
  114. @section pipe
  115. UNIX pipe access protocol.
  116. Allow to read and write from UNIX pipes.
  117. The accepted syntax is:
  118. @example
  119. pipe:[@var{number}]
  120. @end example
  121. @var{number} is the number corresponding to the file descriptor of the
  122. pipe (e.g. 0 for stdin, 1 for stdout, 2 for stderr). If @var{number}
  123. is not specified, by default the stdout file descriptor will be used
  124. for writing, stdin for reading.
  125. For example to read from stdin with @command{ffmpeg}:
  126. @example
  127. cat test.wav | ffmpeg -i pipe:0
  128. # ...this is the same as...
  129. cat test.wav | ffmpeg -i pipe:
  130. @end example
  131. For writing to stdout with @command{ffmpeg}:
  132. @example
  133. ffmpeg -i test.wav -f avi pipe:1 | cat > test.avi
  134. # ...this is the same as...
  135. ffmpeg -i test.wav -f avi pipe: | cat > test.avi
  136. @end example
  137. Note that some formats (typically MOV), require the output protocol to
  138. be seekable, so they will fail with the pipe output protocol.
  139. @section rtmp
  140. Real-Time Messaging Protocol.
  141. The Real-Time Messaging Protocol (RTMP) is used for streaming multimedia
  142. content across a TCP/IP network.
  143. The required syntax is:
  144. @example
  145. rtmp://@var{server}[:@var{port}][/@var{app}][/@var{instance}][/@var{playpath}]
  146. @end example
  147. The accepted parameters are:
  148. @table @option
  149. @item server
  150. The address of the RTMP server.
  151. @item port
  152. The number of the TCP port to use (by default is 1935).
  153. @item app
  154. It is the name of the application to access. It usually corresponds to
  155. the path where the application is installed on the RTMP server
  156. (e.g. @file{/ondemand/}, @file{/flash/live/}, etc.). You can override
  157. the value parsed from the URI through the @code{rtmp_app} option, too.
  158. @item playpath
  159. It is the path or name of the resource to play with reference to the
  160. application specified in @var{app}, may be prefixed by "mp4:". You
  161. can override the value parsed from the URI through the @code{rtmp_playpath}
  162. option, too.
  163. @item listen
  164. Act as a server, listening for an incoming connection.
  165. @item timeout
  166. Maximum time to wait for the incoming connection. Implies listen.
  167. @end table
  168. Additionally, the following parameters can be set via command line options
  169. (or in code via @code{AVOption}s):
  170. @table @option
  171. @item rtmp_app
  172. Name of application to connect on the RTMP server. This option
  173. overrides the parameter specified in the URI.
  174. @item rtmp_buffer
  175. Set the client buffer time in milliseconds. The default is 3000.
  176. @item rtmp_conn
  177. Extra arbitrary AMF connection parameters, parsed from a string,
  178. e.g. like @code{B:1 S:authMe O:1 NN:code:1.23 NS:flag:ok O:0}.
  179. Each value is prefixed by a single character denoting the type,
  180. B for Boolean, N for number, S for string, O for object, or Z for null,
  181. followed by a colon. For Booleans the data must be either 0 or 1 for
  182. FALSE or TRUE, respectively. Likewise for Objects the data must be 0 or
  183. 1 to end or begin an object, respectively. Data items in subobjects may
  184. be named, by prefixing the type with 'N' and specifying the name before
  185. the value (i.e. @code{NB:myFlag:1}). This option may be used multiple
  186. times to construct arbitrary AMF sequences.
  187. @item rtmp_flashver
  188. Version of the Flash plugin used to run the SWF player. The default
  189. is LNX 9,0,124,2.
  190. @item rtmp_flush_interval
  191. Number of packets flushed in the same request (RTMPT only). The default
  192. is 10.
  193. @item rtmp_live
  194. Specify that the media is a live stream. No resuming or seeking in
  195. live streams is possible. The default value is @code{any}, which means the
  196. subscriber first tries to play the live stream specified in the
  197. playpath. If a live stream of that name is not found, it plays the
  198. recorded stream. The other possible values are @code{live} and
  199. @code{recorded}.
  200. @item rtmp_pageurl
  201. URL of the web page in which the media was embedded. By default no
  202. value will be sent.
  203. @item rtmp_playpath
  204. Stream identifier to play or to publish. This option overrides the
  205. parameter specified in the URI.
  206. @item rtmp_subscribe
  207. Name of live stream to subscribe to. By default no value will be sent.
  208. It is only sent if the option is specified or if rtmp_live
  209. is set to live.
  210. @item rtmp_swfhash
  211. SHA256 hash of the decompressed SWF file (32 bytes).
  212. @item rtmp_swfsize
  213. Size of the decompressed SWF file, required for SWFVerification.
  214. @item rtmp_swfurl
  215. URL of the SWF player for the media. By default no value will be sent.
  216. @item rtmp_swfverify
  217. URL to player swf file, compute hash/size automatically.
  218. @item rtmp_tcurl
  219. URL of the target stream. Defaults to proto://host[:port]/app.
  220. @end table
  221. For example to read with @command{ffplay} a multimedia resource named
  222. "sample" from the application "vod" from an RTMP server "myserver":
  223. @example
  224. ffplay rtmp://myserver/vod/sample
  225. @end example
  226. @section rtmpe
  227. Encrypted Real-Time Messaging Protocol.
  228. The Encrypted Real-Time Messaging Protocol (RTMPE) is used for
  229. streaming multimedia content within standard cryptographic primitives,
  230. consisting of Diffie-Hellman key exchange and HMACSHA256, generating
  231. a pair of RC4 keys.
  232. @section rtmps
  233. Real-Time Messaging Protocol over a secure SSL connection.
  234. The Real-Time Messaging Protocol (RTMPS) is used for streaming
  235. multimedia content across an encrypted connection.
  236. @section rtmpt
  237. Real-Time Messaging Protocol tunneled through HTTP.
  238. The Real-Time Messaging Protocol tunneled through HTTP (RTMPT) is used
  239. for streaming multimedia content within HTTP requests to traverse
  240. firewalls.
  241. @section rtmpte
  242. Encrypted Real-Time Messaging Protocol tunneled through HTTP.
  243. The Encrypted Real-Time Messaging Protocol tunneled through HTTP (RTMPTE)
  244. is used for streaming multimedia content within HTTP requests to traverse
  245. firewalls.
  246. @section rtmpts
  247. Real-Time Messaging Protocol tunneled through HTTPS.
  248. The Real-Time Messaging Protocol tunneled through HTTPS (RTMPTS) is used
  249. for streaming multimedia content within HTTPS requests to traverse
  250. firewalls.
  251. @section rtmp, rtmpe, rtmps, rtmpt, rtmpte
  252. Real-Time Messaging Protocol and its variants supported through
  253. librtmp.
  254. Requires the presence of the librtmp headers and library during
  255. configuration. You need to explicitly configure the build with
  256. "--enable-librtmp". If enabled this will replace the native RTMP
  257. protocol.
  258. This protocol provides most client functions and a few server
  259. functions needed to support RTMP, RTMP tunneled in HTTP (RTMPT),
  260. encrypted RTMP (RTMPE), RTMP over SSL/TLS (RTMPS) and tunneled
  261. variants of these encrypted types (RTMPTE, RTMPTS).
  262. The required syntax is:
  263. @example
  264. @var{rtmp_proto}://@var{server}[:@var{port}][/@var{app}][/@var{playpath}] @var{options}
  265. @end example
  266. where @var{rtmp_proto} is one of the strings "rtmp", "rtmpt", "rtmpe",
  267. "rtmps", "rtmpte", "rtmpts" corresponding to each RTMP variant, and
  268. @var{server}, @var{port}, @var{app} and @var{playpath} have the same
  269. meaning as specified for the RTMP native protocol.
  270. @var{options} contains a list of space-separated options of the form
  271. @var{key}=@var{val}.
  272. See the librtmp manual page (man 3 librtmp) for more information.
  273. For example, to stream a file in real-time to an RTMP server using
  274. @command{ffmpeg}:
  275. @example
  276. ffmpeg -re -i myfile -f flv rtmp://myserver/live/mystream
  277. @end example
  278. To play the same stream using @command{ffplay}:
  279. @example
  280. ffplay "rtmp://myserver/live/mystream live=1"
  281. @end example
  282. @section rtp
  283. Real-Time Protocol.
  284. @section rtsp
  285. RTSP is not technically a protocol handler in libavformat, it is a demuxer
  286. and muxer. The demuxer supports both normal RTSP (with data transferred
  287. over RTP; this is used by e.g. Apple and Microsoft) and Real-RTSP (with
  288. data transferred over RDT).
  289. The muxer can be used to send a stream using RTSP ANNOUNCE to a server
  290. supporting it (currently Darwin Streaming Server and Mischa Spiegelmock's
  291. @uref{http://github.com/revmischa/rtsp-server, RTSP server}).
  292. The required syntax for a RTSP url is:
  293. @example
  294. rtsp://@var{hostname}[:@var{port}]/@var{path}
  295. @end example
  296. The following options (set on the @command{ffmpeg}/@command{ffplay} command
  297. line, or set in code via @code{AVOption}s or in @code{avformat_open_input}),
  298. are supported:
  299. Flags for @code{rtsp_transport}:
  300. @table @option
  301. @item udp
  302. Use UDP as lower transport protocol.
  303. @item tcp
  304. Use TCP (interleaving within the RTSP control channel) as lower
  305. transport protocol.
  306. @item udp_multicast
  307. Use UDP multicast as lower transport protocol.
  308. @item http
  309. Use HTTP tunneling as lower transport protocol, which is useful for
  310. passing proxies.
  311. @end table
  312. Multiple lower transport protocols may be specified, in that case they are
  313. tried one at a time (if the setup of one fails, the next one is tried).
  314. For the muxer, only the @code{tcp} and @code{udp} options are supported.
  315. Flags for @code{rtsp_flags}:
  316. @table @option
  317. @item filter_src
  318. Accept packets only from negotiated peer address and port.
  319. @item listen
  320. Act as a server, listening for an incoming connection.
  321. @end table
  322. When receiving data over UDP, the demuxer tries to reorder received packets
  323. (since they may arrive out of order, or packets may get lost totally). This
  324. can be disabled by setting the maximum demuxing delay to zero (via
  325. the @code{max_delay} field of AVFormatContext).
  326. When watching multi-bitrate Real-RTSP streams with @command{ffplay}, the
  327. streams to display can be chosen with @code{-vst} @var{n} and
  328. @code{-ast} @var{n} for video and audio respectively, and can be switched
  329. on the fly by pressing @code{v} and @code{a}.
  330. Example command lines:
  331. To watch a stream over UDP, with a max reordering delay of 0.5 seconds:
  332. @example
  333. ffplay -max_delay 500000 -rtsp_transport udp rtsp://server/video.mp4
  334. @end example
  335. To watch a stream tunneled over HTTP:
  336. @example
  337. ffplay -rtsp_transport http rtsp://server/video.mp4
  338. @end example
  339. To send a stream in realtime to a RTSP server, for others to watch:
  340. @example
  341. ffmpeg -re -i @var{input} -f rtsp -muxdelay 0.1 rtsp://server/live.sdp
  342. @end example
  343. To receive a stream in realtime:
  344. @example
  345. ffmpeg -rtsp_flags listen -i rtsp://ownaddress/live.sdp @var{output}
  346. @end example
  347. @section sap
  348. Session Announcement Protocol (RFC 2974). This is not technically a
  349. protocol handler in libavformat, it is a muxer and demuxer.
  350. It is used for signalling of RTP streams, by announcing the SDP for the
  351. streams regularly on a separate port.
  352. @subsection Muxer
  353. The syntax for a SAP url given to the muxer is:
  354. @example
  355. sap://@var{destination}[:@var{port}][?@var{options}]
  356. @end example
  357. The RTP packets are sent to @var{destination} on port @var{port},
  358. or to port 5004 if no port is specified.
  359. @var{options} is a @code{&}-separated list. The following options
  360. are supported:
  361. @table @option
  362. @item announce_addr=@var{address}
  363. Specify the destination IP address for sending the announcements to.
  364. If omitted, the announcements are sent to the commonly used SAP
  365. announcement multicast address 224.2.127.254 (sap.mcast.net), or
  366. ff0e::2:7ffe if @var{destination} is an IPv6 address.
  367. @item announce_port=@var{port}
  368. Specify the port to send the announcements on, defaults to
  369. 9875 if not specified.
  370. @item ttl=@var{ttl}
  371. Specify the time to live value for the announcements and RTP packets,
  372. defaults to 255.
  373. @item same_port=@var{0|1}
  374. If set to 1, send all RTP streams on the same port pair. If zero (the
  375. default), all streams are sent on unique ports, with each stream on a
  376. port 2 numbers higher than the previous.
  377. VLC/Live555 requires this to be set to 1, to be able to receive the stream.
  378. The RTP stack in libavformat for receiving requires all streams to be sent
  379. on unique ports.
  380. @end table
  381. Example command lines follow.
  382. To broadcast a stream on the local subnet, for watching in VLC:
  383. @example
  384. ffmpeg -re -i @var{input} -f sap sap://224.0.0.255?same_port=1
  385. @end example
  386. Similarly, for watching in @command{ffplay}:
  387. @example
  388. ffmpeg -re -i @var{input} -f sap sap://224.0.0.255
  389. @end example
  390. And for watching in @command{ffplay}, over IPv6:
  391. @example
  392. ffmpeg -re -i @var{input} -f sap sap://[ff0e::1:2:3:4]
  393. @end example
  394. @subsection Demuxer
  395. The syntax for a SAP url given to the demuxer is:
  396. @example
  397. sap://[@var{address}][:@var{port}]
  398. @end example
  399. @var{address} is the multicast address to listen for announcements on,
  400. if omitted, the default 224.2.127.254 (sap.mcast.net) is used. @var{port}
  401. is the port that is listened on, 9875 if omitted.
  402. The demuxers listens for announcements on the given address and port.
  403. Once an announcement is received, it tries to receive that particular stream.
  404. Example command lines follow.
  405. To play back the first stream announced on the normal SAP multicast address:
  406. @example
  407. ffplay sap://
  408. @end example
  409. To play back the first stream announced on one the default IPv6 SAP multicast address:
  410. @example
  411. ffplay sap://[ff0e::2:7ffe]
  412. @end example
  413. @section tcp
  414. Trasmission Control Protocol.
  415. The required syntax for a TCP url is:
  416. @example
  417. tcp://@var{hostname}:@var{port}[?@var{options}]
  418. @end example
  419. @table @option
  420. @item listen
  421. Listen for an incoming connection
  422. @item timeout=@var{microseconds}
  423. In read mode: if no data arrived in more than this time interval, raise error.
  424. In write mode: if socket cannot be written in more than this time interval, raise error.
  425. This also sets timeout on TCP connection establishing.
  426. @example
  427. ffmpeg -i @var{input} -f @var{format} tcp://@var{hostname}:@var{port}?listen
  428. ffplay tcp://@var{hostname}:@var{port}
  429. @end example
  430. @end table
  431. @section tls
  432. Transport Layer Security/Secure Sockets Layer
  433. The required syntax for a TLS/SSL url is:
  434. @example
  435. tls://@var{hostname}:@var{port}[?@var{options}]
  436. @end example
  437. @table @option
  438. @item listen
  439. Act as a server, listening for an incoming connection.
  440. @item cafile=@var{filename}
  441. Certificate authority file. The file must be in OpenSSL PEM format.
  442. @item cert=@var{filename}
  443. Certificate file. The file must be in OpenSSL PEM format.
  444. @item key=@var{filename}
  445. Private key file.
  446. @item verify=@var{0|1}
  447. Verify the peer's certificate.
  448. @end table
  449. Example command lines:
  450. To create a TLS/SSL server that serves an input stream.
  451. @example
  452. ffmpeg -i @var{input} -f @var{format} tls://@var{hostname}:@var{port}?listen&cert=@var{server.crt}&key=@var{server.key}
  453. @end example
  454. To play back a stream from the TLS/SSL server using @command{ffplay}:
  455. @example
  456. ffplay tls://@var{hostname}:@var{port}
  457. @end example
  458. @section udp
  459. User Datagram Protocol.
  460. The required syntax for a UDP url is:
  461. @example
  462. udp://@var{hostname}:@var{port}[?@var{options}]
  463. @end example
  464. @var{options} contains a list of &-separated options of the form @var{key}=@var{val}.
  465. In case threading is enabled on the system, a circular buffer is used
  466. to store the incoming data, which allows to reduce loss of data due to
  467. UDP socket buffer overruns. The @var{fifo_size} and
  468. @var{overrun_nonfatal} options are related to this buffer.
  469. The list of supported options follows.
  470. @table @option
  471. @item buffer_size=@var{size}
  472. Set the UDP socket buffer size in bytes. This is used both for the
  473. receiving and the sending buffer size.
  474. @item localport=@var{port}
  475. Override the local UDP port to bind with.
  476. @item localaddr=@var{addr}
  477. Choose the local IP address. This is useful e.g. if sending multicast
  478. and the host has multiple interfaces, where the user can choose
  479. which interface to send on by specifying the IP address of that interface.
  480. @item pkt_size=@var{size}
  481. Set the size in bytes of UDP packets.
  482. @item reuse=@var{1|0}
  483. Explicitly allow or disallow reusing UDP sockets.
  484. @item ttl=@var{ttl}
  485. Set the time to live value (for multicast only).
  486. @item connect=@var{1|0}
  487. Initialize the UDP socket with @code{connect()}. In this case, the
  488. destination address can't be changed with ff_udp_set_remote_url later.
  489. If the destination address isn't known at the start, this option can
  490. be specified in ff_udp_set_remote_url, too.
  491. This allows finding out the source address for the packets with getsockname,
  492. and makes writes return with AVERROR(ECONNREFUSED) if "destination
  493. unreachable" is received.
  494. For receiving, this gives the benefit of only receiving packets from
  495. the specified peer address/port.
  496. @item sources=@var{address}[,@var{address}]
  497. Only receive packets sent to the multicast group from one of the
  498. specified sender IP addresses.
  499. @item block=@var{address}[,@var{address}]
  500. Ignore packets sent to the multicast group from the specified
  501. sender IP addresses.
  502. @item fifo_size=@var{units}
  503. Set the UDP receiving circular buffer size, expressed as a number of
  504. packets with size of 188 bytes. If not specified defaults to 7*4096.
  505. @item overrun_nonfatal=@var{1|0}
  506. Survive in case of UDP receiving circular buffer overrun. Default
  507. value is 0.
  508. @item timeout=@var{microseconds}
  509. In read mode: if no data arrived in more than this time interval, raise error.
  510. @end table
  511. Some usage examples of the UDP protocol with @command{ffmpeg} follow.
  512. To stream over UDP to a remote endpoint:
  513. @example
  514. ffmpeg -i @var{input} -f @var{format} udp://@var{hostname}:@var{port}
  515. @end example
  516. To stream in mpegts format over UDP using 188 sized UDP packets, using a large input buffer:
  517. @example
  518. ffmpeg -i @var{input} -f mpegts udp://@var{hostname}:@var{port}?pkt_size=188&buffer_size=65535
  519. @end example
  520. To receive over UDP from a remote endpoint:
  521. @example
  522. ffmpeg -i udp://[@var{multicast-address}]:@var{port}
  523. @end example
  524. @c man end PROTOCOLS