Zocoi Vietnamese /ʒoʊ kɔɪ/: (informal) Let's watch/read together

Build your own digital video recorder

How to record streaming from digital TV and compress the videos for your mobile phone.

My task was to create a solution or service that can record a DVB-T channel as video and compress it so that the video can be displayed in a mobile device. All was done in a Linux box and then I can set up a webs server and stream the videos. The solution fulfills my need of recording a piece of morning news and then watching it on the bus or train.

  1. Hardwares
    For this experiment, I used an old P4, 512mb RAM Debian box and a Hauppauge WINTV-NOVA-T PCI DVB-T card
  2. Having the DVB-T card work properly
    Firstly, I tried to scan for the channel list
    scan /usr/share/dvb/dvb-t/fi-Kaupunki > ~/.mplayer/channels.conf
    w_scan >> ~/.mplayer/channels.conf
    Although I read somewhere on the internet that w_scan is recommended but it seems to me that the channels.conf format returned by w_scan can not be used by other media players like Totem, mplayer or Kaffeine so that I switched back to scan and it worked.
    You can test the adapter data traffic with
  3. Stream/File encoding via mencoder
    mencoder belongs to mplayer package so make sure that you have installed mplayer and have channels.conf in your ~/.mplayer/ folder. The syntax is quite easy

    mencoder dvb://${1} -oac copy -ovc copy -of avi -endpos ${2} -o ${FILENAME} -cache 8192 -quiet
    where {1} is the channel name, {2} is the recording duration and {FILENAME} is the path where the video file is saved. For example

    mencoder "dvb://Subtv" -oac lavc -ovc lavc -of avi -endpos 00:00:15 -o public_html/test.mpg -cache 8192

  4. Rescale and encode the streaming for displaying in mobile device
    mencoder "dvb://Subtv" -oac mp3lame -ovc lavc -of avi -endpos 00:01:00 -o public_html/test.mpg -cache 8192 -vf scale=176:144 -ofps 12 -lavcopts acodec=mp2:abitrate=32
    mencoder "dvb://Subtv" -oac lavc -lavcopts abitrate=32 -ovc xvid -of avi -endpos 00:01:00 -o public_html/test.mpg -cache 8192 -vf scale=176:144 -ofps 12 -xvidencopts turbo:vhq=0:bitrate=738556 -srate 22050
    Although I used different codecs to bring out different video qualities, I always want to scale it to 176:144 and reduce the numbers of frame to 12 (24 in normal case).


  • Support 3gp and mp4 format
  • Better compression ratio (currently 1min ~= 1mb)
  • Setting up a streaming server using Apache