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.

758 lines
22KB

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