Avidemux

avidemux_xn

Avidemux is a video editing software that I’ve been used before to encode the recorded videos from TV. When recorded from TV, the video is in uncompressed MPEG format, resulting in large size. Sometimes a video of an hour length is about 2GB.

The best encoding format I’ve been used before is using AVI container with x264 (single pass) video encoding format, and AC3 audio encoding

To get information about a video, in Windows you can use GSpot (it’s bundled together with Media Player Classic). For Linux or Mac, you can use mplayer or ffmpeg command

$ mplayer -ao dummy -vo dummy -identify video.mp4

// output:
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 53.61.100 (external)
AUDIO: 48000 Hz, 2 ch, s16le, 192.0 kbit/12.50% (ratio: 24000->192000)
ID_AUDIO_BITRATE=192000
ID_AUDIO_RATE=48000
ID_AUDIO_NCH=2
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
$ ffmpeg -i video.mp4

// output:
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 800x450 [SAR 1:1 DAR 16:9], 823 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 192 kb/s

Record from tv card using mencoder

* Assuming tv card audio in cannot be detected & need to use line-in

rekodtv.sh

#!/bin/bash

CHANNEL=29 # R6-TV1,E11-TV2,29-TV3,37-NTV7,44-8TV,48-TV9
DURATION="60:00" # 60 minutes

amixer -c 0 sset 'Line',0 80% mute cap
mencoder tv://
  -tv channel=$CHANNEL:chanlist=europe-east:forceaudio:alsa:amode=1:adevice=hw.0,0:mjpeg
  -vf pp=md
  -of mpeg
  -oac lavc
  -ovc xvid
  -xvidencopts bitrate=800:vhq=2
  -endpos $DURATION
  -o tv.mpg&& sleep 20 && mplayer tv.mpg

Note: I set the Line-in as the capture channel for audio and mute it, so that no real-time audio coming out of the speaker. After 20 secs sleep, the recording playback started, settings to 5 secs is too low & the playback may stop itself.

To determine alsa hardware ID (hw.0,0) – assuming audio card 0 is the one
that connected the tv card audio out through line-in

$ amixer -c 0

Check

Simple mixer control 'Input Source',0
  ...
  Item0: 'Line'

Therefore, device ID is 0 (see ‘Input Source’)

ALSA hardware ID : hw.<cardID>,<deviceID>

To record:

$ chmod +x rekodtv.sh
$ ./rekodtv.sh

To force stop the recording (above script will auto stop record after 60 minutes)

stoprekod.sh

#!/bin/bash

kill -9 `ps ax|grep mencoder|grep -v grep|awk '{print $1}'`

Recorded videos must be reindexed before storing

idx.sh

#!/bin/bash

mencoder -idx tv.mpg -ovc copy -oac copy -o tv_idx.mpg

To play:

$ mplayer tv.mpg