You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

678 lines
18KB

  1. \input texinfo @c -*- texinfo -*-
  2. @settitle ffserver Documentation
  3. @titlepage
  4. @center @titlefont{ffserver Documentation}
  5. @end titlepage
  6. @top
  7. @contents
  8. @chapter Synopsis
  9. ffserver [@var{options}]
  10. @chapter Description
  11. @c man begin DESCRIPTION
  12. @command{ffserver} is a streaming server for both audio and video. It
  13. supports several live feeds, streaming from files and time shifting on
  14. live feeds (you can seek to positions in the past on each live feed,
  15. provided you specify a big enough feed storage in
  16. @file{ffserver.conf}).
  17. @command{ffserver} receives prerecorded files or FFM streams from some
  18. @command{ffmpeg} instance as input, then streams them over
  19. RTP/RTSP/HTTP.
  20. An @command{ffserver} instance will listen on some port as specified
  21. in the configuration file. You can launch one or more instances of
  22. @command{ffmpeg} and send one or more FFM streams to the port where
  23. ffserver is expecting to receive them. Alternately, you can make
  24. @command{ffserver} launch such @command{ffmpeg} instances at startup.
  25. Input streams are called feeds, and each one is specified by a
  26. @code{<Feed>} section in the configuration file.
  27. For each feed you can have different output streams in various
  28. formats, each one specified by a @code{<Stream>} section in the
  29. configuration file.
  30. @section Status stream
  31. @command{ffserver} supports an HTTP interface which exposes the
  32. current status of the server.
  33. Simply point your browser to the address of the special status stream
  34. specified in the configuration file.
  35. For example if you have:
  36. @example
  37. <Stream status.html>
  38. Format status
  39. # Only allow local people to get the status
  40. ACL allow localhost
  41. ACL allow 192.168.0.0 192.168.255.255
  42. </Stream>
  43. @end example
  44. then the server will post a page with the status information when
  45. the special stream @file{status.html} is requested.
  46. @section How do I make it work?
  47. First, build the kit. It *really* helps to have installed LAME first. Then when
  48. you run the ffserver ./configure, make sure that you have the
  49. @code{--enable-libmp3lame} flag turned on.
  50. LAME is important as it allows for streaming audio to Windows Media Player.
  51. Don't ask why the other audio types do not work.
  52. As a simple test, just run the following two command lines where INPUTFILE
  53. is some file which you can decode with ffmpeg:
  54. @example
  55. ffserver -f doc/ffserver.conf &
  56. ffmpeg -i INPUTFILE http://localhost:8090/feed1.ffm
  57. @end example
  58. At this point you should be able to go to your Windows machine and fire up
  59. Windows Media Player (WMP). Go to Open URL and enter
  60. @example
  61. http://<linuxbox>:8090/test.asf
  62. @end example
  63. You should (after a short delay) see video and hear audio.
  64. WARNING: trying to stream test1.mpg doesn't work with WMP as it tries to
  65. transfer the entire file before starting to play.
  66. The same is true of AVI files.
  67. @section What happens next?
  68. You should edit the ffserver.conf file to suit your needs (in terms of
  69. frame rates etc). Then install ffserver and ffmpeg, write a script to start
  70. them up, and off you go.
  71. @section What else can it do?
  72. You can replay video from .ffm files that was recorded earlier.
  73. However, there are a number of caveats, including the fact that the
  74. ffserver parameters must match the original parameters used to record the
  75. file. If they do not, then ffserver deletes the file before recording into it.
  76. (Now that I write this, it seems broken).
  77. You can fiddle with many of the codec choices and encoding parameters, and
  78. there are a bunch more parameters that you cannot control. Post a message
  79. to the mailing list if there are some 'must have' parameters. Look in
  80. ffserver.conf for a list of the currently available controls.
  81. It will automatically generate the ASX or RAM files that are often used
  82. in browsers. These files are actually redirections to the underlying ASF
  83. or RM file. The reason for this is that the browser often fetches the
  84. entire file before starting up the external viewer. The redirection files
  85. are very small and can be transferred quickly. [The stream itself is
  86. often 'infinite' and thus the browser tries to download it and never
  87. finishes.]
  88. @section Tips
  89. * When you connect to a live stream, most players (WMP, RA, etc) want to
  90. buffer a certain number of seconds of material so that they can display the
  91. signal continuously. However, ffserver (by default) starts sending data
  92. in realtime. This means that there is a pause of a few seconds while the
  93. buffering is being done by the player. The good news is that this can be
  94. cured by adding a '?buffer=5' to the end of the URL. This means that the
  95. stream should start 5 seconds in the past -- and so the first 5 seconds
  96. of the stream are sent as fast as the network will allow. It will then
  97. slow down to real time. This noticeably improves the startup experience.
  98. You can also add a 'Preroll 15' statement into the ffserver.conf that will
  99. add the 15 second prebuffering on all requests that do not otherwise
  100. specify a time. In addition, ffserver will skip frames until a key_frame
  101. is found. This further reduces the startup delay by not transferring data
  102. that will be discarded.
  103. * You may want to adjust the MaxBandwidth in the ffserver.conf to limit
  104. the amount of bandwidth consumed by live streams.
  105. @section Why does the ?buffer / Preroll stop working after a time?
  106. It turns out that (on my machine at least) the number of frames successfully
  107. grabbed is marginally less than the number that ought to be grabbed. This
  108. means that the timestamp in the encoded data stream gets behind realtime.
  109. This means that if you say 'Preroll 10', then when the stream gets 10
  110. or more seconds behind, there is no Preroll left.
  111. Fixing this requires a change in the internals of how timestamps are
  112. handled.
  113. @section Does the @code{?date=} stuff work.
  114. Yes (subject to the limitation outlined above). Also note that whenever you
  115. start ffserver, it deletes the ffm file (if any parameters have changed),
  116. thus wiping out what you had recorded before.
  117. The format of the @code{?date=xxxxxx} is fairly flexible. You should use one
  118. of the following formats (the 'T' is literal):
  119. @example
  120. * YYYY-MM-DDTHH:MM:SS (localtime)
  121. * YYYY-MM-DDTHH:MM:SSZ (UTC)
  122. @end example
  123. You can omit the YYYY-MM-DD, and then it refers to the current day. However
  124. note that @samp{?date=16:00:00} refers to 16:00 on the current day -- this
  125. may be in the future and so is unlikely to be useful.
  126. You use this by adding the ?date= to the end of the URL for the stream.
  127. For example: @samp{http://localhost:8080/test.asf?date=2002-07-26T23:05:00}.
  128. @c man end
  129. @section What is FFM, FFM2
  130. FFM and FFM2 are formats used by ffserver. They allow storing a wide variety of
  131. video and audio streams and encoding options, and can store a moving time segment
  132. of an infinite movie or a whole movie.
  133. FFM is version specific, and there is limited compatibility of FFM files
  134. generated by one version of ffmpeg/ffserver and another version of
  135. ffmpeg/ffserver. It may work but it is not guaranteed to work.
  136. FFM2 is extensible while maintaining compatibility and should work between
  137. differing versions of tools. FFM2 is the default.
  138. @chapter Options
  139. @c man begin OPTIONS
  140. @include fftools-common-opts.texi
  141. @section Main options
  142. @table @option
  143. @item -f @var{configfile}
  144. Use @file{configfile} instead of @file{/etc/ffserver.conf}.
  145. @item -n
  146. Enable no-launch mode. This option disables all the Launch directives
  147. within the various <Stream> sections. Since ffserver will not launch
  148. any ffmpeg instances, you will have to launch them manually.
  149. @item -d
  150. Enable debug mode. This option increases log verbosity, directs log
  151. messages to stdout.
  152. @end table
  153. @chapter Configuration file syntax
  154. @command{ffserver} reads a configuration file containing global
  155. options and settings for each stream and feed.
  156. The configuration file consists of global options and dedicated
  157. sections, which must be introduced by "<@var{SECTION_NAME}
  158. @var{ARGS}>" on a separate line and must be terminated by a line in
  159. the form "</@var{SECTION_NAME}>". @var{ARGS} is optional.
  160. Currently the following sections are recognized: @samp{Feed},
  161. @samp{Stream}, @samp{Redirect}.
  162. A line starting with @code{#} is ignored and treated as a comment.
  163. @section Global options
  164. @table @option
  165. @item Port @var{port_number}
  166. @item RTSPPort @var{port_number}
  167. Set TCP port number on which the HTTP/RTSP server is listening. You
  168. must select a different port from your standard HTTP web server if it
  169. is running on the same computer.
  170. If not specified, no corresponding server will be created.
  171. @item BindAddress @var{ip_address}
  172. @item RTSPBindAddress @var{ip_address}
  173. Set address on which the HTTP/RTPS server is bound. Only useful if you
  174. have several network interfaces.
  175. @item MaxHTTPConnections @var{n}
  176. Set number of simultaneous HTTP connections that can be handled. It
  177. has to be defined @emph{before} the @option{MaxClients} parameter,
  178. since it defines the @option{MaxClients} maximum limit.
  179. Default value is 2000.
  180. @item MaxClients @var{n}
  181. Set number of simultaneous requests that can be handled. Since
  182. @command{ffserver} is very fast, it is more likely that you will want
  183. to leave this high and use @option{MaxBandwidth}.
  184. Default value is 5.
  185. @item MaxBandwidth @var{kbps}
  186. Set the maximum amount of kbit/sec that you are prepared to consume
  187. when streaming to clients.
  188. Default value is 1000.
  189. @item CustomLog @var{filename}
  190. Set access log file (uses standard Apache log file format).
  191. '-' is the standard output.
  192. @end table
  193. @section ACL syntax
  194. An ACL (Access Control List) specifies the address which are allowed
  195. to access a given stream, or to write a given feed.
  196. It accepts the folling forms
  197. @itemize
  198. @item
  199. Allow/deny access to @var{address}.
  200. @example
  201. ACL ALLOW <address>
  202. ACL DENY <address>
  203. @end example
  204. @item
  205. Allow/deny access to ranges of addresses from @var{first_address} to
  206. @var{last_address}.
  207. @example
  208. ACL ALLOW <first_address> <last_address>
  209. ACL DENY <first_address> <last_address>
  210. @end example
  211. @end itemize
  212. You can repeat the ACL allow/deny as often as you like. It is on a per
  213. stream basis. The first match defines the action. If there are no matches,
  214. then the default is the inverse of the last ACL statement.
  215. Thus 'ACL allow localhost' only allows access from localhost.
  216. 'ACL deny 1.0.0.0 1.255.255.255' would deny the whole of network 1 and
  217. allow everybody else.
  218. @section Feed section
  219. A Feed section defines a feed provided to @command{ffserver}.
  220. Each live feed contains one video and/or audio sequence coming from an
  221. @command{ffmpeg} encoder or another @command{ffserver}. This sequence
  222. may be encoded simultaneously with several codecs at several
  223. resolutions.
  224. A feed instance specification is introduced by a line in the form:
  225. @example
  226. <Feed FEED_FILENAME>
  227. @end example
  228. where @var{FEED_FILENAME} specifies the unique name of the FFM stream.
  229. The following options are recognized within a Feed section.
  230. @table @option
  231. @item File @var{filename}
  232. Set the path where the file is stored on disk.
  233. @item FileMaxSize @var{size}
  234. Set maximum size of the feed. 0 means unlimited.
  235. @item ReadOnlyFile @var{filename}
  236. Mark the file as readonly and it will not be deleted or updated.
  237. @item Launch
  238. @item ACL
  239. Specify the list of IP address which are allowed or denied to write
  240. the feed. Multiple ACL options can be specified.
  241. @end table
  242. @section Stream section
  243. A Stream section defines a stream provided by @command{ffserver}, and
  244. identified by a single name.
  245. The stream is sent when answering a request containing the stream
  246. name.
  247. A stream section must be introduced by the line:
  248. @example
  249. <Stream STREAM_NAME>
  250. @end example
  251. where @var{STREAM_NAME} specifies the unique name of the stream.
  252. The following options are recognized within a Stream section.
  253. @table @option
  254. @item Feed @var{feed_name}
  255. Set the input feed.
  256. Must be specified.
  257. @item Format @var{format_name}
  258. Set the format of the stream.
  259. Must be the name of a format recognized by FFmpeg.
  260. @item AudioBitRate @var{rate}
  261. Set bitrate for the audio stream in KB per second.
  262. @item AudioChannels @var{n}
  263. Set number of audio channels.
  264. @item AudioSampleRate @var{n}
  265. Set sampling frequency for audio. When using low bitrates, you should
  266. lower this frequency to 22050 or 11025. The supported frequencies
  267. depend on the selected audio codec.
  268. @item VideoBitRate @var{n}
  269. Set bitrate for the video stream in KB per second.
  270. @item VideoBitRateRange @var{range}
  271. Set video bitrate range.
  272. @item VideoBitRateRangeTolerance @var{n}
  273. @item PixelFormat
  274. Set video pixel format.
  275. @item VideoBufferSize @var{n}
  276. Set ratecontrol buffer size.
  277. @item VideoFrameRate @var{n}
  278. Set number of video frames per second.
  279. @item VideoSize
  280. Set size of the video frame, must be an abbreviation or in the form
  281. @var{W}x@var{H}. See @ref{video size syntax,,the Video size section
  282. in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  283. Default value is @code{160x128}.
  284. @item VideoIntraOnly
  285. Transmit only intra frames (useful for low bitrates, but kills frame rate).
  286. @item VideoGopSize @var{n}
  287. If non-intra only, an intra frame is transmitted every VideoGopSize
  288. frames. Video synchronization can only begin at an intra frame.
  289. @item VideoHighQuality
  290. @item Video4MotionVector
  291. @item AudioCodec @var{codec_name}
  292. @item VideoCodec @var{codec_name}
  293. Set audio/video codec.
  294. @item NoAudio
  295. @item NoVideo
  296. Suppress audio/video.
  297. @item VideoQMin @var{n}
  298. @item VideoQMax @var{n}
  299. Set video qmin/qmax.
  300. @item AVOptionAudio @var{option} @var{value}
  301. @item AVOptionVideo @var{option} @var{value}
  302. Set generic option for audio/video stream.
  303. @item AVPresetAudio @var{preset}
  304. @item AVOptionVideo @var{preset}
  305. Set preset for audio/video stream.
  306. @var{preset} must be the path of a preset file.
  307. @item Preroll @var{n}
  308. Set this to the number of seconds backwards in time to start. Note that
  309. most players will buffer 5-10 seconds of video, and also you need to allow
  310. for a keyframe to appear in the data stream.
  311. @item ACL @var{spec}
  312. Set ACL for the stream.
  313. @item Author @var{value}
  314. @item Comment @var{value}
  315. @item Copyright @var{value}
  316. @item Title @var{value}
  317. Set metadata corresponding to the option.
  318. @item StartSendOnKey
  319. Do not send stream until it gets the first key frame. By default
  320. @command{ffserver} will send data immediately.
  321. @item FaviconURL @var{url}
  322. Set favicon (favourite icon) for the server status page. It is ignored
  323. for regular streams.
  324. @end table
  325. @subsection Server status stream
  326. A server status stream is a special stream which is used to show
  327. statistics about the @command{ffserver} operations.
  328. It must be specified setting the option @option{Format} to
  329. @code{status}.
  330. @section Redirect section
  331. A redirect section specifies where to redirect the requested URL to
  332. another page.
  333. A redirect section must be introduced by the line:
  334. @example
  335. <Redirect NAME>
  336. @end example
  337. where @var{NAME} is the name of the page which should be redirected.
  338. It only accepts the option @option{URL}, which specify the redirection
  339. URL.
  340. @chapter Stream examples
  341. @itemize
  342. @item
  343. Multipart JPEG
  344. @example
  345. <Stream test.mjpg>
  346. Feed feed1.ffm
  347. Format mpjpeg
  348. VideoFrameRate 2
  349. VideoIntraOnly
  350. NoAudio
  351. Strict -1
  352. </Stream>
  353. @end example
  354. @item
  355. Single JPEG
  356. @example
  357. <Stream test.jpg>
  358. Feed feed1.ffm
  359. Format jpeg
  360. VideoFrameRate 2
  361. VideoIntraOnly
  362. #VideoSize 352x240
  363. NoAudio
  364. Strict -1
  365. </Stream>
  366. @end example
  367. @item
  368. Flash
  369. @example
  370. <Stream test.swf>
  371. Feed feed1.ffm
  372. Format swf
  373. VideoFrameRate 2
  374. VideoIntraOnly
  375. NoAudio
  376. </Stream>
  377. @end example
  378. @item
  379. ASF compatible
  380. @example
  381. <Stream test.asf>
  382. Feed feed1.ffm
  383. Format asf
  384. VideoFrameRate 15
  385. VideoSize 352x240
  386. VideoBitRate 256
  387. VideoBufferSize 40
  388. VideoGopSize 30
  389. AudioBitRate 64
  390. StartSendOnKey
  391. </Stream>
  392. @end example
  393. @item
  394. MP3 audio
  395. @example
  396. <Stream test.mp3>
  397. Feed feed1.ffm
  398. Format mp2
  399. AudioCodec mp3
  400. AudioBitRate 64
  401. AudioChannels 1
  402. AudioSampleRate 44100
  403. NoVideo
  404. </Stream>
  405. @end example
  406. @item
  407. Ogg Vorbis audio:
  408. @example
  409. <Stream test.ogg>
  410. Feed feed1.ffm
  411. Title "Stream title"
  412. AudioBitRate 64
  413. AudioChannels 2
  414. AudioSampleRate 44100
  415. NoVideo
  416. </Stream>
  417. @end example
  418. @item
  419. Real with audio only at 32 kbits
  420. @example
  421. <Stream test.ra>
  422. Feed feed1.ffm
  423. Format rm
  424. AudioBitRate 32
  425. NoVideo
  426. NoAudio
  427. </Stream>
  428. @end example
  429. @item
  430. Real with audio and video at 64 kbits
  431. @example
  432. <Stream test.rm>
  433. Feed feed1.ffm
  434. Format rm
  435. AudioBitRate 32
  436. VideoBitRate 128
  437. VideoFrameRate 25
  438. VideoGopSize 25
  439. NoAudio
  440. </Stream>
  441. @end example
  442. @item
  443. For stream coming from a file: you only need to set the input filename
  444. and optionally a new format.
  445. @example
  446. <Stream file.rm>
  447. File "/usr/local/httpd/htdocs/tlive.rm"
  448. NoAudio
  449. </Stream>
  450. @end example
  451. @example
  452. <Stream file.asf>
  453. File "/usr/local/httpd/htdocs/test.asf"
  454. NoAudio
  455. Author "Me"
  456. Copyright "Super MegaCorp"
  457. Title "Test stream from disk"
  458. Comment "Test comment"
  459. </Stream>
  460. @end example
  461. @end itemize
  462. @c man end
  463. @include config.texi
  464. @ifset config-all
  465. @ifset config-avutil
  466. @include utils.texi
  467. @end ifset
  468. @ifset config-avcodec
  469. @include codecs.texi
  470. @include bitstream_filters.texi
  471. @end ifset
  472. @ifset config-avformat
  473. @include formats.texi
  474. @include protocols.texi
  475. @end ifset
  476. @ifset config-avdevice
  477. @include devices.texi
  478. @end ifset
  479. @ifset config-swresample
  480. @include resampler.texi
  481. @end ifset
  482. @ifset config-swscale
  483. @include scaler.texi
  484. @end ifset
  485. @ifset config-avfilter
  486. @include filters.texi
  487. @end ifset
  488. @end ifset
  489. @chapter See Also
  490. @ifhtml
  491. @ifset config-all
  492. @url{ffserver.html,ffserver},
  493. @end ifset
  494. @ifset config-not-all
  495. @url{ffserver-all.html,ffserver-all},
  496. @end ifset
  497. the @file{doc/ffserver.conf} example,
  498. @url{ffmpeg.html,ffmpeg}, @url{ffplay.html,ffplay}, @url{ffprobe.html,ffprobe},
  499. @url{ffmpeg-utils.html,ffmpeg-utils},
  500. @url{ffmpeg-scaler.html,ffmpeg-scaler},
  501. @url{ffmpeg-resampler.html,ffmpeg-resampler},
  502. @url{ffmpeg-codecs.html,ffmpeg-codecs},
  503. @url{ffmpeg-bitstream-filters.html,ffmpeg-bitstream-filters},
  504. @url{ffmpeg-formats.html,ffmpeg-formats},
  505. @url{ffmpeg-devices.html,ffmpeg-devices},
  506. @url{ffmpeg-protocols.html,ffmpeg-protocols},
  507. @url{ffmpeg-filters.html,ffmpeg-filters}
  508. @end ifhtml
  509. @ifnothtml
  510. @ifset config-all
  511. ffserver(1),
  512. @end ifset
  513. @ifset config-not-all
  514. ffserver-all(1),
  515. @end ifset
  516. the @file{doc/ffserver.conf} example, ffmpeg(1), ffplay(1), ffprobe(1),
  517. ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1),
  518. ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1),
  519. ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1)
  520. @end ifnothtml
  521. @include authors.texi
  522. @ignore
  523. @setfilename ffserver
  524. @settitle ffserver video server
  525. @end ignore
  526. @bye