protocols.texi 39 KB

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