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.

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