Note: this page is not complete. I got errors on my laptop as well as my desktop. This page will be completed once those are fixed.
In this section, we'll setup ffserver with Ubuntu 13.04. Then, do streaming via localhost.
First, we need to start the server. To start it, we need ffserver.conf. But for now, we can just copy it from http://ffmpeg.org/sample.html, and put it unser /etc.
Once we create a valid config file, we can start ffserver:
$ ffserver -f /etc/ffserver.conf & ffserver version git-2013-10-30-e1848aa Copyright (c) 2000-2013 the FFmpeg developers built on Oct 29 2013 19:55:56 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu8) configuration: --prefix=/home/khong/ffmpeg_build --extra-cflags=-I/home/khong/ffmpeg_build/include --extra-ldflags=-L/home/khong/ffmpeg_build/lib --bindir=/home/khong/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab libavutil 52. 48.100 / 52. 48.100 libavcodec 55. 39.100 / 55. 39.100 libavformat 55. 19.104 / 55. 19.104 libavdevice 55. 5.100 / 55. 5.100 libavfilter 3. 90.100 / 3. 90.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 Tue Oct 29 20:06:13 2013 FFserver started.
Once our ffserver is up and running, it's time to connect input sources to it. Without input sources, our ffserver is not going to broadcast anything to the outside world and will be pretty much useless. So, let's see how we can connect input sources to ffserver. The simplest way is to use the ffmpeg tool.
$ ffmpeg \ -f v4l2 -s 320x240 -r 25 -i /dev/video0 \ -f alsa -ac 1 -i hw:0 \ http://localhost:8090/feed1.ffm
Initially, I got the following error:
ffmpeg version git-2013-10-30-e1848aa Copyright (c) 2000-2013 the FFmpeg developers built on Oct 29 2013 19:55:56 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu8) configuration: --prefix=/home/khong/ffmpeg_build --extra-cflags=-I/home/khong/ffmpeg_build/include --extra-ldflags=-L/home/khong/ffmpeg_build/lib --bindir=/home/khong/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab libavutil 52. 48.100 / 52. 48.100 libavcodec 55. 39.100 / 55. 39.100 libavformat 55. 19.104 / 55. 19.104 libavdevice 55. 5.100 / 55. 5.100 libavfilter 3. 90.100 / 3. 90.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 [video4linux2,v4l2 @ 0x1ab42e0] The driver changed the time per frame from 1/25 to 1/30 Input #0, video4linux2,v4l2, from '/dev/video0': Duration: N/A, start: 13686.146927, bitrate: 36864 kb/s Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 320x240, 36864 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc [alsa @ 0x1ab5e60] cannot open audio device hw:0 (No such file or directory) hw:0: Input/output error
If I use arecord, aplay, and amixer:
$ arecord -l **** List of CAPTURE Hardware Devices **** card 1: Generic_1 [HD-Audio Generic], device 0: ALC269VC Analog [ALC269VC Analog] Subdevices: 0/1 Subdevice #0: subdevice #0 $ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: Generic_1 [HD-Audio Generic], device 0: ALC269VC Analog [ALC269VC Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 $ amixer Simple mixer control 'IEC958',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [on]
An ALSA identifier has the syntax:
hw:CARD[,DEV[,SUBDEV]]
where the DEV and SUBDEV components are optional.
To capture with ffmpeg from an ALSA device with card id 0 or 1:
$ ffmpeg -f alsa -i hw: alsaout.wav ... [alsa @ 0x27f0980] cannot open audio device hw:0 (No such file or directory) hw:0: Input/output error $ ffmpeg -f alsa -i hw:1 alsaout.wav ... [alsa @ 0x356b980] cannot open audio device hw:1 (Device or resource busy) hw:1: Input/output error
To see the list of cards currently recognized by our system check the files "/proc/asound/cards" and "/proc/asound/devices":
$ cd /proc/asound/ $ ls card0 card1 cards devices Generic Generic_1 hwdep modules pcm seq timers version $ cd card0 $ ls codec#0 eld#0.0 id pcm3p $ cd ../card1 $ ls codec#0 id pcm0c pcm0p $ cd ../Generic $ ls codec#0 eld#0.0 id pcm3p $ cd ../Generic_1 $ ls codec#0 id pcm0c pcm0p