Simple Way to Record TV with Ubuntu

Taken from this post.

This is how I record TV without installing mythtv.

1. Get mencoder

Code:


sudo apt-get install mencoder

2. Create the script (record.sh):
Code:


#!/bin/sh

# Duration of recording (in seconds)
DURATION=$1

CHANNEL=$2

# Filename (excluding extension)
FILE=$3\.avi

# Record from tv
mencoder tv:// -tv driver=v4l2:device=/dev/video0:channel=$CHANNEL:forceaudio:norm=NTSC-M:chanlist=us-cable:alsa:adevice=hw.0,0:immediatemode=0 \
-ovc xvid -xvidencopts bitrate=800 \
-oac pcm \
-endpos $DURATION -sws 1 -o $FILE

3. Make the script executable and run it:

Code:

chmod u+x record.sh
./record.sh 3600 3 heroes

Another script from here:


#!/bin/bash

if [ $# -ne 3 ]
then
echo "Usage: $0 channel seconds filename"
exit
fi

WIDTH=640
HEIGHT=480
MENCODER=/usr/bin/mencoder
AUDIO="-oac mp3lame -lameopts cbr:br=128:mode=3"
VIDEO="-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=6400"
DSP="adevice=/dev/dsp"
TV=" -tv driver=v4l2:width=$WIDTH:height=$HEIGHT:outfmt=yuy2:input=0:device=/dev/v4l/video0:norm=NTSC:chanlist=us-cable:channel=$1:$DSP"
$MENCODER tv:// $TV $VIDEO $AUDIO -endpos $2 -ffourcc divx -o "$3.avi"

Leave a comment