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.

1342 lines
37KB

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