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.

1208 lines
34KB

  1. @chapter Protocols
  2. @c man begin PROTOCOLS
  3. Protocols are configured elements in FFmpeg that enable access to
  4. resources that require specific protocols.
  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 cache
  37. Caching wrapper for input stream.
  38. Cache the input stream to temporary file. It brings seeking capability to live streams.
  39. @example
  40. cache:@var{URL}
  41. @end example
  42. @section concat
  43. Physical concatenation protocol.
  44. Allow to read and seek from many resource in sequence as if they were
  45. a unique resource.
  46. A URL accepted by this protocol has the syntax:
  47. @example
  48. concat:@var{URL1}|@var{URL2}|...|@var{URLN}
  49. @end example
  50. where @var{URL1}, @var{URL2}, ..., @var{URLN} are the urls of the
  51. resource to be concatenated, each one possibly specifying a distinct
  52. protocol.
  53. For example to read a sequence of files @file{split1.mpeg},
  54. @file{split2.mpeg}, @file{split3.mpeg} with @command{ffplay} use the
  55. command:
  56. @example
  57. ffplay concat:split1.mpeg\|split2.mpeg\|split3.mpeg
  58. @end example
  59. Note that you may need to escape the character "|" which is special for
  60. many shells.
  61. @section crypto
  62. AES-encrypted stream reading protocol.
  63. The accepted options are:
  64. @table @option
  65. @item key
  66. Set the AES decryption key binary block from given hexadecimal representation.
  67. @item iv
  68. Set the AES decryption initialization vector binary block from given hexadecimal representation.
  69. @end table
  70. Accepted URL formats:
  71. @example
  72. crypto:@var{URL}
  73. crypto+@var{URL}
  74. @end example
  75. @section data
  76. Data in-line in the URI. See @url{http://en.wikipedia.org/wiki/Data_URI_scheme}.
  77. For example, to convert a GIF file given inline with @command{ffmpeg}:
  78. @example
  79. ffmpeg -i "data:image/gif;base64,R0lGODdhCAAIAMIEAAAAAAAA//8AAP//AP///////////////ywAAAAACAAIAAADF0gEDLojDgdGiJdJqUX02iB4E8Q9jUMkADs=" smiley.png
  80. @end example
  81. @section file
  82. File access protocol.
  83. Allow to read from or write to a file.
  84. A file URL can have the form:
  85. @example
  86. file:@var{filename}
  87. @end example
  88. where @var{filename} is the path of the file to read.
  89. An URL that does not have a protocol prefix will be assumed to be a
  90. file URL. Depending on the build, an URL that looks like a Windows
  91. path with the drive letter at the beginning will also be assumed to be
  92. a file URL (usually not the case in builds for unix-like systems).
  93. For example to read from a file @file{input.mpeg} with @command{ffmpeg}
  94. use the command:
  95. @example
  96. ffmpeg -i file:input.mpeg output.mpeg
  97. @end example
  98. This protocol accepts the following options:
  99. @table @option
  100. @item truncate
  101. Truncate existing files on write, if set to 1. A value of 0 prevents
  102. truncating. Default value is 1.
  103. @item blocksize
  104. Set I/O operation maximum block size, in bytes. Default value is
  105. @code{INT_MAX}, which results in not limiting the requested block size.
  106. Setting this value reasonably low improves user termination request reaction
  107. time, which is valuable for files on slow medium.
  108. @end table
  109. @section ftp
  110. FTP (File Transfer Protocol).
  111. Allow to read from or write to remote resources using FTP protocol.
  112. Following syntax is required.
  113. @example
  114. ftp://[user[:password]@@]server[:port]/path/to/remote/resource.mpeg
  115. @end example
  116. This protocol accepts the following options.
  117. @table @option
  118. @item timeout
  119. Set timeout in microseconds of socket I/O operations used by the underlying low level
  120. operation. By default it is set to -1, which means that the timeout is
  121. not specified.
  122. @item ftp-anonymous-password
  123. Password used when login as anonymous user. Typically an e-mail address
  124. should be used.
  125. @item ftp-write-seekable
  126. Control seekability of connection during encoding. If set to 1 the
  127. resource is supposed to be seekable, if set to 0 it is assumed not
  128. to be seekable. Default value is 0.
  129. @end table
  130. NOTE: Protocol can be used as output, but it is recommended to not do
  131. it, unless special care is taken (tests, customized server configuration
  132. etc.). Different FTP servers behave in different way during seek
  133. operation. ff* tools may produce incomplete content due to server limitations.
  134. @section gopher
  135. Gopher protocol.
  136. @section hls
  137. Read Apple HTTP Live Streaming compliant segmented stream as
  138. a uniform one. The M3U8 playlists describing the segments can be
  139. remote HTTP resources or local files, accessed using the standard
  140. file protocol.
  141. The nested protocol is declared by specifying
  142. "+@var{proto}" after the hls URI scheme name, where @var{proto}
  143. is either "file" or "http".
  144. @example
  145. hls+http://host/path/to/remote/resource.m3u8
  146. hls+file://path/to/local/resource.m3u8
  147. @end example
  148. Using this protocol is discouraged - the hls demuxer should work
  149. just as well (if not, please report the issues) and is more complete.
  150. To use the hls demuxer instead, simply use the direct URLs to the
  151. m3u8 files.
  152. @section http
  153. HTTP (Hyper Text Transfer Protocol).
  154. This protocol accepts the following options:
  155. @table @option
  156. @item seekable
  157. Control seekability of connection. If set to 1 the resource is
  158. supposed to be seekable, if set to 0 it is assumed not to be seekable,
  159. if set to -1 it will try to autodetect if it is seekable. Default
  160. value is -1.
  161. @item chunked_post
  162. If set to 1 use chunked Transfer-Encoding for posts, default is 1.
  163. @item content_type
  164. Set a specific content type for the POST messages.
  165. @item headers
  166. Set custom HTTP headers, can override built in default headers. The
  167. value must be a string encoding the headers.
  168. @item multiple_requests
  169. Use persistent connections if set to 1, default is 0.
  170. @item post_data
  171. Set custom HTTP post data.
  172. @item user-agent
  173. @item user_agent
  174. Override the User-Agent header. If not specified the protocol will use a
  175. string describing the libavformat build. ("Lavf/<version>")
  176. @item timeout
  177. Set timeout in microseconds of socket I/O operations used by the underlying low level
  178. operation. By default it is set to -1, which means that the timeout is
  179. not specified.
  180. @item mime_type
  181. Export the MIME type.
  182. @item icy
  183. If set to 1 request ICY (SHOUTcast) metadata from the server. If the server
  184. supports this, the metadata has to be retrieved by the application by reading
  185. the @option{icy_metadata_headers} and @option{icy_metadata_packet} options.
  186. The default is 0.
  187. @item icy_metadata_headers
  188. If the server supports ICY metadata, this contains the ICY-specific HTTP reply
  189. headers, separated by newline characters.
  190. @item icy_metadata_packet
  191. If the server supports ICY metadata, and @option{icy} was set to 1, this
  192. contains the last non-empty metadata packet sent by the server. It should be
  193. polled in regular intervals by applications interested in mid-stream metadata
  194. updates.
  195. @item cookies
  196. Set the cookies to be sent in future requests. The format of each cookie is the
  197. same as the value of a Set-Cookie HTTP response field. Multiple cookies can be
  198. delimited by a newline character.
  199. @item offset
  200. Set initial byte offset.
  201. @item end_offset
  202. Try to limit the request to bytes preceding this offset.
  203. @end table
  204. @subsection HTTP Cookies
  205. Some HTTP requests will be denied unless cookie values are passed in with the
  206. request. The @option{cookies} option allows these cookies to be specified. At
  207. the very least, each cookie must specify a value along with a path and domain.
  208. HTTP requests that match both the domain and path will automatically include the
  209. cookie value in the HTTP Cookie header field. Multiple cookies can be delimited
  210. by a newline.
  211. The required syntax to play a stream specifying a cookie is:
  212. @example
  213. ffplay -cookies "nlqptid=nltid=tsn; path=/; domain=somedomain.com;" http://somedomain.com/somestream.m3u8
  214. @end example
  215. @section mmst
  216. MMS (Microsoft Media Server) protocol over TCP.
  217. @section mmsh
  218. MMS (Microsoft Media Server) protocol over HTTP.
  219. The required syntax is:
  220. @example
  221. mmsh://@var{server}[:@var{port}][/@var{app}][/@var{playpath}]
  222. @end example
  223. @section md5
  224. MD5 output protocol.
  225. Computes the MD5 hash of the data to be written, and on close writes
  226. this to the designated output or stdout if none is specified. It can
  227. be used to test muxers without writing an actual file.
  228. Some examples follow.
  229. @example
  230. # Write the MD5 hash of the encoded AVI file to the file output.avi.md5.
  231. ffmpeg -i input.flv -f avi -y md5:output.avi.md5
  232. # Write the MD5 hash of the encoded AVI file to stdout.
  233. ffmpeg -i input.flv -f avi -y md5:
  234. @end example
  235. Note that some formats (typically MOV) require the output protocol to
  236. be seekable, so they will fail with the MD5 output protocol.
  237. @section pipe
  238. UNIX pipe access protocol.
  239. Allow to read and write from UNIX pipes.
  240. The accepted syntax is:
  241. @example
  242. pipe:[@var{number}]
  243. @end example
  244. @var{number} is the number corresponding to the file descriptor of the
  245. pipe (e.g. 0 for stdin, 1 for stdout, 2 for stderr). If @var{number}
  246. is not specified, by default the stdout file descriptor will be used
  247. for writing, stdin for reading.
  248. For example to read from stdin with @command{ffmpeg}:
  249. @example
  250. cat test.wav | ffmpeg -i pipe:0
  251. # ...this is the same as...
  252. cat test.wav | ffmpeg -i pipe:
  253. @end example
  254. For writing to stdout with @command{ffmpeg}:
  255. @example
  256. ffmpeg -i test.wav -f avi pipe:1 | cat > test.avi
  257. # ...this is the same as...
  258. ffmpeg -i test.wav -f avi pipe: | cat > test.avi
  259. @end example
  260. This protocol accepts the following options:
  261. @table @option
  262. @item blocksize
  263. Set I/O operation maximum block size, in bytes. Default value is
  264. @code{INT_MAX}, which results in not limiting the requested block size.
  265. Setting this value reasonably low improves user termination request reaction
  266. time, which is valuable if data transmission is slow.
  267. @end table
  268. Note that some formats (typically MOV), require the output protocol to
  269. be seekable, so they will fail with the pipe output protocol.
  270. @section rtmp
  271. Real-Time Messaging Protocol.
  272. The Real-Time Messaging Protocol (RTMP) is used for streaming multimedia
  273. content across a TCP/IP network.
  274. The required syntax is:
  275. @example
  276. rtmp://[@var{username}:@var{password}@@]@var{server}[:@var{port}][/@var{app}][/@var{instance}][/@var{playpath}]
  277. @end example
  278. The accepted parameters are:
  279. @table @option
  280. @item username
  281. An optional username (mostly for publishing).
  282. @item password
  283. An optional password (mostly for publishing).
  284. @item server
  285. The address of the RTMP server.
  286. @item port
  287. The number of the TCP port to use (by default is 1935).
  288. @item app
  289. It is the name of the application to access. It usually corresponds to
  290. the path where the application is installed on the RTMP server
  291. (e.g. @file{/ondemand/}, @file{/flash/live/}, etc.). You can override
  292. the value parsed from the URI through the @code{rtmp_app} option, too.
  293. @item playpath
  294. It is the path or name of the resource to play with reference to the
  295. application specified in @var{app}, may be prefixed by "mp4:". You
  296. can override the value parsed from the URI through the @code{rtmp_playpath}
  297. option, too.
  298. @item listen
  299. Act as a server, listening for an incoming connection.
  300. @item timeout
  301. Maximum time to wait for the incoming connection. Implies listen.
  302. @end table
  303. Additionally, the following parameters can be set via command line options
  304. (or in code via @code{AVOption}s):
  305. @table @option
  306. @item rtmp_app
  307. Name of application to connect on the RTMP server. This option
  308. overrides the parameter specified in the URI.
  309. @item rtmp_buffer
  310. Set the client buffer time in milliseconds. The default is 3000.
  311. @item rtmp_conn
  312. Extra arbitrary AMF connection parameters, parsed from a string,
  313. e.g. like @code{B:1 S:authMe O:1 NN:code:1.23 NS:flag:ok O:0}.
  314. Each value is prefixed by a single character denoting the type,
  315. B for Boolean, N for number, S for string, O for object, or Z for null,
  316. followed by a colon. For Booleans the data must be either 0 or 1 for
  317. FALSE or TRUE, respectively. Likewise for Objects the data must be 0 or
  318. 1 to end or begin an object, respectively. Data items in subobjects may
  319. be named, by prefixing the type with 'N' and specifying the name before
  320. the value (i.e. @code{NB:myFlag:1}). This option may be used multiple
  321. times to construct arbitrary AMF sequences.
  322. @item rtmp_flashver
  323. Version of the Flash plugin used to run the SWF player. The default
  324. is LNX 9,0,124,2. (When publishing, the default is FMLE/3.0 (compatible;
  325. <libavformat version>).)
  326. @item rtmp_flush_interval
  327. Number of packets flushed in the same request (RTMPT only). The default
  328. is 10.
  329. @item rtmp_live
  330. Specify that the media is a live stream. No resuming or seeking in
  331. live streams is possible. The default value is @code{any}, which means the
  332. subscriber first tries to play the live stream specified in the
  333. playpath. If a live stream of that name is not found, it plays the
  334. recorded stream. The other possible values are @code{live} and
  335. @code{recorded}.
  336. @item rtmp_pageurl
  337. URL of the web page in which the media was embedded. By default no
  338. value will be sent.
  339. @item rtmp_playpath
  340. Stream identifier to play or to publish. This option overrides the
  341. parameter specified in the URI.
  342. @item rtmp_subscribe
  343. Name of live stream to subscribe to. By default no value will be sent.
  344. It is only sent if the option is specified or if rtmp_live
  345. is set to live.
  346. @item rtmp_swfhash
  347. SHA256 hash of the decompressed SWF file (32 bytes).
  348. @item rtmp_swfsize
  349. Size of the decompressed SWF file, required for SWFVerification.
  350. @item rtmp_swfurl
  351. URL of the SWF player for the media. By default no value will be sent.
  352. @item rtmp_swfverify
  353. URL to player swf file, compute hash/size automatically.
  354. @item rtmp_tcurl
  355. URL of the target stream. Defaults to proto://host[:port]/app.
  356. @end table
  357. For example to read with @command{ffplay} a multimedia resource named
  358. "sample" from the application "vod" from an RTMP server "myserver":
  359. @example
  360. ffplay rtmp://myserver/vod/sample
  361. @end example
  362. To publish to a password protected server, passing the playpath and
  363. app names separately:
  364. @example
  365. ffmpeg -re -i <input> -f flv -rtmp_playpath some/long/path -rtmp_app long/app/name rtmp://username:password@@myserver/
  366. @end example
  367. @section rtmpe
  368. Encrypted Real-Time Messaging Protocol.
  369. The Encrypted Real-Time Messaging Protocol (RTMPE) is used for
  370. streaming multimedia content within standard cryptographic primitives,
  371. consisting of Diffie-Hellman key exchange and HMACSHA256, generating
  372. a pair of RC4 keys.
  373. @section rtmps
  374. Real-Time Messaging Protocol over a secure SSL connection.
  375. The Real-Time Messaging Protocol (RTMPS) is used for streaming
  376. multimedia content across an encrypted connection.
  377. @section rtmpt
  378. Real-Time Messaging Protocol tunneled through HTTP.
  379. The Real-Time Messaging Protocol tunneled through HTTP (RTMPT) is used
  380. for streaming multimedia content within HTTP requests to traverse
  381. firewalls.
  382. @section rtmpte
  383. Encrypted Real-Time Messaging Protocol tunneled through HTTP.
  384. The Encrypted Real-Time Messaging Protocol tunneled through HTTP (RTMPTE)
  385. is used for streaming multimedia content within HTTP requests to traverse
  386. firewalls.
  387. @section rtmpts
  388. Real-Time Messaging Protocol tunneled through HTTPS.
  389. The Real-Time Messaging Protocol tunneled through HTTPS (RTMPTS) is used
  390. for streaming multimedia content within HTTPS requests to traverse
  391. firewalls.
  392. @section libssh
  393. Secure File Transfer Protocol via libssh
  394. Allow to read from or write to remote resources using SFTP protocol.
  395. Following syntax is required.
  396. @example
  397. sftp://[user[:password]@@]server[:port]/path/to/remote/resource.mpeg
  398. @end example
  399. This protocol accepts the following options.
  400. @table @option
  401. @item timeout
  402. Set timeout of socket I/O operations used by the underlying low level
  403. operation. By default it is set to -1, which means that the timeout
  404. is not specified.
  405. @item truncate
  406. Truncate existing files on write, if set to 1. A value of 0 prevents
  407. truncating. Default value is 1.
  408. @item private_key
  409. Specify the path of the file containing private key to use during authorization.
  410. By default libssh searches for keys in the @file{~/.ssh/} directory.
  411. @end table
  412. Example: Play a file stored on remote server.
  413. @example
  414. ffplay sftp://user:password@@server_address:22/home/user/resource.mpeg
  415. @end example
  416. @section librtmp rtmp, rtmpe, rtmps, rtmpt, rtmpte
  417. Real-Time Messaging Protocol and its variants supported through
  418. librtmp.
  419. Requires the presence of the librtmp headers and library during
  420. configuration. You need to explicitly configure the build with
  421. "--enable-librtmp". If enabled this will replace the native RTMP
  422. protocol.
  423. This protocol provides most client functions and a few server
  424. functions needed to support RTMP, RTMP tunneled in HTTP (RTMPT),
  425. encrypted RTMP (RTMPE), RTMP over SSL/TLS (RTMPS) and tunneled
  426. variants of these encrypted types (RTMPTE, RTMPTS).
  427. The required syntax is:
  428. @example
  429. @var{rtmp_proto}://@var{server}[:@var{port}][/@var{app}][/@var{playpath}] @var{options}
  430. @end example
  431. where @var{rtmp_proto} is one of the strings "rtmp", "rtmpt", "rtmpe",
  432. "rtmps", "rtmpte", "rtmpts" corresponding to each RTMP variant, and
  433. @var{server}, @var{port}, @var{app} and @var{playpath} have the same
  434. meaning as specified for the RTMP native protocol.
  435. @var{options} contains a list of space-separated options of the form
  436. @var{key}=@var{val}.
  437. See the librtmp manual page (man 3 librtmp) for more information.
  438. For example, to stream a file in real-time to an RTMP server using
  439. @command{ffmpeg}:
  440. @example
  441. ffmpeg -re -i myfile -f flv rtmp://myserver/live/mystream
  442. @end example
  443. To play the same stream using @command{ffplay}:
  444. @example
  445. ffplay "rtmp://myserver/live/mystream live=1"
  446. @end example
  447. @section rtp
  448. Real-time Transport Protocol.
  449. The required syntax for an RTP URL is:
  450. rtp://@var{hostname}[:@var{port}][?@var{option}=@var{val}...]
  451. @var{port} specifies the RTP port to use.
  452. The following URL options are supported:
  453. @table @option
  454. @item ttl=@var{n}
  455. Set the TTL (Time-To-Live) value (for multicast only).
  456. @item rtcpport=@var{n}
  457. Set the remote RTCP port to @var{n}.
  458. @item localrtpport=@var{n}
  459. Set the local RTP port to @var{n}.
  460. @item localrtcpport=@var{n}'
  461. Set the local RTCP port to @var{n}.
  462. @item pkt_size=@var{n}
  463. Set max packet size (in bytes) to @var{n}.
  464. @item connect=0|1
  465. Do a @code{connect()} on the UDP socket (if set to 1) or not (if set
  466. to 0).
  467. @item sources=@var{ip}[,@var{ip}]
  468. List allowed source IP addresses.
  469. @item block=@var{ip}[,@var{ip}]
  470. List disallowed (blocked) source IP addresses.
  471. @item write_to_source=0|1
  472. Send packets to the source address of the latest received packet (if
  473. set to 1) or to a default remote address (if set to 0).
  474. @item localport=@var{n}
  475. Set the local RTP port to @var{n}.
  476. This is a deprecated option. Instead, @option{localrtpport} should be
  477. used.
  478. @end table
  479. Important notes:
  480. @enumerate
  481. @item
  482. If @option{rtcpport} is not set the RTCP port will be set to the RTP
  483. port value plus 1.
  484. @item
  485. If @option{localrtpport} (the local RTP port) is not set any available
  486. port will be used for the local RTP and RTCP ports.
  487. @item
  488. If @option{localrtcpport} (the local RTCP port) is not set it will be
  489. set to the the local RTP port value plus 1.
  490. @end enumerate
  491. @section rtsp
  492. Real-Time Streaming Protocol.
  493. RTSP is not technically a protocol handler in libavformat, it is a demuxer
  494. and muxer. The demuxer supports both normal RTSP (with data transferred
  495. over RTP; this is used by e.g. Apple and Microsoft) and Real-RTSP (with
  496. data transferred over RDT).
  497. The muxer can be used to send a stream using RTSP ANNOUNCE to a server
  498. supporting it (currently Darwin Streaming Server and Mischa Spiegelmock's
  499. @uref{https://github.com/revmischa/rtsp-server, RTSP server}).
  500. The required syntax for a RTSP url is:
  501. @example
  502. rtsp://@var{hostname}[:@var{port}]/@var{path}
  503. @end example
  504. Options can be set on the @command{ffmpeg}/@command{ffplay} command
  505. line, or set in code via @code{AVOption}s or in
  506. @code{avformat_open_input}.
  507. The following options are supported.
  508. @table @option
  509. @item initial_pause
  510. Do not start playing the stream immediately if set to 1. Default value
  511. is 0.
  512. @item rtsp_transport
  513. Set RTSP transport protocols.
  514. It accepts the following values:
  515. @table @samp
  516. @item udp
  517. Use UDP as lower transport protocol.
  518. @item tcp
  519. Use TCP (interleaving within the RTSP control channel) as lower
  520. transport protocol.
  521. @item udp_multicast
  522. Use UDP multicast as lower transport protocol.
  523. @item http
  524. Use HTTP tunneling as lower transport protocol, which is useful for
  525. passing proxies.
  526. @end table
  527. Multiple lower transport protocols may be specified, in that case they are
  528. tried one at a time (if the setup of one fails, the next one is tried).
  529. For the muxer, only the @samp{tcp} and @samp{udp} options are supported.
  530. @item rtsp_flags
  531. Set RTSP flags.
  532. The following values are accepted:
  533. @table @samp
  534. @item filter_src
  535. Accept packets only from negotiated peer address and port.
  536. @item listen
  537. Act as a server, listening for an incoming connection.
  538. @item prefer_tcp
  539. Try TCP for RTP transport first, if TCP is available as RTSP RTP transport.
  540. @end table
  541. Default value is @samp{none}.
  542. @item allowed_media_types
  543. Set media types to accept from the server.
  544. The following flags are accepted:
  545. @table @samp
  546. @item video
  547. @item audio
  548. @item data
  549. @end table
  550. By default it accepts all media types.
  551. @item min_port
  552. Set minimum local UDP port. Default value is 5000.
  553. @item max_port
  554. Set maximum local UDP port. Default value is 65000.
  555. @item timeout
  556. Set maximum timeout (in seconds) to wait for incoming connections.
  557. A value of -1 means infinite (default). This option implies the
  558. @option{rtsp_flags} set to @samp{listen}.
  559. @item reorder_queue_size
  560. Set number of packets to buffer for handling of reordered packets.
  561. @item stimeout
  562. Set socket TCP I/O timeout in microseconds.
  563. @item user-agent
  564. Override User-Agent header. If not specified, it defaults to the
  565. libavformat identifier string.
  566. @end table
  567. When receiving data over UDP, the demuxer tries to reorder received packets
  568. (since they may arrive out of order, or packets may get lost totally). This
  569. can be disabled by setting the maximum demuxing delay to zero (via
  570. the @code{max_delay} field of AVFormatContext).
  571. When watching multi-bitrate Real-RTSP streams with @command{ffplay}, the
  572. streams to display can be chosen with @code{-vst} @var{n} and
  573. @code{-ast} @var{n} for video and audio respectively, and can be switched
  574. on the fly by pressing @code{v} and @code{a}.
  575. @subsection Examples
  576. The following examples all make use of the @command{ffplay} and
  577. @command{ffmpeg} tools.
  578. @itemize
  579. @item
  580. Watch a stream over UDP, with a max reordering delay of 0.5 seconds:
  581. @example
  582. ffplay -max_delay 500000 -rtsp_transport udp rtsp://server/video.mp4
  583. @end example
  584. @item
  585. Watch a stream tunneled over HTTP:
  586. @example
  587. ffplay -rtsp_transport http rtsp://server/video.mp4
  588. @end example
  589. @item
  590. Send a stream in realtime to a RTSP server, for others to watch:
  591. @example
  592. ffmpeg -re -i @var{input} -f rtsp -muxdelay 0.1 rtsp://server/live.sdp
  593. @end example
  594. @item
  595. Receive a stream in realtime:
  596. @example
  597. ffmpeg -rtsp_flags listen -i rtsp://ownaddress/live.sdp @var{output}
  598. @end example
  599. @end itemize
  600. @section sap
  601. Session Announcement Protocol (RFC 2974). This is not technically a
  602. protocol handler in libavformat, it is a muxer and demuxer.
  603. It is used for signalling of RTP streams, by announcing the SDP for the
  604. streams regularly on a separate port.
  605. @subsection Muxer
  606. The syntax for a SAP url given to the muxer is:
  607. @example
  608. sap://@var{destination}[:@var{port}][?@var{options}]
  609. @end example
  610. The RTP packets are sent to @var{destination} on port @var{port},
  611. or to port 5004 if no port is specified.
  612. @var{options} is a @code{&}-separated list. The following options
  613. are supported:
  614. @table @option
  615. @item announce_addr=@var{address}
  616. Specify the destination IP address for sending the announcements to.
  617. If omitted, the announcements are sent to the commonly used SAP
  618. announcement multicast address 224.2.127.254 (sap.mcast.net), or
  619. ff0e::2:7ffe if @var{destination} is an IPv6 address.
  620. @item announce_port=@var{port}
  621. Specify the port to send the announcements on, defaults to
  622. 9875 if not specified.
  623. @item ttl=@var{ttl}
  624. Specify the time to live value for the announcements and RTP packets,
  625. defaults to 255.
  626. @item same_port=@var{0|1}
  627. If set to 1, send all RTP streams on the same port pair. If zero (the
  628. default), all streams are sent on unique ports, with each stream on a
  629. port 2 numbers higher than the previous.
  630. VLC/Live555 requires this to be set to 1, to be able to receive the stream.
  631. The RTP stack in libavformat for receiving requires all streams to be sent
  632. on unique ports.
  633. @end table
  634. Example command lines follow.
  635. To broadcast a stream on the local subnet, for watching in VLC:
  636. @example
  637. ffmpeg -re -i @var{input} -f sap sap://224.0.0.255?same_port=1
  638. @end example
  639. Similarly, for watching in @command{ffplay}:
  640. @example
  641. ffmpeg -re -i @var{input} -f sap sap://224.0.0.255
  642. @end example
  643. And for watching in @command{ffplay}, over IPv6:
  644. @example
  645. ffmpeg -re -i @var{input} -f sap sap://[ff0e::1:2:3:4]
  646. @end example
  647. @subsection Demuxer
  648. The syntax for a SAP url given to the demuxer is:
  649. @example
  650. sap://[@var{address}][:@var{port}]
  651. @end example
  652. @var{address} is the multicast address to listen for announcements on,
  653. if omitted, the default 224.2.127.254 (sap.mcast.net) is used. @var{port}
  654. is the port that is listened on, 9875 if omitted.
  655. The demuxers listens for announcements on the given address and port.
  656. Once an announcement is received, it tries to receive that particular stream.
  657. Example command lines follow.
  658. To play back the first stream announced on the normal SAP multicast address:
  659. @example
  660. ffplay sap://
  661. @end example
  662. To play back the first stream announced on one the default IPv6 SAP multicast address:
  663. @example
  664. ffplay sap://[ff0e::2:7ffe]
  665. @end example
  666. @section sctp
  667. Stream Control Transmission Protocol.
  668. The accepted URL syntax is:
  669. @example
  670. sctp://@var{host}:@var{port}[?@var{options}]
  671. @end example
  672. The protocol accepts the following options:
  673. @table @option
  674. @item listen
  675. If set to any value, listen for an incoming connection. Outgoing connection is done by default.
  676. @item max_streams
  677. Set the maximum number of streams. By default no limit is set.
  678. @end table
  679. @section srtp
  680. Secure Real-time Transport Protocol.
  681. The accepted options are:
  682. @table @option
  683. @item srtp_in_suite
  684. @item srtp_out_suite
  685. Select input and output encoding suites.
  686. Supported values:
  687. @table @samp
  688. @item AES_CM_128_HMAC_SHA1_80
  689. @item SRTP_AES128_CM_HMAC_SHA1_80
  690. @item AES_CM_128_HMAC_SHA1_32
  691. @item SRTP_AES128_CM_HMAC_SHA1_32
  692. @end table
  693. @item srtp_in_params
  694. @item srtp_out_params
  695. Set input and output encoding parameters, which are expressed by a
  696. base64-encoded representation of a binary block. The first 16 bytes of
  697. this binary block are used as master key, the following 14 bytes are
  698. used as master salt.
  699. @end table
  700. @section subfile
  701. Virtually extract a segment of a file or another stream.
  702. The underlying stream must be seekable.
  703. Accepted options:
  704. @table @option
  705. @item start
  706. Start offset of the extracted segment, in bytes.
  707. @item end
  708. End offset of the extracted segment, in bytes.
  709. @end table
  710. Examples:
  711. Extract a chapter from a DVD VOB file (start and end sectors obtained
  712. externally and multiplied by 2048):
  713. @example
  714. subfile,,start,153391104,end,268142592,,:/media/dvd/VIDEO_TS/VTS_08_1.VOB
  715. @end example
  716. Play an AVI file directly from a TAR archive:
  717. subfile,,start,183241728,end,366490624,,:archive.tar
  718. @section tcp
  719. Transmission Control Protocol.
  720. The required syntax for a TCP url is:
  721. @example
  722. tcp://@var{hostname}:@var{port}[?@var{options}]
  723. @end example
  724. @var{options} contains a list of &-separated options of the form
  725. @var{key}=@var{val}.
  726. The list of supported options follows.
  727. @table @option
  728. @item listen=@var{1|0}
  729. Listen for an incoming connection. Default value is 0.
  730. @item timeout=@var{microseconds}
  731. Set raise error timeout, expressed in microseconds.
  732. This option is only relevant in read mode: if no data arrived in more
  733. than this time interval, raise error.
  734. @item listen_timeout=@var{microseconds}
  735. Set listen timeout, expressed in microseconds.
  736. @end table
  737. The following example shows how to setup a listening TCP connection
  738. with @command{ffmpeg}, which is then accessed with @command{ffplay}:
  739. @example
  740. ffmpeg -i @var{input} -f @var{format} tcp://@var{hostname}:@var{port}?listen
  741. ffplay tcp://@var{hostname}:@var{port}
  742. @end example
  743. @section tls
  744. Transport Layer Security (TLS) / Secure Sockets Layer (SSL)
  745. The required syntax for a TLS/SSL url is:
  746. @example
  747. tls://@var{hostname}:@var{port}[?@var{options}]
  748. @end example
  749. The following parameters can be set via command line options
  750. (or in code via @code{AVOption}s):
  751. @table @option
  752. @item ca_file, cafile=@var{filename}
  753. A file containing certificate authority (CA) root certificates to treat
  754. as trusted. If the linked TLS library contains a default this might not
  755. need to be specified for verification to work, but not all libraries and
  756. setups have defaults built in.
  757. The file must be in OpenSSL PEM format.
  758. @item tls_verify=@var{1|0}
  759. If enabled, try to verify the peer that we are communicating with.
  760. Note, if using OpenSSL, this currently only makes sure that the
  761. peer certificate is signed by one of the root certificates in the CA
  762. database, but it does not validate that the certificate actually
  763. matches the host name we are trying to connect to. (With GnuTLS,
  764. the host name is validated as well.)
  765. This is disabled by default since it requires a CA database to be
  766. provided by the caller in many cases.
  767. @item cert_file, cert=@var{filename}
  768. A file containing a certificate to use in the handshake with the peer.
  769. (When operating as server, in listen mode, this is more often required
  770. by the peer, while client certificates only are mandated in certain
  771. setups.)
  772. @item key_file, key=@var{filename}
  773. A file containing the private key for the certificate.
  774. @item listen=@var{1|0}
  775. If enabled, listen for connections on the provided port, and assume
  776. the server role in the handshake instead of the client role.
  777. @end table
  778. Example command lines:
  779. To create a TLS/SSL server that serves an input stream.
  780. @example
  781. ffmpeg -i @var{input} -f @var{format} tls://@var{hostname}:@var{port}?listen&cert=@var{server.crt}&key=@var{server.key}
  782. @end example
  783. To play back a stream from the TLS/SSL server using @command{ffplay}:
  784. @example
  785. ffplay tls://@var{hostname}:@var{port}
  786. @end example
  787. @section udp
  788. User Datagram Protocol.
  789. The required syntax for an UDP URL is:
  790. @example
  791. udp://@var{hostname}:@var{port}[?@var{options}]
  792. @end example
  793. @var{options} contains a list of &-separated options of the form @var{key}=@var{val}.
  794. In case threading is enabled on the system, a circular buffer is used
  795. to store the incoming data, which allows one to reduce loss of data due to
  796. UDP socket buffer overruns. The @var{fifo_size} and
  797. @var{overrun_nonfatal} options are related to this buffer.
  798. The list of supported options follows.
  799. @table @option
  800. @item buffer_size=@var{size}
  801. Set the UDP maximum socket buffer size in bytes. This is used to set either
  802. the receive or send buffer size, depending on what the socket is used for.
  803. Default is 64KB. See also @var{fifo_size}.
  804. @item localport=@var{port}
  805. Override the local UDP port to bind with.
  806. @item localaddr=@var{addr}
  807. Choose the local IP address. This is useful e.g. if sending multicast
  808. and the host has multiple interfaces, where the user can choose
  809. which interface to send on by specifying the IP address of that interface.
  810. @item pkt_size=@var{size}
  811. Set the size in bytes of UDP packets.
  812. @item reuse=@var{1|0}
  813. Explicitly allow or disallow reusing UDP sockets.
  814. @item ttl=@var{ttl}
  815. Set the time to live value (for multicast only).
  816. @item connect=@var{1|0}
  817. Initialize the UDP socket with @code{connect()}. In this case, the
  818. destination address can't be changed with ff_udp_set_remote_url later.
  819. If the destination address isn't known at the start, this option can
  820. be specified in ff_udp_set_remote_url, too.
  821. This allows finding out the source address for the packets with getsockname,
  822. and makes writes return with AVERROR(ECONNREFUSED) if "destination
  823. unreachable" is received.
  824. For receiving, this gives the benefit of only receiving packets from
  825. the specified peer address/port.
  826. @item sources=@var{address}[,@var{address}]
  827. Only receive packets sent to the multicast group from one of the
  828. specified sender IP addresses.
  829. @item block=@var{address}[,@var{address}]
  830. Ignore packets sent to the multicast group from the specified
  831. sender IP addresses.
  832. @item fifo_size=@var{units}
  833. Set the UDP receiving circular buffer size, expressed as a number of
  834. packets with size of 188 bytes. If not specified defaults to 7*4096.
  835. @item overrun_nonfatal=@var{1|0}
  836. Survive in case of UDP receiving circular buffer overrun. Default
  837. value is 0.
  838. @item timeout=@var{microseconds}
  839. Set raise error timeout, expressed in microseconds.
  840. This option is only relevant in read mode: if no data arrived in more
  841. than this time interval, raise error.
  842. @item broadcast=@var{1|0}
  843. Explicitly allow or disallow UDP broadcasting.
  844. Note that broadcasting may not work properly on networks having
  845. a broadcast storm protection.
  846. @end table
  847. @subsection Examples
  848. @itemize
  849. @item
  850. Use @command{ffmpeg} to stream over UDP to a remote endpoint:
  851. @example
  852. ffmpeg -i @var{input} -f @var{format} udp://@var{hostname}:@var{port}
  853. @end example
  854. @item
  855. Use @command{ffmpeg} to stream in mpegts format over UDP using 188
  856. sized UDP packets, using a large input buffer:
  857. @example
  858. ffmpeg -i @var{input} -f mpegts udp://@var{hostname}:@var{port}?pkt_size=188&buffer_size=65535
  859. @end example
  860. @item
  861. Use @command{ffmpeg} to receive over UDP from a remote endpoint:
  862. @example
  863. ffmpeg -i udp://[@var{multicast-address}]:@var{port} ...
  864. @end example
  865. @end itemize
  866. @section unix
  867. Unix local socket
  868. The required syntax for a Unix socket URL is:
  869. @example
  870. unix://@var{filepath}
  871. @end example
  872. The following parameters can be set via command line options
  873. (or in code via @code{AVOption}s):
  874. @table @option
  875. @item timeout
  876. Timeout in ms.
  877. @item listen
  878. Create the Unix socket in listening mode.
  879. @end table
  880. @c man end PROTOCOLS