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.

736 lines
21KB

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