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.

721 lines
20KB

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