protocols.texi 39 KB

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