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.

1088 lines
31KB

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