protocols.texi 37 KB

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