Stream a DV-camera using vlc

From Alpine Linux
Revision as of 06:15, 12 March 2012 by Mhavela (talk | contribs) (x264 variables.)
This material is work-in-progress ...

Do not follow instructions here until this notice is removed.
(Last edited by Mhavela on 12 Mar 2012.)

In this howto we are going to stream the video coming from a DV-camera connected through ie1394 (firewire).
vlc is used to stream the content.
We will be using h264 and AAC to transcode the stream (should be fairly easy to change to whatever suits your needs).

Setup Alpine

Initial Setup

Follow Installing_Alpine to setup Alpine Linux.

Install programs

apk add vlc-daemon vlc-dev

Todo: I haven't figured out why vlc-dev is needed. Manually adding all vlc-dev dependencies does not work


Using ACF to control vlc

Todo: Create Makefiles and test acf-vlc-daemon and remove this note when it works


Tip: A easy way to control vlc-daemon would be through ACF. Consider following these simple steps.
But as it is optional you could just skip this ACF section.

Setup/install acf (unless it's not already done).

setup-acf

Install acf-package for vlc

apk add acf-vlc-daemon

We won't describe in this tutorial how you would use ACF to control vlc-daemon (basically because it's so simple it does not need any describing).
If you installed ACF, just browse https://ip.of.your.box and you would from this tutorial understand what to do.

Configure vlc

Configuration is done by modifying '/etc/conf.d/vlc'.
Here comes the actual configuration that makes vlc stream the DV-camera.

###############
BITRATE=500

###############
# DV 720x576, vga 640x480, dcif 528x384
XRES=720
YRES=576

###############
# H.264 options for speed
H264_OPT_FRAMETYPE="keyint=250,min-keyint=25,bframes=3,ref=3"
H264_OPT_RATECONTROL="qcomp=0.1,qpstep=10,ratetol=0.1,vbv-maxrate=${BITRATE},vbv-bufsize=256"
H264_OPT_ANALYSIS="me=hex,subme=3,merange=8,8x8dct,partitions=p8x8,trellis=0"
# Bind everything together
H264="${H264_OPT_FRAMETYPE},${H264_OPT_RATECONTROL},${H264_OPT_ANALYSIS}"

###############
# Transcoder
TVIDEO="venc=x264{$H264},vcodec=h264,vb=${BITRATE},scale=1,width=${XRES},height=${YRES}"
TAUDIO="acodec=mp4a,ab=64,channels=1,samplerate=32000"
TMISC="deinterlace,audio-sync"

###############
TRANSPORT="std{access=http,mux=ts,dst=0.0.0.0:2012}"

VLC_OPTS="--daemon -I dummy dv:///dev/fw0 --rawdv-hurry-up --sout-keep --sout-transcode-audio-sync \
--file-logging --logfile /var/log/vlc/vlc.log \
--sout #transcode{$TVIDEO,$TAUDIO,$TMISC}:$TRANSPORT"
Todo: Finetune the x264 parameters


Start it up

Prepare the hardware

Here comes the hardest part in this tutorial... Attach the DV-camera to your ie1394/firewire port.
Well... that wasn't too hard! :-)

Manual start

Start vlc-daemon either from terminal:

/etc/init.d/vlc start

or using ACF and just klick [Start].

Make it start at next reboot

You might want to make it automatically start at next reboot

rc-update add vlc-daemon default

Debug

In case something goes wrong, consider looking at the logfiles.

less -I /var/log/vlc/vlc.log

If you don't find any useful information you could add verbosity by adding '-v' or '-vv' to /etc/conf.d/vlc and restart vlc (you would need to restart vlc-daemon to see more information in the logs).