Skip to content

Instantly share code, notes, and snippets.

@arkadijs
Last active August 29, 2015 14:15
Show Gist options
  • Save arkadijs/07856cb195b7ac3f256c to your computer and use it in GitHub Desktop.
Save arkadijs/07856cb195b7ac3f256c to your computer and use it in GitHub Desktop.
HDV FireWire camcoder for Google Hangouts / V4L2 / WebRTC

HDV FireWire camcoder for Google Hangouts / V4L2 / WebRTC

Core i7 class CPU recommended.

On Ubuntu Linux 14.04, install v4l2loopback driver from repository:

apt-get install -y v4l2loopback-dkms v4l2loopback-utils

..or from latest sources:

apt-get install -y linux-headers-generic git make gcc
git clone https://github.com/umlaeute/v4l2loopback.git
cd v4l2loopback && make && sudo make install install-utils

Load the driver:

sudo modprobe v4l2loopback devices=4

Number of devices is optional. Configure the loopback:

v4l2loopback-ctl set-fps 25 /dev/video0
v4l2loopback-ctl set-caps \
    'video/x-raw-yuv, width=1920, height=1080, format=(fourcc)I420' \
    /dev/video0

Install video software

apt-get install -y dvgrab mplayer mencoder

Launch DV conversion to V4L2:

dvgrab - |
    mencoder -ovc raw -nosound -vf scale=1920:-1,format=i420 -o /dev/video0 -

Notice trailing -. Another format to try is YUY2, but YMMV.

Test the video:

mplayer tv:// -tv device=/dev/video0

Video is lagging - let introduce latency to audio.

Install SWH LADSPA plugins

apt-get install -y swh-plugins

Choose a delay:

delay=0.3 # seconds

Do PulseAudio magic:

pactl load-module module-null-sink
pactl load-module module-ladspa-sink sink_name=ladspa master=null \
    plugin=delay_1898 label=delay_n control=$delay,$delay
pactl load-module module-loopback sink=ladspa

After Hangout is started, use PulseAudio Volume Control (pavucontrol) to move Chrome (WEBRTC with Firefox) on Recording tab to Monitor of Null Output, or from command line:

id=$(pactl list short source-outputs | 
    grep 'protocol-native.*s16le' |
    awk '{print $1}')
pactl move-source-output $id null.monitor

Choose another delay, reload PA modules with pact list short modules / pactl unload-module #INDEX or pulseaudio -k. Wash-repeat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment