69

I need to record some video from my webcam, and while Cheese works, it lacks settings, and only outputs the webm format that is full of stutters, etc.

Can't seem to find any alternative...

6 Answers 6

71

Guvcview aims to provide a simple GTK interface for capturing and viewing video from devices supported by the Linux UVC driver, although it should also work with any v4l2 compatible device.

The project is based on luvcview for video rendering, but all controls are build using a GTK2 interface.

Guvcview (since version 0.9.9) has a control only window, (from console: guvcview --control_only, --control_panel in newer versions), this allows image control on other apps, like ekiga, cheese, mplayer, skype...

Audio.

Guvcview audio support is based on the portaudio library, up until version 0.9.3 the blocking API was used for audio capture, since version 0.9.4 the callback method is used instead, this provides better performance, it is also the preferred method for the portaudio API.

All interfaces (ALSA, OSD, JACK, ...) supported by portaudio should be available in guvcview. Just make sure portaudio was compiled with the desired interfaces enabled.

UVC Dynamic controls.

The Linux UVC driver has an implementation for extension controls (these are vendor specific controls and are supported in the UVC spec.), they are called dynamic controls since they must be dynamically loaded into the driver.

Until today only logitech has supplied specs for their UVC webcam extension controls, these are supported by guvcview.

In new driver revisions admin rights are needed in order to add these controls to the driver, so there are basically two solutions:

  1. start guvcview as root (using sudo) at least once per session, since version 1.2.0 you can do this with the option --add_ctrls avoiding the need to fully launch guvcview

  2. install libwebcam this software has a udev script that should add the necessary controls to your logitech camera.

Install Guvcview to Ubuntu 12.04 via ppa

sudo add-apt-repository ppa:pj-assis/ppa
sudo apt-get update
sudo apt-get install guvcview
5
  • 1
    This app is awesome. BTW - most of the controls worked well without having to do anything.
    – Dave
    Sep 11, 2012 at 3:25
  • 1
    Cheese simply didn't work for me, Guvcview worked perfectly. Only thing was finding the right audo input source took a minute of playing, but still didn't need to read the manual or do some cli magic to get it working.
    – jdarling
    Feb 18, 2015 at 18:22
  • 2
    For all the great guvcview looks, it's currently ruined (at least in 16.04) by bugs.launchpad.net/ubuntu/+source/guvcview/+bug/1558060 (frozen video). Instead, I'm using the mencoder line from commandlinefu.com/commands/view/3498/… (adjusting width & height) and it works flawlessly.
    – miguev
    Jul 17, 2017 at 18:20
  • @miguev This version seems to fix the issue. Sep 19, 2018 at 12:36
  • "Guvcview error could not start a video stream in the device" GUVCVIEW (1): Guvcview error invalid resolution index GUVCVIEW: invalid resolution index Segmentation fault (core dumped) Feb 19, 2019 at 3:48
17

If you need a new app, guvcview Install guvcview is good.

https://launchpad.net/guvcview

1
  • +1, just tried out this application due to a problem with audio recording in cheese. Worked a treat!
    – Ash
    Apr 3, 2013 at 11:11
12

Parts of this question comes from the answer in this question: Record from VHS tapes.

We need to make sure that the software is gathering the proper data from the right device. Let's drop a query in the terminal which will let us see how many devices are connected to your computer, which can be used to gather images, use this command in a terminal:

ls -l /dev/video*

Results should be like this:

geppettvs@DYLAN:~$ ls -l /dev/video*
crw-rw----+ 1 root video 81, 0 2012-04-17 19:53 /dev/video0
crw-rw----+ 1 root video 81, 1 2012-04-17 19:53 /dev/video1
crw-rw----+ 1 root video 81, 2 2012-04-18 17:54 /dev/video2
geppettvs@DYLAN:~$ 

In my case, I have 3 video devices, of which one of them is the USB TV Tuner that I use for watching/recording live TV Shows/VTR/VCR/RF-DVD/Video converter and other RF Signals.

The other devices are USB Webcam attached to USB slots on the computer.

If your webcam is featuring a microphone, both audio and video can be recorded using the tvcap-script by Andreas Schalk, which code I place here for your convenience:

#!/bin/bash
#
#  tvcap-script by Andreas Schalk, easycap.blogspot.com (Dec. 2011)
#  This script is based an a template TV-script from Jose Catre-Vandis (Jan 2006).
#  The ascii artwork is based on a template i found here: http://www.retrojunkie.com/asciiart/electron/tv.txt
#  Contact: [email protected]
#-----------------------------------------------------------------------------
#
#  FUNCTION: This script provides Zenity menues for viewing an capturing video with a tv-card on Linux.
#
#  Supported programs: MPlayer, MEncoder, VLC, Tvtime, Cheese und Sox
# 
#-----------------------------------------------------------------------------
#  
#  Basic options:
#
#  Change the following parameters for viewing/ capturing according to your needs
#
#-----------------------------------------------------------------------------
VERBOSE=1   # if '0', this script does not show messages window and does not ask for norm and input number anymore
NORM="PAL"  # preselect tv norm 'PAL' or 'NTSC'
INPUT_NR=0      # preselect input number of your easycap where video source is plugged in
input_width=720     # preselect width an height of video source (mplayer, vlc, mencoder)
input_height=576    # other possible combinations: 640/480; 320/240 
ASPECT=169          # '169' (16:9) or '43' (4:3); this value affects video playback with mplayer or vlc only!
FREQ="48000"        # on soundproblems reduce audio frequency (44100 oder 32000 oder 8000)
TV_INPUT="no"       # if 'yes' the analogue antenna input of the tv-card will be used (mplayer only)
CHAN="chanlist=europe-west:channel=60"      # channel setting (nur mplayer/ mencoder) the analogue antenna input of the tv-card is used
NORM="PAL"          # preselect TV-norm 'PAL' oder 'NTSC'
INPUT_NR=1          # preselct the Input on the TV-card, where the videosource is plugged in ('0' normally is the antenna, '1' the first CVBS ...
#-----------------------------------------------------------------------------

MESSAGE=()
R_MESSAGE=()
EXITCODE=0

#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#   test videodevices
##-----------------------------------------------------------------------------

declare -a VIDEO_DEV

VIDEO_DEV=( TRUE    none
            FALSE   none
            FALSE   none
            FALSE   none
            ) 
i1=0;
i2=0;
while `test -e "/dev/video${i1}"`; do
  VIDEO_DEV[$i2+1]="/dev/video${i1}"; 
  i1=$[$i1+1];
  i2=$[$i2+2];
done
if [ "xnone" = "x${VIDEO_DEV[1]}" ]; then 
  zenity  --error --timeout=5 --text "Cannot find /dev/video0!\n Script ends in 5 seconds" --title "No videodevice!";
  exit 1;
fi

if [ "x${VIDEO_DEV[$i2+1]}" = "xnone" ];  then
    VIDEO_DEV[$i2]="" && VIDEO_DEV[$i2+1]="" && VIDEO_DEV[$i2+2]="" && VIDEO_DEV[$i2+3]="" && VIDEO_DEV[$i2+4]="" && VIDEO_DEV[$i2+5]="";
fi

DEV_VIDEO=$(zenity --list --text "Select videodevice" --radiolist --column "Choice" --column "Device" ${VIDEO_DEV[@]}) || exit 0 

if [ ${VERBOSE} = 1 ]; then
#-----------------------------------------------------------------------------
#  select TV norm
#-----------------------------------------------------------------------------
title="Select tv norm"
NORM=`zenity --title="$title" --list --radiolist --column="Choice" \
    --column="Norm" --column="Description" \
    TRUE "PAL" "PAL Norm" \
    FALSE "NTSC" "NTSC Norm" \
    ` || exit 0 
fi
#-----------------------------------------------------------------------------
#  select Input number
#-----------------------------------------------------------------------------
title="Select Input NR"
INPUT_NR=`zenity --title="$title" --list --radiolist --column="Choice" \
    --column="Input NR" --column="Description" \
    TRUE "0" "Input 1 (TV)" \
    FALSE "1" "Input 2" \
    FALSE "2" "Input 3" \
    FALSE "3" "Input 4" \
    FALSE "4" "Input 5" \
    FALSE "5" "Input 6"
    ` || exit 0 
#-----------------------------------------------------------------------------


#-----------------------------------------------------------------------------
#  Check if snd_usb_audio module is loaded
#-----------------------------------------------------------------------------
SND_USB=`lsmod | grep snd_usb_audio | wc -l`
if  [ "${SND_USB}" -ge "1" ]; then
#  MESSAGE=("${MESSAGE[@]}" "\nNOTE: snd_usb_audio module was loaded and may conflict with your USB capture device")
   zenity  --info --text "NOTE: The snd_usb_audio module was loaded\nand may conflict with your USB capture device.\n \nIf sound problems appear,\nplug out your USB capturedevice and run\n rmmod snd_usb_audio \nas root in the terminal!" --title "Snd_usb_audio module loaded!"
fi

#-----------------------------------------------------------------------------
# test and select soundcard
#-----------------------------------------------------------------------------

if `test ! -e /dev/dsp` && [ -z "`ls -1 /proc/asound`" ]; then
    if_audio="no";
    echo "No soundcard detected";
    MESSAGE=("${MESSAGE[@]}" "Note: No soundcard can be found!\nSound is not supported.\n");
else
if_audio="yes"
declare -a SOUND_DEV

SOUND_DEV=( FALSE   /dev/dsp    OSS
            FALSE   card1   ALSA    
            TRUE    card2   ALSA
            FALSE   card3   ALSA
            ) 

test ! -e /dev/dsp && echo "No dsp" && SOUND_DEV[0]="" && SOUND_DEV[1]="" && SOUND_DEV[2]=""

ALSA_CARD=$(cat /proc/asound/cards | cut -d":" -f1 -s)
declare -a ALSA_CARDS
ALSA_CARDS=(${ALSA_CARD})

i5=1
for P in ${ALSA_CARDS[@]}; do
    ALSA_NAME=$(echo ${ALSA_CARDS[$i5]} | tr -d [=[=] );
    SOUND_DEV[$i5+3]=$ALSA_NAME
    if [ "x${ALSA_NAME}" = "x" ];  then
    SOUND_DEV[$i5+2]="" && SOUND_DEV[$i5+3]="" && SOUND_DEV[$i5+4]=""
    fi
    i5=$[$i5+3];
done
fi

DEV_AUDIO=$(zenity --list --text "Select soundcard" --radiolist --column "Choice" --column "Device" --column "Type" ${SOUND_DEV[@]}) || exit 0 

if [ $DEV_AUDIO = "/dev/dsp" ]; then 
    AUDIO_TYPE="oss"
    else
    AUDIO_TYPE="alsa"
fi
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#   test, if devicenodes are read- and writable for unprivileged users
#-----------------------------------------------------------------------------

if [ -r ${DEV_VIDEO} ] && [ -w ${DEV_VIDEO} ]; then
MESSAGE=("${MESSAGE[@]}" "\nSUCCESS! ${DEV_VIDEO} is read- and writable!\n")
elif [ -e ${DEV_VIDEO} ]; then
zenity --info --text "Cannot access ${DEV_VIDEO}!\nRun 'sudo chmod a+rw ${DEV_VIDEO}'\nin the terminal!" --title "Message"
EXITCODE=1
fi

    if [ -r ${DEV_AUDIO} ] && [ -w ${DEV_AUDIO} ]; then
    MESSAGE=("${MESSAGE[@]}" "\nSUCCESS! ${DEV_AUDIO} is read- and writable!")
    elif [ -e ${DEV_AUDIO} ]; then
    zenity --info --text "\nCannot access ${DEV_AUDIO}!\nRun 'sudo chmod a+rw ${DEV_AUDIO}'\nin the terminal!" --title "Message"
    MESSAGE=("${MESSAGE[@]}" "\n\nCannot access ${DEV_AUDIO}!\nRun 'sudo chmod a+rw ${DEV_AUDIO}'\nin the terminal!!")
    if_audio="no"
    fi
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#  find executable programs
#-----------------------------------------------------------------------------
PROG_LIST=( TRUE    vlc     #
            FALSE   mplayer     #
            FALSE   cheese      #
            FALSE   tvtime      #
            FALSE   mencoder    #
            FALSE   sox         #
            ) 

PROGS=(vlc mplayer cheese tvtime mencoder sox)
i4=0
for P in ${PROGS[@]}; do
            PROG=`which $P`
            if [ "x" = "x${PROG}" ] || [ ! -x ${PROG} ]; then
            echo "Cannot find or execute $P. Is t installed?"
            MESSAGE=("${MESSAGE[@]}" "\nCannot find or execute $P. Is it installed?")
            PROG_LIST[$i4]=""
            PROG_LIST[$i4+1]=""
                if [ "${PROG_LIST[11]}" = "" ]; then
                echo "Sox is needed for sound with tvtime!"
                MESSAGE=("${MESSAGE[@]}" "\nSox is needed for sound with tvtime!")
                fi          
            fi
            i4=$i4+2
done
PROG_LIST[10]=""        # Sox does not show up on list
PROG_LIST[11]=""        #
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#  messages are displayed and script ends
#-----------------------------------------------------------------------------
if [ ${EXITCODE} = 1 ]; then
    MESSAGE=("${MESSAGE[@]}" "\nScript ends")
fi
echo ${MESSAGE[*]}
#########################
if [ ${VERBOSE} = 1 ]; then
zenity --height="50" --info --text "${MESSAGE[*]}" --title "Messages"
fi

if [ ${EXITCODE} = 1 ]; then
    exit 1
fi
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#  create logfile
#-----------------------------------------------------------------------------
LOGFILE="./test`echo "${DEV_VIDEO}" | sed -e "s,/dev/,," - `.log"

# echo "Log file is:  ${LOGFILE}"
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#  zenity list - program choice
#-----------------------------------------------------------------------------

view_cap=$(zenity --list --width=250 --height=400 --text "  ___________\n |  .----------.  o|\n | |   Easy  | o|\n | |   CAP_  | o|\n |_\`-----------´ _|\n   ´\`          ´\`\\nTv-norm: $NORM  Input-Nr:$INPUT_NR\nVideodevice: $DEV_VIDEO $input_width x $input_height \nAudiodevice: $AUDIO_TYPE $DEV_AUDIO $FREQ Hz\nIs audio on? $if_audio\nLogfile: $LOGFILE " --radiolist --column "Choice" --column "program" ${PROG_LIST[@]}) || exit 0

#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#  mplayer command
#-----------------------------------------------------------------------------
if [ "alsa" = "${AUDIO_TYPE}" ]; then
M_AUDIO="buffersize=16:alsa:amode=1:forcechan=2:audiorate=${FREQ}:adevice=plughw.${DEV_AUDIO}"
elif [ "oss" = "${AUDIO_TYPE}" ]; then
M_AUDIO="adevice=${DEV_AUDIO}"
fi

if [ "$NORM" = "PAL" ]; then
    fps_count=25
else 
    fps_count=30
fi

if [ "$ASPECT" = 169 ]; then
    M_ASPECT="-aspect 1.78"
#   elif [ "$ASPECT" = 43 ]; then
#   M_ASPECT="-aspect 1"
    else
    M_ASPECT=""
    fi

if [ "yes" = "${TV_INPUT}" ]; then
M_VIDEO="${CHAN}"
elif [ "no" = "${TV_INPUT}" ]; then
M_VIDEO="norm=${NORM}:width=${input_width}:height=${input_height}:outfmt=uyvy:device=${DEV_VIDEO}:input=${INPUT_NR}:fps=${fps_count}"
fi

#echo $M_VIDEO
#echo $M_AUDIO
#echo $view_cap

if [ "mplayer" = "${view_cap}" ]; then


if [ "$if_audio" = "yes" ]; then    
1>${LOGFILE} 2>&1 \
mplayer tv:// -tv driver=v4l2:${M_VIDEO}:${M_AUDIO}:forceaudio:immediatemode=0 -hardframedrop ${M_ASPECT} -ao sdl, ${AUDIO_TYPE} -msglevel all=9

elif [ "$if_audio" = "no" ]; then
1>${LOGFILE} 2>&1 \
mplayer tv:// -tv driver=v4l2:${M_VIDEO} -hardframedrop ${M_ASPECT} -msglevel all=9 -nosound
fi
fi
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#  vlc command
#-----------------------------------------------------------------------------
if [ "vlc" = "${view_cap}" ]; then

    if [ "alsa" = "${AUDIO_TYPE}" ]; then
    V_AUDIO="//plughw:${DEV_AUDIO}"
    elif [ "oss" = "${AUDIO_TYPE}" ]; then
    V_AUDIO="//${DEV_AUDIO}"
    fi

    if [ "$NORM" = "PAL" ]; then
    V_NORM="pal"
    elif [ "$NORM" = "NTSC" ]; then
    V_NORM="ntsc"
    fi

    if [ "$ASPECT" = 169 ]; then
    V_ASPECT="--aspect-ratio=16:9"
    elif [ "$ASPECT" = 43 ]; then
    V_ASPECT="--aspect-ratio=4:3"
    else
    V_ASPECT=""
    fi

1>${LOGFILE} 2>&1 \
vlc -vvv v4l2://${DEV_VIDEO}:input=${INPUT_NR}:width=$input_width:height=$input_height:norm=${V_NORM} ${V_ASPECT} :input-slave=${AUDIO_TYPE}:${V_AUDIO} --demux rawvideo 
fi
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#  tvtime command
#-----------------------------------------------------------------------------
if [ "tvtime" = "${view_cap}" ]; then
    if [ "alsa" = "${AUDIO_TYPE}" ]; then
    T_AUDIO="-t alsa plughw:${DEV_AUDIO} -s2 -c 2 -r ${FREQ} -s2 -t alsa default"
    elif [ "oss" = "${AUDIO_TYPE}" ]; then
    T_AUDIO="-t raw -s2 ${DEV_AUDIO} -c 2 -r ${FREQ} -s2 -t ossdsp /dev/dsp"
    fi
echo $T_AUDIO
1>${LOGFILE} 2>&1 \
>./tvtime.err
(tvtime -d ${DEV_VIDEO} -i 0 -n "${NORM}" 1>/dev/null 2>>./tvtime.err) &
rc=1
while [ 0 -ne ${rc} ];
do
  tvtime-command run_command "(sox -c 2 -r ${FREQ} ${T_AUDIO} 1>/dev/null 2>>./tvtime.err)" 1>/dev/null 2>>./tvtime.err
  rc=$?
  if [ 0 -eq ${rc} ]; then break; fi
  sleep 0.5
done
fi
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#  cheese command
#-----------------------------------------------------------------------------
if [ "cheese" = "${view_cap}" ]; then
1>${LOGFILE} 2>&1 \
cheese
fi
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#  mencoder command - recording section
#-----------------------------------------------------------------------------

if [ "mencoder" = "${view_cap}" ]; then

#Auswahl des Seitenverhältnisses der Aufnahme?
title="Chose aspect of your target file!"
aspect_type=`zenity  --width="400" --height="220" --title="$title" --list --radiolist --column="Click Here" \
    --column="choice" --column="source >> target" \
    TRUE "1" "4:3 > 4:3"\
    FALSE "2" "4:3 > scale=16:9" \
    FALSE "3" "4:3 > crop borders=16:9" \
    ` || exit 0 

if [ "$aspect_type" = "1" ]; then
    crop_scale="scale=640:480"
elif [ "$aspect_type" = "2" ]; then
    crop_scale="scale=720:406"
elif [ "$aspect_type" = "3" ]; then
    crop_scale="crop=720:406:0:72"
fi  

#################################################################################
#Quality?
title="What quality do you want to record at ?"
qual_type=`zenity  --width="380" --height="380" --title="$title" --list --radiolist --column="Click Here" \
    --column="Record Time" --column="Description" \
    FALSE "500" "Passable Quality"\
    FALSE "900" "OK Quality"\
    FALSE "1100" "VHS Quality"\
    TRUE "1300" "SVHS Quality"\
    FALSE "1500" "VCD Quality"\
    FALSE "1800" "SVCD Quality" \
    FALSE "2000" "Very Good Quality"\
    FALSE "2500" "High Quality" \
    FALSE "3000" "Excellent Quality"\
    ` || exit 0

##################################################################################
#How Long?
title="How long do you want to record for ?"
time_type=`zenity  --width="380" --height="500" --title="$title" --list --radiolist --column="Click Here" \
    --column="Record Time" --column="Description" \
    FALSE "00:00:00" "unlimited"\
    TRUE "00:00:30" "30 seconds for testing"\
    FALSE "00:10:00" "0.2 hours"\
    FALSE "00:30:00" "0.5 hours"\
    FALSE "00:45:00" "0.75 hours"\
    FALSE "01:00:00" "1 hour"\
    FALSE "01:15:00" "1.25 hours"\
    FALSE "01:30:00" "1.5 hours" \
    FALSE "01:45:00" "1.75 hours"\
    FALSE "02:00:00" "2 hours" \
    FALSE "02:15:00" "2.25 hours"\
    FALSE "02:30:00" "2.5 hours" \
    FALSE "02:45:00" "2.75 hours"\
    FALSE "03:00:00" "3 hours" \
    FALSE "03:15:00" "3.25 hours" \
    FALSE "03:30:00" "3.5 hours" \
    ` || exit 0

#M_TIME="-endpos $time_type"

#################################################################################
#user must enter a filename
filedate=$(date +%F_%H:%M-%S)
title="Please enter a filename for your recording, no spaces"
file_name=`zenity  --width="480" --height="150" --title="$title" --file-selection --save --confirm-overwrite --filename="tvcap_$filedate"` || exit 0

###########################################################################################
# summary
R_MESSAGE=("${R_MESSAGE[@]}" "\nRecording options:")
R_MESSAGE=("${R_MESSAGE[@]}" "\nRecording audio: $if_audio")
R_MESSAGE=("${R_MESSAGE[@]}" "\nRecording from Input $INPUT_NR - Norm: $NORM $fps_count fps")
R_MESSAGE=("${R_MESSAGE[@]}" "\nCrop and scale options: $crop_scale")
R_MESSAGE=("${R_MESSAGE[@]}" "\nEncoding quality: $qual_type kb/s")
R_MESSAGE=("${R_MESSAGE[@]}" "\nRecording time:$time_type hours")
R_MESSAGE=("${R_MESSAGE[@]}" "\nFile name: $file_name.avi ")

echo ${R_MESSAGE[*]}

if [ ${VERBOSE} = 1 ]; then
zenity --info --text "${R_MESSAGE[*]}" --title "Recording options"
fi
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#  mencoder line
#-----------------------------------------------------------------------------
if [ "$if_audio" = "yes" ]; then

zenity --info --title="Start recording with audio" --text="Press OK to start."

mencoder tv:// -tv driver=v4l2:norm=$NORM:width=$input_width:height=$input_height:outfmt=uyvy:device=${DEV_VIDEO}:input=${INPUT_NR}:fps=$fps_count:${M_AUDIO}:forceaudio:immediatemode=0 -msglevel all=9 -ovc lavc -ffourcc DX50 -lavcopts vcodec=mpeg4:mbd=2:turbo:vbitrate=$qual_type:keyint=15 -vf pp=lb,$crop_scale -oac mp3lame -endpos $time_type -o $file_name.avi | tee ${LOGFILE} | zenity --progress --pulsate --auto-close --auto-kill --text="Processing Video - length: $time_type H:M:S" 

zenity --info --title="Job complete" --text="The recording is now complete."


elif [ "$if_audio" = "no" ]; then

zenity --info --title="Start recording without audio" --text="Press ok to start recording"
1>${LOGFILE} 2>&1 \
mencoder tv:// -tv driver=v4l2:norm=$NORM:width=$input_width:height=$input_height:outfmt=uyvy:device=${DEV_VIDEO}:input=${INPUT_NR}:fps=$fps_count -msglevel all=9 -nosound -ovc lavc -ffourcc DX50 -lavcopts vcodec=mpeg4:mbd=2:turbo:vbitrate=$qual_type:keyint=15 -vf pp=lb,$crop_scale -endpos $time_type -o $file_name.avi | tee ${LOGFILE} | zenity --progress --pulsate --auto-close --auto-kill --text="Processing Video - length: $time_type H:M:S" 

zenity --info --title="Job complete" --text="The recording is now complete."

fi

fi
exit 1

Simply copy/paste all this code in a file called tvcap-script.sh, give the execution permissions and run it in a terminal. The process is quite easy and I am going to explain as follows:

1.- After pressing Enter, you will be asked for the capture source, and dependind on the device's location (tested before), you can have -as in my case- several video sources, I am using the /dev/video2 for this example, which refers to my USB TV Tuner. Note that this screenshot didn't get the window decorator but the options and the "OK" button can be seen right there.

enter image description here

2.- Now we need to define the norm, in Mexico we use NTSC, and unless you wish to capture your video using a different norm with square aspect ratio you should not use PAL, which can indeed harm a bit your video quality. It also depends on where you live and the norm of your country.

enter image description here

3.- My TV Tuner is having several inputs, yours can have a different amount of inputs, check it out and run as many tests as you need to determine which one is the best for your capture. I am going to use the one that refers to TV. (Input 1 (TV))

enter image description here

4.- Next, you may (or not) be warned and offered for a solution if something goes wrong during the sound capture (both audio and video are going to be captured at once but if your snd_usb_audio module has already been loaded it may crash the audio capture and thus the video capture itself)

enter image description here

5.- My TV Tuner features support for several audio inputs, which includes the integration with the embedded sound device in my motherboard (via connecting a cable to the aux-line and controlled by sound mixer), you check which one is the best for you and remember that the defaults are usually marked as the "best for you".

enter image description here

6.- If everything is going fine, you will see a small window with a message that reads something like this:

"SUCCESS! /dev/video2 is read- and writable!"

click "OK" to continue.

enter image description here

7.- After that, you can choose from the list of recording options available on your system. I have installed what you can see in the next screenshot. Anyone is valid and the quality doesn't reflect major changes but I personally prefer mencoder. If you don't have any of these installed you should install it in order to run your tests.

enter image description here

8.- After you have chosen your encoding software preference (in the previous step) you will be asked for the aspect ratio. If you don't have experience on this just leave it as is. It normally defaults to which better fits your TV Tuner signal.

enter image description here

9.- Based on your choice related to the aspect ratio, you will have several options for the video quality, also based on bitrate, the description in the next window is very specific. Remember that: the higher bitrate (best quality) the video file size can become a huge amount.

enter image description here

10.- After that, we need just to choose how long will our video capture be. There are several presets, I have chosen "30 seconds for testing" in this example but you can choose any or even choose "unlimited" in order to you decide when to stop the recording.

enter image description here

11.- Next, you will be asked for a file name, giving one by default, which you can change in this screen.

enter image description here

12.- You will be prompted to check your "Recording options" in the next screen, just click "OK".

enter image description here

13.- Just one more click to start.

enter image description here

14.- When recording, the terminal may show some activity, and a small window like this:

enter image description here

15.- At the end of the process, you will receive a confirmation window.

enter image description here

And... that's it...

You can cancel the recording or the process itself by pressing ESC at any moment, there will be no changes at all.

At the end of the recording, you will have the video in the place that you choose in the step 11, in companion with a log file with a name like: "testvideo0.log" or something like that.

This is the easiest way to encode from RF Signal TV Tuners, gathering both audio and video in the same file.

I have another process which is achieved using a python process which features a GUI in which you can handle several useful things, like changing the channel, run pre-recording tests and even record but sometimes it drops me failures. If you wish it please let me know how can I reach you. I don't want to write parchments or a bible... LOL!

If this procedure doesn't work for your case please let me know including your results in order to provide some support before deleting this answer. Thank you and...

Good luck!

2
  • What USB TV Tuner card do you recommend, and does the above solution work for more than 2-3 video feeds on a single linux machine? I want to try to record 4-8 videos on a single machine. Is that feasible in your opinion?
    – CP3O
    Sep 13, 2017 at 17:39
  • Any analog TV Tuner card, both PCI and/or USB should work if and just if the device is properly detected and installed. For what is about the multi-feed recording, this solution should work perfect if you run several instances and choosing the right media feed. Unfortunately, in some cases the audio stream is managed by your favorite audio mixer (let's say alsa or pulseaudio, jack, etc.) this may will need to fine tune the code in order to say which audio stream we're going to use for the capture on certain video device. Additionally, the more streams you capture, more resources it does need. Sep 15, 2017 at 16:25
4

You must try "QtCAM" - a free, Open Source Linux Webcamera Software with more than 10 image control settings.

QtCAM image capture settings

1
  • This now works on 16.04
    – Tim
    May 30, 2017 at 2:33
3

Simplest command with ffmpeg:

ffmpeg -i /dev/video0 output.mp4
1
  • Hey, welcome to Ask Ubuntu! Could you please take a moment to edit your answer to explain how the comment works and how it will best solve OP's problem? Thanks :)
    – grooveplex
    Feb 27, 2019 at 14:37
2

I would advise vokoscreen for Ubuntu 18.04. You can install it with 'sudo apt install vokoscreen'. See also https://github.com/vkohaupt/vokoscreen .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .