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.

1308 lines
36KB

  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. Read and seek from many resources 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. 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. 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 1.
  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. @item listen
  204. If set to 1 enables experimental HTTP server. This can be used to send data when
  205. used as an output option, or read data from a client with HTTP POST when used as
  206. an input option.
  207. @example
  208. # Server side (sending):
  209. ffmpeg -i somefile.ogg -c copy -listen 1 -f ogg http://@var{server}:@var{port}
  210. # Client side (receiving):
  211. ffmpeg -i http://@var{server}:@var{port} -c copy somefile.ogg
  212. # Client can also be done with wget:
  213. wget http://@var{server}:@var{port} -O somefile.ogg
  214. # Server side (receiving):
  215. ffmpeg -listen 1 -i http://@var{server}:@var{port} -c copy somefile.ogg
  216. # Client side (sending):
  217. ffmpeg -i somefile.ogg -chunked_post 0 -c copy -f ogg http://@var{server}:@var{port}
  218. # Client can also be done with wget:
  219. wget --post-file=somefile.ogg http://@var{server}:@var{port}
  220. @end example
  221. @end table
  222. @subsection HTTP Cookies
  223. Some HTTP requests will be denied unless cookie values are passed in with the
  224. request. The @option{cookies} option allows these cookies to be specified. At
  225. the very least, each cookie must specify a value along with a path and domain.
  226. HTTP requests that match both the domain and path will automatically include the
  227. cookie value in the HTTP Cookie header field. Multiple cookies can be delimited
  228. by a newline.
  229. The required syntax to play a stream specifying a cookie is:
  230. @example
  231. ffplay -cookies "nlqptid=nltid=tsn; path=/; domain=somedomain.com;" http://somedomain.com/somestream.m3u8
  232. @end example
  233. @section Icecast
  234. Icecast protocol (stream to Icecast servers)
  235. This protocol accepts the following options:
  236. @table @option
  237. @item ice_genre
  238. Set the stream genre.
  239. @item ice_name
  240. Set the stream name.
  241. @item ice_description
  242. Set the stream description.
  243. @item ice_url
  244. Set the stream website URL.
  245. @item ice_public
  246. Set if the stream should be public.
  247. The default is 0 (not public).
  248. @item user_agent
  249. Override the User-Agent header. If not specified a string of the form
  250. "Lavf/<version>" will be used.
  251. @item password
  252. Set the Icecast mountpoint password.
  253. @item content_type
  254. Set the stream content type. This must be set if it is different from
  255. audio/mpeg.
  256. @item legacy_icecast
  257. This enables support for Icecast versions < 2.4.0, that do not support the
  258. HTTP PUT method but the SOURCE method.
  259. @end table
  260. @example
  261. icecast://[@var{username}[:@var{password}]@@]@var{server}:@var{port}/@var{mountpoint}
  262. @end example
  263. @section mmst
  264. MMS (Microsoft Media Server) protocol over TCP.
  265. @section mmsh
  266. MMS (Microsoft Media Server) protocol over HTTP.
  267. The required syntax is:
  268. @example
  269. mmsh://@var{server}[:@var{port}][/@var{app}][/@var{playpath}]
  270. @end example
  271. @section md5
  272. MD5 output protocol.
  273. Computes the MD5 hash of the data to be written, and on close writes
  274. this to the designated output or stdout if none is specified. It can
  275. be used to test muxers without writing an actual file.
  276. Some examples follow.
  277. @example
  278. # Write the MD5 hash of the encoded AVI file to the file output.avi.md5.
  279. ffmpeg -i input.flv -f avi -y md5:output.avi.md5
  280. # Write the MD5 hash of the encoded AVI file to stdout.
  281. ffmpeg -i input.flv -f avi -y md5:
  282. @end example
  283. Note that some formats (typically MOV) require the output protocol to
  284. be seekable, so they will fail with the MD5 output protocol.
  285. @section pipe
  286. UNIX pipe access protocol.
  287. Read and write from UNIX pipes.
  288. The accepted syntax is:
  289. @example
  290. pipe:[@var{number}]
  291. @end example
  292. @var{number} is the number corresponding to the file descriptor of the
  293. pipe (e.g. 0 for stdin, 1 for stdout, 2 for stderr). If @var{number}
  294. is not specified, by default the stdout file descriptor will be used
  295. for writing, stdin for reading.
  296. For example to read from stdin with @command{ffmpeg}:
  297. @example
  298. cat test.wav | ffmpeg -i pipe:0
  299. # ...this is the same as...
  300. cat test.wav | ffmpeg -i pipe:
  301. @end example
  302. For writing to stdout with @command{ffmpeg}:
  303. @example
  304. ffmpeg -i test.wav -f avi pipe:1 | cat > test.avi
  305. # ...this is the same as...
  306. ffmpeg -i test.wav -f avi pipe: | cat > test.avi
  307. @end example
  308. This protocol accepts the following options:
  309. @table @option
  310. @item blocksize
  311. Set I/O operation maximum block size, in bytes. Default value is
  312. @code{INT_MAX}, which results in not limiting the requested block size.
  313. Setting this value reasonably low improves user termination request reaction
  314. time, which is valuable if data transmission is slow.
  315. @end table
  316. Note that some formats (typically MOV), require the output protocol to
  317. be seekable, so they will fail with the pipe output protocol.
  318. @section rtmp
  319. Real-Time Messaging Protocol.
  320. The Real-Time Messaging Protocol (RTMP) is used for streaming multimedia
  321. content across a TCP/IP network.
  322. The required syntax is:
  323. @example
  324. rtmp://[@var{username}:@var{password}@@]@var{server}[:@var{port}][/@var{app}][/@var{instance}][/@var{playpath}]
  325. @end example
  326. The accepted parameters are:
  327. @table @option
  328. @item username
  329. An optional username (mostly for publishing).
  330. @item password
  331. An optional password (mostly for publishing).
  332. @item server
  333. The address of the RTMP server.
  334. @item port
  335. The number of the TCP port to use (by default is 1935).
  336. @item app
  337. It is the name of the application to access. It usually corresponds to
  338. the path where the application is installed on the RTMP server
  339. (e.g. @file{/ondemand/}, @file{/flash/live/}, etc.). You can override
  340. the value parsed from the URI through the @code{rtmp_app} option, too.
  341. @item playpath
  342. It is the path or name of the resource to play with reference to the
  343. application specified in @var{app}, may be prefixed by "mp4:". You
  344. can override the value parsed from the URI through the @code{rtmp_playpath}
  345. option, too.
  346. @item listen
  347. Act as a server, listening for an incoming connection.
  348. @item timeout
  349. Maximum time to wait for the incoming connection. Implies listen.
  350. @end table
  351. Additionally, the following parameters can be set via command line options
  352. (or in code via @code{AVOption}s):
  353. @table @option
  354. @item rtmp_app
  355. Name of application to connect on the RTMP server. This option
  356. overrides the parameter specified in the URI.
  357. @item rtmp_buffer
  358. Set the client buffer time in milliseconds. The default is 3000.
  359. @item rtmp_conn
  360. Extra arbitrary AMF connection parameters, parsed from a string,
  361. e.g. like @code{B:1 S:authMe O:1 NN:code:1.23 NS:flag:ok O:0}.
  362. Each value is prefixed by a single character denoting the type,
  363. B for Boolean, N for number, S for string, O for object, or Z for null,
  364. followed by a colon. For Booleans the data must be either 0 or 1 for
  365. FALSE or TRUE, respectively. Likewise for Objects the data must be 0 or
  366. 1 to end or begin an object, respectively. Data items in subobjects may
  367. be named, by prefixing the type with 'N' and specifying the name before
  368. the value (i.e. @code{NB:myFlag:1}). This option may be used multiple
  369. times to construct arbitrary AMF sequences.
  370. @item rtmp_flashver
  371. Version of the Flash plugin used to run the SWF player. The default
  372. is LNX 9,0,124,2. (When publishing, the default is FMLE/3.0 (compatible;
  373. <libavformat version>).)
  374. @item rtmp_flush_interval
  375. Number of packets flushed in the same request (RTMPT only). The default
  376. is 10.
  377. @item rtmp_live
  378. Specify that the media is a live stream. No resuming or seeking in
  379. live streams is possible. The default value is @code{any}, which means the
  380. subscriber first tries to play the live stream specified in the
  381. playpath. If a live stream of that name is not found, it plays the
  382. recorded stream. The other possible values are @code{live} and
  383. @code{recorded}.
  384. @item rtmp_pageurl
  385. URL of the web page in which the media was embedded. By default no
  386. value will be sent.
  387. @item rtmp_playpath
  388. Stream identifier to play or to publish. This option overrides the
  389. parameter specified in the URI.
  390. @item rtmp_subscribe
  391. Name of live stream to subscribe to. By default no value will be sent.
  392. It is only sent if the option is specified or if rtmp_live
  393. is set to live.
  394. @item rtmp_swfhash
  395. SHA256 hash of the decompressed SWF file (32 bytes).
  396. @item rtmp_swfsize
  397. Size of the decompressed SWF file, required for SWFVerification.
  398. @item rtmp_swfurl
  399. URL of the SWF player for the media. By default no value will be sent.
  400. @item rtmp_swfverify
  401. URL to player swf file, compute hash/size automatically.
  402. @item rtmp_tcurl
  403. URL of the target stream. Defaults to proto://host[:port]/app.
  404. @end table
  405. For example to read with @command{ffplay} a multimedia resource named
  406. "sample" from the application "vod" from an RTMP server "myserver":
  407. @example
  408. ffplay rtmp://myserver/vod/sample
  409. @end example
  410. To publish to a password protected server, passing the playpath and
  411. app names separately:
  412. @example
  413. ffmpeg -re -i <input> -f flv -rtmp_playpath some/long/path -rtmp_app long/app/name rtmp://username:password@@myserver/
  414. @end example
  415. @section rtmpe
  416. Encrypted Real-Time Messaging Protocol.
  417. The Encrypted Real-Time Messaging Protocol (RTMPE) is used for
  418. streaming multimedia content within standard cryptographic primitives,
  419. consisting of Diffie-Hellman key exchange and HMACSHA256, generating
  420. a pair of RC4 keys.
  421. @section rtmps
  422. Real-Time Messaging Protocol over a secure SSL connection.
  423. The Real-Time Messaging Protocol (RTMPS) is used for streaming
  424. multimedia content across an encrypted connection.
  425. @section rtmpt
  426. Real-Time Messaging Protocol tunneled through HTTP.
  427. The Real-Time Messaging Protocol tunneled through HTTP (RTMPT) is used
  428. for streaming multimedia content within HTTP requests to traverse
  429. firewalls.
  430. @section rtmpte
  431. Encrypted Real-Time Messaging Protocol tunneled through HTTP.
  432. The Encrypted Real-Time Messaging Protocol tunneled through HTTP (RTMPTE)
  433. is used for streaming multimedia content within HTTP requests to traverse
  434. firewalls.
  435. @section rtmpts
  436. Real-Time Messaging Protocol tunneled through HTTPS.
  437. The Real-Time Messaging Protocol tunneled through HTTPS (RTMPTS) is used
  438. for streaming multimedia content within HTTPS requests to traverse
  439. firewalls.
  440. @section libsmbclient
  441. libsmbclient permits one to manipulate CIFS/SMB network resources.
  442. Following syntax is required.
  443. @example
  444. smb://[[domain:]user[:password@@]]server[/share[/path[/file]]]
  445. @end example
  446. This protocol accepts the following options.
  447. @table @option
  448. @item timeout
  449. Set timeout in miliseconds of socket I/O operations used by the underlying
  450. low level operation. By default it is set to -1, which means that the timeout
  451. is not specified.
  452. @item truncate
  453. Truncate existing files on write, if set to 1. A value of 0 prevents
  454. truncating. Default value is 1.
  455. @item workgroup
  456. Set the workgroup used for making connections. By default workgroup is not specified.
  457. @end table
  458. For more information see: @url{http://www.samba.org/}.
  459. @section libssh
  460. Secure File Transfer Protocol via libssh
  461. Read from or write to remote resources using SFTP protocol.
  462. Following syntax is required.
  463. @example
  464. sftp://[user[:password]@@]server[:port]/path/to/remote/resource.mpeg
  465. @end example
  466. This protocol accepts the following options.
  467. @table @option
  468. @item timeout
  469. Set timeout of socket I/O operations used by the underlying low level
  470. operation. By default it is set to -1, which means that the timeout
  471. is not specified.
  472. @item truncate
  473. Truncate existing files on write, if set to 1. A value of 0 prevents
  474. truncating. Default value is 1.
  475. @item private_key
  476. Specify the path of the file containing private key to use during authorization.
  477. By default libssh searches for keys in the @file{~/.ssh/} directory.
  478. @end table
  479. Example: Play a file stored on remote server.
  480. @example
  481. ffplay sftp://user:password@@server_address:22/home/user/resource.mpeg
  482. @end example
  483. @section librtmp rtmp, rtmpe, rtmps, rtmpt, rtmpte
  484. Real-Time Messaging Protocol and its variants supported through
  485. librtmp.
  486. Requires the presence of the librtmp headers and library during
  487. configuration. You need to explicitly configure the build with
  488. "--enable-librtmp". If enabled this will replace the native RTMP
  489. protocol.
  490. This protocol provides most client functions and a few server
  491. functions needed to support RTMP, RTMP tunneled in HTTP (RTMPT),
  492. encrypted RTMP (RTMPE), RTMP over SSL/TLS (RTMPS) and tunneled
  493. variants of these encrypted types (RTMPTE, RTMPTS).
  494. The required syntax is:
  495. @example
  496. @var{rtmp_proto}://@var{server}[:@var{port}][/@var{app}][/@var{playpath}] @var{options}
  497. @end example
  498. where @var{rtmp_proto} is one of the strings "rtmp", "rtmpt", "rtmpe",
  499. "rtmps", "rtmpte", "rtmpts" corresponding to each RTMP variant, and
  500. @var{server}, @var{port}, @var{app} and @var{playpath} have the same
  501. meaning as specified for the RTMP native protocol.
  502. @var{options} contains a list of space-separated options of the form
  503. @var{key}=@var{val}.
  504. See the librtmp manual page (man 3 librtmp) for more information.
  505. For example, to stream a file in real-time to an RTMP server using
  506. @command{ffmpeg}:
  507. @example
  508. ffmpeg -re -i myfile -f flv rtmp://myserver/live/mystream
  509. @end example
  510. To play the same stream using @command{ffplay}:
  511. @example
  512. ffplay "rtmp://myserver/live/mystream live=1"
  513. @end example
  514. @section rtp
  515. Real-time Transport Protocol.
  516. The required syntax for an RTP URL is:
  517. rtp://@var{hostname}[:@var{port}][?@var{option}=@var{val}...]
  518. @var{port} specifies the RTP port to use.
  519. The following URL options are supported:
  520. @table @option
  521. @item ttl=@var{n}
  522. Set the TTL (Time-To-Live) value (for multicast only).
  523. @item rtcpport=@var{n}
  524. Set the remote RTCP port to @var{n}.
  525. @item localrtpport=@var{n}
  526. Set the local RTP port to @var{n}.
  527. @item localrtcpport=@var{n}'
  528. Set the local RTCP port to @var{n}.
  529. @item pkt_size=@var{n}
  530. Set max packet size (in bytes) to @var{n}.
  531. @item connect=0|1
  532. Do a @code{connect()} on the UDP socket (if set to 1) or not (if set
  533. to 0).
  534. @item sources=@var{ip}[,@var{ip}]
  535. List allowed source IP addresses.
  536. @item block=@var{ip}[,@var{ip}]
  537. List disallowed (blocked) source IP addresses.
  538. @item write_to_source=0|1
  539. Send packets to the source address of the latest received packet (if
  540. set to 1) or to a default remote address (if set to 0).
  541. @item localport=@var{n}
  542. Set the local RTP port to @var{n}.
  543. This is a deprecated option. Instead, @option{localrtpport} should be
  544. used.
  545. @end table
  546. Important notes:
  547. @enumerate
  548. @item
  549. If @option{rtcpport} is not set the RTCP port will be set to the RTP
  550. port value plus 1.
  551. @item
  552. If @option{localrtpport} (the local RTP port) is not set any available
  553. port will be used for the local RTP and RTCP ports.
  554. @item
  555. If @option{localrtcpport} (the local RTCP port) is not set it will be
  556. set to the local RTP port value plus 1.
  557. @end enumerate
  558. @section rtsp
  559. Real-Time Streaming Protocol.
  560. RTSP is not technically a protocol handler in libavformat, it is a demuxer
  561. and muxer. The demuxer supports both normal RTSP (with data transferred
  562. over RTP; this is used by e.g. Apple and Microsoft) and Real-RTSP (with
  563. data transferred over RDT).
  564. The muxer can be used to send a stream using RTSP ANNOUNCE to a server
  565. supporting it (currently Darwin Streaming Server and Mischa Spiegelmock's
  566. @uref{https://github.com/revmischa/rtsp-server, RTSP server}).
  567. The required syntax for a RTSP url is:
  568. @example
  569. rtsp://@var{hostname}[:@var{port}]/@var{path}
  570. @end example
  571. Options can be set on the @command{ffmpeg}/@command{ffplay} command
  572. line, or set in code via @code{AVOption}s or in
  573. @code{avformat_open_input}.
  574. The following options are supported.
  575. @table @option
  576. @item initial_pause
  577. Do not start playing the stream immediately if set to 1. Default value
  578. is 0.
  579. @item rtsp_transport
  580. Set RTSP transport protocols.
  581. It accepts the following values:
  582. @table @samp
  583. @item udp
  584. Use UDP as lower transport protocol.
  585. @item tcp
  586. Use TCP (interleaving within the RTSP control channel) as lower
  587. transport protocol.
  588. @item udp_multicast
  589. Use UDP multicast as lower transport protocol.
  590. @item http
  591. Use HTTP tunneling as lower transport protocol, which is useful for
  592. passing proxies.
  593. @end table
  594. Multiple lower transport protocols may be specified, in that case they are
  595. tried one at a time (if the setup of one fails, the next one is tried).
  596. For the muxer, only the @samp{tcp} and @samp{udp} options are supported.
  597. @item rtsp_flags
  598. Set RTSP flags.
  599. The following values are accepted:
  600. @table @samp
  601. @item filter_src
  602. Accept packets only from negotiated peer address and port.
  603. @item listen
  604. Act as a server, listening for an incoming connection.
  605. @item prefer_tcp
  606. Try TCP for RTP transport first, if TCP is available as RTSP RTP transport.
  607. @end table
  608. Default value is @samp{none}.
  609. @item allowed_media_types
  610. Set media types to accept from the server.
  611. The following flags are accepted:
  612. @table @samp
  613. @item video
  614. @item audio
  615. @item data
  616. @end table
  617. By default it accepts all media types.
  618. @item min_port
  619. Set minimum local UDP port. Default value is 5000.
  620. @item max_port
  621. Set maximum local UDP port. Default value is 65000.
  622. @item timeout
  623. Set maximum timeout (in seconds) to wait for incoming connections.
  624. A value of -1 means infinite (default). This option implies the
  625. @option{rtsp_flags} set to @samp{listen}.
  626. @item reorder_queue_size
  627. Set number of packets to buffer for handling of reordered packets.
  628. @item stimeout
  629. Set socket TCP I/O timeout in microseconds.
  630. @item user-agent
  631. Override User-Agent header. If not specified, it defaults to the
  632. libavformat identifier string.
  633. @end table
  634. When receiving data over UDP, the demuxer tries to reorder received packets
  635. (since they may arrive out of order, or packets may get lost totally). This
  636. can be disabled by setting the maximum demuxing delay to zero (via
  637. the @code{max_delay} field of AVFormatContext).
  638. When watching multi-bitrate Real-RTSP streams with @command{ffplay}, the
  639. streams to display can be chosen with @code{-vst} @var{n} and
  640. @code{-ast} @var{n} for video and audio respectively, and can be switched
  641. on the fly by pressing @code{v} and @code{a}.
  642. @subsection Examples
  643. The following examples all make use of the @command{ffplay} and
  644. @command{ffmpeg} tools.
  645. @itemize
  646. @item
  647. Watch a stream over UDP, with a max reordering delay of 0.5 seconds:
  648. @example
  649. ffplay -max_delay 500000 -rtsp_transport udp rtsp://server/video.mp4
  650. @end example
  651. @item
  652. Watch a stream tunneled over HTTP:
  653. @example
  654. ffplay -rtsp_transport http rtsp://server/video.mp4
  655. @end example
  656. @item
  657. Send a stream in realtime to a RTSP server, for others to watch:
  658. @example
  659. ffmpeg -re -i @var{input} -f rtsp -muxdelay 0.1 rtsp://server/live.sdp
  660. @end example
  661. @item
  662. Receive a stream in realtime:
  663. @example
  664. ffmpeg -rtsp_flags listen -i rtsp://ownaddress/live.sdp @var{output}
  665. @end example
  666. @end itemize
  667. @section sap
  668. Session Announcement Protocol (RFC 2974). This is not technically a
  669. protocol handler in libavformat, it is a muxer and demuxer.
  670. It is used for signalling of RTP streams, by announcing the SDP for the
  671. streams regularly on a separate port.
  672. @subsection Muxer
  673. The syntax for a SAP url given to the muxer is:
  674. @example
  675. sap://@var{destination}[:@var{port}][?@var{options}]
  676. @end example
  677. The RTP packets are sent to @var{destination} on port @var{port},
  678. or to port 5004 if no port is specified.
  679. @var{options} is a @code{&}-separated list. The following options
  680. are supported:
  681. @table @option
  682. @item announce_addr=@var{address}
  683. Specify the destination IP address for sending the announcements to.
  684. If omitted, the announcements are sent to the commonly used SAP
  685. announcement multicast address 224.2.127.254 (sap.mcast.net), or
  686. ff0e::2:7ffe if @var{destination} is an IPv6 address.
  687. @item announce_port=@var{port}
  688. Specify the port to send the announcements on, defaults to
  689. 9875 if not specified.
  690. @item ttl=@var{ttl}
  691. Specify the time to live value for the announcements and RTP packets,
  692. defaults to 255.
  693. @item same_port=@var{0|1}
  694. If set to 1, send all RTP streams on the same port pair. If zero (the
  695. default), all streams are sent on unique ports, with each stream on a
  696. port 2 numbers higher than the previous.
  697. VLC/Live555 requires this to be set to 1, to be able to receive the stream.
  698. The RTP stack in libavformat for receiving requires all streams to be sent
  699. on unique ports.
  700. @end table
  701. Example command lines follow.
  702. To broadcast a stream on the local subnet, for watching in VLC:
  703. @example
  704. ffmpeg -re -i @var{input} -f sap sap://224.0.0.255?same_port=1
  705. @end example
  706. Similarly, for watching in @command{ffplay}:
  707. @example
  708. ffmpeg -re -i @var{input} -f sap sap://224.0.0.255
  709. @end example
  710. And for watching in @command{ffplay}, over IPv6:
  711. @example
  712. ffmpeg -re -i @var{input} -f sap sap://[ff0e::1:2:3:4]
  713. @end example
  714. @subsection Demuxer
  715. The syntax for a SAP url given to the demuxer is:
  716. @example
  717. sap://[@var{address}][:@var{port}]
  718. @end example
  719. @var{address} is the multicast address to listen for announcements on,
  720. if omitted, the default 224.2.127.254 (sap.mcast.net) is used. @var{port}
  721. is the port that is listened on, 9875 if omitted.
  722. The demuxers listens for announcements on the given address and port.
  723. Once an announcement is received, it tries to receive that particular stream.
  724. Example command lines follow.
  725. To play back the first stream announced on the normal SAP multicast address:
  726. @example
  727. ffplay sap://
  728. @end example
  729. To play back the first stream announced on one the default IPv6 SAP multicast address:
  730. @example
  731. ffplay sap://[ff0e::2:7ffe]
  732. @end example
  733. @section sctp
  734. Stream Control Transmission Protocol.
  735. The accepted URL syntax is:
  736. @example
  737. sctp://@var{host}:@var{port}[?@var{options}]
  738. @end example
  739. The protocol accepts the following options:
  740. @table @option
  741. @item listen
  742. If set to any value, listen for an incoming connection. Outgoing connection is done by default.
  743. @item max_streams
  744. Set the maximum number of streams. By default no limit is set.
  745. @end table
  746. @section srtp
  747. Secure Real-time Transport Protocol.
  748. The accepted options are:
  749. @table @option
  750. @item srtp_in_suite
  751. @item srtp_out_suite
  752. Select input and output encoding suites.
  753. Supported values:
  754. @table @samp
  755. @item AES_CM_128_HMAC_SHA1_80
  756. @item SRTP_AES128_CM_HMAC_SHA1_80
  757. @item AES_CM_128_HMAC_SHA1_32
  758. @item SRTP_AES128_CM_HMAC_SHA1_32
  759. @end table
  760. @item srtp_in_params
  761. @item srtp_out_params
  762. Set input and output encoding parameters, which are expressed by a
  763. base64-encoded representation of a binary block. The first 16 bytes of
  764. this binary block are used as master key, the following 14 bytes are
  765. used as master salt.
  766. @end table
  767. @section subfile
  768. Virtually extract a segment of a file or another stream.
  769. The underlying stream must be seekable.
  770. Accepted options:
  771. @table @option
  772. @item start
  773. Start offset of the extracted segment, in bytes.
  774. @item end
  775. End offset of the extracted segment, in bytes.
  776. @end table
  777. Examples:
  778. Extract a chapter from a DVD VOB file (start and end sectors obtained
  779. externally and multiplied by 2048):
  780. @example
  781. subfile,,start,153391104,end,268142592,,:/media/dvd/VIDEO_TS/VTS_08_1.VOB
  782. @end example
  783. Play an AVI file directly from a TAR archive:
  784. @example
  785. subfile,,start,183241728,end,366490624,,:archive.tar
  786. @end example
  787. @section tcp
  788. Transmission Control Protocol.
  789. The required syntax for a TCP url is:
  790. @example
  791. tcp://@var{hostname}:@var{port}[?@var{options}]
  792. @end example
  793. @var{options} contains a list of &-separated options of the form
  794. @var{key}=@var{val}.
  795. The list of supported options follows.
  796. @table @option
  797. @item listen=@var{1|0}
  798. Listen for an incoming connection. Default value is 0.
  799. @item timeout=@var{microseconds}
  800. Set raise error timeout, expressed in microseconds.
  801. This option is only relevant in read mode: if no data arrived in more
  802. than this time interval, raise error.
  803. @item listen_timeout=@var{milliseconds}
  804. Set listen timeout, expressed in milliseconds.
  805. @end table
  806. The following example shows how to setup a listening TCP connection
  807. with @command{ffmpeg}, which is then accessed with @command{ffplay}:
  808. @example
  809. ffmpeg -i @var{input} -f @var{format} tcp://@var{hostname}:@var{port}?listen
  810. ffplay tcp://@var{hostname}:@var{port}
  811. @end example
  812. @section tls
  813. Transport Layer Security (TLS) / Secure Sockets Layer (SSL)
  814. The required syntax for a TLS/SSL url is:
  815. @example
  816. tls://@var{hostname}:@var{port}[?@var{options}]
  817. @end example
  818. The following parameters can be set via command line options
  819. (or in code via @code{AVOption}s):
  820. @table @option
  821. @item ca_file, cafile=@var{filename}
  822. A file containing certificate authority (CA) root certificates to treat
  823. as trusted. If the linked TLS library contains a default this might not
  824. need to be specified for verification to work, but not all libraries and
  825. setups have defaults built in.
  826. The file must be in OpenSSL PEM format.
  827. @item tls_verify=@var{1|0}
  828. If enabled, try to verify the peer that we are communicating with.
  829. Note, if using OpenSSL, this currently only makes sure that the
  830. peer certificate is signed by one of the root certificates in the CA
  831. database, but it does not validate that the certificate actually
  832. matches the host name we are trying to connect to. (With GnuTLS,
  833. the host name is validated as well.)
  834. This is disabled by default since it requires a CA database to be
  835. provided by the caller in many cases.
  836. @item cert_file, cert=@var{filename}
  837. A file containing a certificate to use in the handshake with the peer.
  838. (When operating as server, in listen mode, this is more often required
  839. by the peer, while client certificates only are mandated in certain
  840. setups.)
  841. @item key_file, key=@var{filename}
  842. A file containing the private key for the certificate.
  843. @item listen=@var{1|0}
  844. If enabled, listen for connections on the provided port, and assume
  845. the server role in the handshake instead of the client role.
  846. @end table
  847. Example command lines:
  848. To create a TLS/SSL server that serves an input stream.
  849. @example
  850. ffmpeg -i @var{input} -f @var{format} tls://@var{hostname}:@var{port}?listen&cert=@var{server.crt}&key=@var{server.key}
  851. @end example
  852. To play back a stream from the TLS/SSL server using @command{ffplay}:
  853. @example
  854. ffplay tls://@var{hostname}:@var{port}
  855. @end example
  856. @section udp
  857. User Datagram Protocol.
  858. The required syntax for an UDP URL is:
  859. @example
  860. udp://@var{hostname}:@var{port}[?@var{options}]
  861. @end example
  862. @var{options} contains a list of &-separated options of the form @var{key}=@var{val}.
  863. In case threading is enabled on the system, a circular buffer is used
  864. to store the incoming data, which allows one to reduce loss of data due to
  865. UDP socket buffer overruns. The @var{fifo_size} and
  866. @var{overrun_nonfatal} options are related to this buffer.
  867. The list of supported options follows.
  868. @table @option
  869. @item buffer_size=@var{size}
  870. Set the UDP maximum socket buffer size in bytes. This is used to set either
  871. the receive or send buffer size, depending on what the socket is used for.
  872. Default is 64KB. See also @var{fifo_size}.
  873. @item localport=@var{port}
  874. Override the local UDP port to bind with.
  875. @item localaddr=@var{addr}
  876. Choose the local IP address. This is useful e.g. if sending multicast
  877. and the host has multiple interfaces, where the user can choose
  878. which interface to send on by specifying the IP address of that interface.
  879. @item pkt_size=@var{size}
  880. Set the size in bytes of UDP packets.
  881. @item reuse=@var{1|0}
  882. Explicitly allow or disallow reusing UDP sockets.
  883. @item ttl=@var{ttl}
  884. Set the time to live value (for multicast only).
  885. @item connect=@var{1|0}
  886. Initialize the UDP socket with @code{connect()}. In this case, the
  887. destination address can't be changed with ff_udp_set_remote_url later.
  888. If the destination address isn't known at the start, this option can
  889. be specified in ff_udp_set_remote_url, too.
  890. This allows finding out the source address for the packets with getsockname,
  891. and makes writes return with AVERROR(ECONNREFUSED) if "destination
  892. unreachable" is received.
  893. For receiving, this gives the benefit of only receiving packets from
  894. the specified peer address/port.
  895. @item sources=@var{address}[,@var{address}]
  896. Only receive packets sent to the multicast group from one of the
  897. specified sender IP addresses.
  898. @item block=@var{address}[,@var{address}]
  899. Ignore packets sent to the multicast group from the specified
  900. sender IP addresses.
  901. @item fifo_size=@var{units}
  902. Set the UDP receiving circular buffer size, expressed as a number of
  903. packets with size of 188 bytes. If not specified defaults to 7*4096.
  904. @item overrun_nonfatal=@var{1|0}
  905. Survive in case of UDP receiving circular buffer overrun. Default
  906. value is 0.
  907. @item timeout=@var{microseconds}
  908. Set raise error timeout, expressed in microseconds.
  909. This option is only relevant in read mode: if no data arrived in more
  910. than this time interval, raise error.
  911. @item broadcast=@var{1|0}
  912. Explicitly allow or disallow UDP broadcasting.
  913. Note that broadcasting may not work properly on networks having
  914. a broadcast storm protection.
  915. @end table
  916. @subsection Examples
  917. @itemize
  918. @item
  919. Use @command{ffmpeg} to stream over UDP to a remote endpoint:
  920. @example
  921. ffmpeg -i @var{input} -f @var{format} udp://@var{hostname}:@var{port}
  922. @end example
  923. @item
  924. Use @command{ffmpeg} to stream in mpegts format over UDP using 188
  925. sized UDP packets, using a large input buffer:
  926. @example
  927. ffmpeg -i @var{input} -f mpegts udp://@var{hostname}:@var{port}?pkt_size=188&buffer_size=65535
  928. @end example
  929. @item
  930. Use @command{ffmpeg} to receive over UDP from a remote endpoint:
  931. @example
  932. ffmpeg -i udp://[@var{multicast-address}]:@var{port} ...
  933. @end example
  934. @end itemize
  935. @section unix
  936. Unix local socket
  937. The required syntax for a Unix socket URL is:
  938. @example
  939. unix://@var{filepath}
  940. @end example
  941. The following parameters can be set via command line options
  942. (or in code via @code{AVOption}s):
  943. @table @option
  944. @item timeout
  945. Timeout in ms.
  946. @item listen
  947. Create the Unix socket in listening mode.
  948. @end table
  949. @c man end PROTOCOLS