Experiences with the easycap DC60 audio and video capture adapter on Linux

This Blog is dedicated to all owners of the STK1160 chip based EasyCAP (or identical) devices, who want to use it under Linux.

Activating audio for the STK1160 device: read the this post

German speaking users: read my article on ubuntuusers.de

The EasyCAP DC60 and its clones are cheap little USB analogue capturing devices which can be used for viewing and recording video under Linux from different sources like VHS tape recorders, satellitereceivers, camcorders ...

Recording

Note: A rework of the pages on this blog is in progress. The former instructions for viewing and recording from analogue video devices under Linux will be splitted in Command Line TV and GUI TV. These pages already exist and will be continuously filled with information. 
Until this rework is completed, this page will stay as it is, although there are many overlaps compared to the new pages.
Andrew


Recording solutions for devices supported by the easycap driver

1. Recording with tvcap-script
2. Recording with mtvcgui
3. Recording with mencoder
4. Recording with ffmpeg avconv (libav)
5. Recording with vlc

________________________________________________

1: tvcap-script
The  tvcap-script supports capturing with mencoder and viewing with mplayer, vlc, tvtime and cheese.
Download and more information on the tvcap page.
The tvcap-script is the successor of my easyview-n-cap script.

If someone is interested in the previous versions of this script, it can be downloaded here: 
older version
The easyview-n-cap script is based on a tv_recording skript i found here
http://ubuntuforums.org/showthread.php?p=2009744#post2009744
I modified this skript so that i can view or record with the EasycapDC60 device only with a few mouseclicks.
It provides a nice GUI based on zenity. Encoding is done by mencoder (using the DivX5 line below) 
Usage: After downloading save the script somewhere you have r/w access, make the script executeable:
chmod a+x /path/to/easyview-n-cap-0.9.sh

Note: Open the script in any editor, read through the given information and edit the options in the
#Basic options

section of the script if needed.
It is recommended, to invoke the script from the commandline, when you first try it, to see, if error messages occur.
If everything works, simply run the skript by clicking on it.
The easyview-n-cap-0.9.sh script now includes the check routines of the test scripts coming with the driver source.
If something does not work properly, a message box appears with some information.
If everything is set up ok a radio list appears where you can choose the prefered viewing application or mencoder for capturing.
2: mtvcgui http://code.google.com/p/mtvcgui/
Description from the project page:
mtvcgui
is a very simple graphical user interface for TV capturing using the mplayer encoder (mencoder).
It allows the user to specify various parameters for the mencoder command line utility using separate widgets, but non covered parameters can still be supplied as extra parameters.
See the Mtvcgui page on this blog below for the usage with the easycap device

3: MEncoder
Mencoder is, in my estimation, the best program to record from any v4l2 source.
This line creates divx5 avi files from PAL source, which can be played back on almost every hardware player:
mencoder tv:// -tv driver=v4l2:width=720:height=576:norm=PAL:outfmt=uyvy:device=/dev/video0:input=0:fps=25:alsa:amode=1:forcechan=2:audiorate=48000:adevice=plughw.1,0:forceaudio:immediatemode=0 -msglevel all=9 -ffourcc DX50 -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:turbo:vbitrate=1200:keyint=100 -vf pp=lb,scale=640:480 -oac mp3lame -o test.avi 
This line creates DVD compatible mpeg files from PAL source:
mencoder tv:// -tv driver=v4l2:width=720:height=576:norm=PAL:outfmt=uyvy:device=/dev/video0:input=1:fps=25:alsa:adevice=plughw.1,0:audiorate=48000:amode=1:forceaudio:immediatemode=0 -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=8000:vbitrate=5000:keyint=15:acodec=ac3:abitrate=192:aspect=4/3 -o test.mpg
Chance the norm=XXX option if you have another TV source material. Mencoders console output shows all supported norms.
You can control output quality by rising/lowering the vbitrate=xxxx option.
If you have 16:9 source change scale=720:406
If you want to crop the image, ad crop=w:x:y:z after pp=lb, option:

Example "-vf pp=lb,crop=720:406:0:68,scale=704:396" deinterlaces the movie and crops the black borders from a 16:9 movie on PAL 4:3 DVD source (or analog satellite receiver source) and scales down the output
Read more about mplayer on the Command Line TV page on this blog

4: FFmpeg - AVconv
Some notes on FFmpeg: 
FFmpeg has now two branches (ffmpeg.org and libav.org - the second branch is part of Ubuntu) and the syntax is changing.
After all, the 0.7 version of FFmpeg (libav Ubuntu 11.10) doesn't support capturing from v4l2 at all because of a bug. 


The recent libav version 0.8.3 in Ubuntu 12.04 supports v4l2 capturing again. The ffmpeg and ffplay command in libav are deprecated and soon will be entirely replaced by 'avconv' and 'avplay'.

Play back a v4l2 source with avplay
avplay -f video4linux2 /dev/video0

This line creates deinterlaced divx5 avi files
avconv -f video4linux2 -channel 1 -i /dev/video0 -f alsa -i hw:1 -vcodec mpeg4 -vtag DX50 -b 1200k -r 25 -acodec libmp3lame -ar 44100 -ac 2 -ab 128k -vf yadif,scale=720:406  -y test.avi 


Outdated FFmpeg commands, working with ffmpeg 0.6.x
This line creates divx5 avi files
ffmpeg -f video4linux2 -aspect 1.3333 -s 720x576 -r 25 -vc 1 -pix_fmt yuv420p -i /dev/video0 -f alsa -ar 44100 -ac 2 -acodec pcm_s16le -i hw:1 -vcodec mpeg4 -vtag DX50 -b 1200k -r 25 -acodec libmp3lame -ar 44100 -ac 2 -ab 128k -y test.avi
 This line creates DVD mpeg files
ffmpeg -v 9 -vsync 1 -map 0.0:1.0 -map 1.0 -tvstd PAL_BGHIN -f video4linux2 -pix_fmt uyvy422 -r 25 -s 720x576 -aspect 4:3 -i /dev/easycap0 -f oss -ac 2 -ab 192K -ar 48000 -i /dev/easysnd1 -b 4000k -bt 300k -acodec mp2 -ac 2 -ab 192k -a 48000 -vcodec mpeg2video -pix_fmt uyvy422 -me_method epzs -threads 4 -f vob test.mpg
5: VLC
You can view or make recordings with vlc: 

On the commandline:
Here are two cvlc commands which transcode the captured video either to a mp4-avi or to a dvd-mp2 file. If you do not need audio cut ot the highlighted parts. It is recommended to leave the full width an height ( 720 x 576) in this command, either some parts of th picture are cut out.

Some more information about vlc's commandline interface can be found here: http://www.videolan.org/doc/vlc-user-guide/en/ch04.html#id339397

or if you type
vlc -H 
on the commandline.

Mp4 - avi
/usr/bin/cvlc v4l2:///dev/video0:input=1:width=720:height=576 --input-slave=alsa://plughw:1,0 --run-time 10 --sout='#transcode{vcodec=mp4v, vb=1024, acodec=mpga, ab=128}:std{access=file, mux=avi, dst=file_name.avi}' vlc://quit;

MPEG - DVD
/usr/bin/cvlc v4l2:///dev/video1:input=1:width=720:height=576 --input-slave=alsa://plughw:1,0 --run-time 10 --sout='#transcode{vcodec=mp2v, vb=5000, acodec=mp2a, ab=128}:std{access=file, mux=mpeg1, dst=file_name.mpg}' vlc://quit;

Using the grafical interface:
Note: The pictures refer to a previous driver version than 0.9.x

In the main menu select "Media" >  "Open Capture device"
into the field "Video device name" type: /dev/video0:input=1:width=720:height=576
into the field "Audio device name" type:  plughw:1,0
(change the numbers according to your system if necessary)

if you have OSS audio:
into the field "Audio device name" type: /dev/easysnd1 (or /dev/dsp)
check the 'Show more options' checkbox and
change the line in the 'Edit Options' dialog from "alsa" to "oss"

Now click on "Play" if you want to view with vlc.

If you want to record a video with vlc,
click the button left from Play and select convert,
now this window appears
Type in the name of your destination file,
select the prefered profile (= filetype) and
click "Start".
Now don't forget to click the Play button.