Skip to content

FFserver

Stream

스트리밍은 <Stream>를 사용하면 된다. 이 경우 스트리밍할 포맷(Format)을 정확히 입력해야 하며, Feed또는 File의 포맷이 일치해야 한다.

Example

아래와 같이 FFserver 설정파일을 생성한다. HTTP를 사용하는 8090과 RTPS를 사용하는 8091포트는 미리 방화벽을 풀어준다.

Port 8090
RTSPPort 8091
# bind to all IPs aliased or not 
BindAddress 0.0.0.0
# max number of simultaneous clients 
MaxClients 1000
# max bandwidth per-client (kb/s) 
MaxBandwidth 10000
# Suppress that if you want to launch ffserver as a daemon. 
NoDaemon

<Feed feed1.ffm>
  File /tmp/feed1.ffm
  FileMaxSize 5M
</Feed>

<Stream test.swf>
  Feed feed1.ffm
  Format swf
  VideoCodec flv
  VideoFrameRate 15
  VideoBufferSize 80000
  VideoBitRate 100
  VideoQMin 1
  VideoQMax 5
  VideoSize 352x288
  PreRoll 0
  Noaudio
</Stream>

<Stream sample.mpg>
  Format rtp
  File "/home/your/Downloads/test1.mpg"
</Stream>

<Stream stat.html>
  Format status
  ACL allow localhost
  ACL allow 192.168.0.0 192.168.255.255
</Stream>

설정파일을 사용하여 FFserver를 백그라운드에서 실행한다.

ffserver -d -f ~/ffserver.conf &

FFmpeg를 사용하여 카메라 영상을 FFserver에 전송한다.

ffmpeg -r 25 -s 352x288 -f video4linux2 -i /dev/video0 http://localhost:8090/feed1.ffm

참고로 아래와 같이 사용하면 현재 화면을 캡쳐할 수 있다.

ffmpeg -f x11grab -r 25 -s 1280x800 -i :0.0 -f alsa -i pulse http://localhost:8090/feed1.ffm

아래와 같이 클라이언트에서 접속할 수 있다.

More example

아래와 같은 방법으로 h264 스트리밍이 가능하다.

# Transcode an incoming live feed to another live feed,
# using libx264 and video presets

<Stream live.h264>
Format rtp
Feed feed1.ffm
VideoCodec libx264
VideoFrameRate 24
VideoBitRate 100
VideoSize 480x272
AVPresetVideo default
AVPresetVideo baseline
AVOptionVideo flags +global_header

AudioCodec libfaac
AudioBitRate 32
AudioChannels 2
AudioSampleRate 22050
AVOptionAudio flags +global_header
</Stream>

See also

Troubleshooting

FFserver 사용시 발생할 수 있는 문제점 및 해결 방법에 대하여 정리한다.

Android MediaPlayer streaming

Favorite site

Streaming

References


  1. Ffmpeg_ffserver_streaming_server.pdf