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.

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