Compress / Decompress files using XZ

Compress

xz -zk myfile.txt

will produce myfile.txt.xz in the same directory

Decompress

xz -dkc myfile.txt.xz > myfile.txt

Check process that prevent unmount USB drive

Get PID of process that prevent from unmounting a USB drive

$ fuser -m /var/run/media/mycomputer/mythumbdrive/
/run/media/mycomputer/mythumbdrive: 1583m

See what that process is

$ ps ax|grep 1583
1583  ?      S   0:02  /usr/bin/python /usr/lib/python2.7/site-packages/rabbitvcs/services/checkerservice.pyc
6859  pts/0  S+  0:00  grep --color=auto 1583

Oh, it’s rabbitvcs. Now kill it

$ kill -9 1583

Now I can remove the USB safely

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