Soundstation: 5 - Watch movies
5a - Resolution
Music is working. Nice! But in the end I have a whole PC sitting there just ripping and playing music - why not making it do more stuff? And what? Why not playing movies? So, the first problem I came across is the resolution.
I have a 16:9 TV, which is a ~1.7 ratio. The native resolution of my touchscreen is 800x600, which is a ~1.33 ratio. This means that if I start up the desktop with a 800x600 resolution, the image on screen will be distorted.
I tried to use the MPlayer settings to change the aspect ratio of the movies, but that comes at a cost of ~90% CPU usage on my 800Mhz machine while playing movies, as this is not hardware accellerated. I therefore had to change the resolution, but to which one? Well, one of the standard VGA resolutions that has an aspect ratio near to 1.7 is 1280x768, which gives a ratio of ~1.66.
Ok, I now know I somehow have to change res when I want to play videos. How?
What I did was:
- When you login into your Linux, the system automatically searches a file called .profile in your home directory (at least if you're using the bash shell). I therefore created a .profile containing the following code:
echo "This is your .profile script" tty TERMINAL=$(tty) if [ "$TERMINAL" = "/dev/tty1" ] then echo "This is the main terminal, so I am starting up X" /home/shared/scripts/startx_custom else echo "This is a secondary terminal, so I won't start up X" fi
- Let's have a look at the startx_custom script:
STESCRIPTS="/home/shared/scripts" export STESCRIPTS for ((a=1;a<2;)) do sleep 2 #Get the information about what has to be done #0=Shutdown #1=Start music mode - use xorg.conf.master.pc #2=Start video mode - use xorg.conf.master.tv ACTION=$(cat $STESCRIPTS/startx_nextaction) #For cases 1 and 2, copy the xorg.conf and enlightenment files and fire up enlightenment. #For case 0, exit the loop and shut down the machine. #When the machine is booted, the value 1 will automatically be assigned by an init script. case "$ACTION" in 0) #Shutdown #echo exiting script a=3 ;; 1) cp /home/masterfiles/enlightenment.master.pc /etc/X11/Sessions/enlightenment $STESCRIPTS/touchscreen/tchscreen_replaceevent echo Y > /sys/module/usbtouchscreen/parameters/swap_xy echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor startx #echo starting into pc mode #sleep 10 ;; 2) cp /home/masterfiles/enlightenment.master.tv /etc/X11/Sessions/enlightenment cp /home/masterfiles/xorg.conf.master.tv /etc/X11/xorg.conf nxtvepg -daemonstop killall nxtvepg echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor startx #echo starting into tv mode #sleep 10 ;; *) echo nothing >> /dev/null ;; esac done shutdown -h now #echo Shutting down the pc
- As with the above script the value in the temporary file is set to 0 when shutting down, I had to set a default value during boot in the file /etc/init.d/startx_prepare:
#Used to make X start with the pc setup (for music) start() { echo 1 > /home/shared/scripts/startx_nextaction } stop() { echo ciao >> /dev/null }
- What drives which mode is chosen? Well, the config file of the remote control ~/.lircrc sets the value...
begin prog = irexec button = Videos config = /home/shared/scripts/x_switch2tv & end begin prog = irexec button = Music config = /home/shared/scripts/x_switch2pc & end
#This command will return an error if Amarok is not running - it's ok. dcop amarok MainApplication-Interface quit #Set the next action of the script startx_custom to go into TV mode. echo 2 > /home/shared/scripts/startx_nextaction #Close the X desktop, so that the script startx_custom can continue its execution. eesh exit
#This command will return an error if Amarok is not running - it's ok. dcop amarok MainApplication-Interface quit #Set the next action of the script startx_custom to go into PC mode. echo 1 > /home/shared/scripts/startx_nextaction #Close the X desktop, so that the script startx_custom can continue its execution. eesh exit
5b - Movie application
Ok, now I press on the Video button of the remote control, the desktop shuts down and restarts with a resolution 1280x768 - I just need a program to act as a movie jukebox!
I knew MythTV, but that is more a TV recording app. I therefore chose freevo, which fits better.
The funny thing I noticed is, that when I was playing a movie using MPlayer through Freevo, I had 10% CPU overhead compared to directly run MPlayer as a standalone. I traced back the source and, apparently, Freevo forces MPlayer to do deinterlacing for any kind of video (I have an LCD TV, so I don't need this). Additionally I forced in the Freevo config file /etc/freeevo//etc/local_conf.py MPlayer to use xv as output driver. Here is the final section of the local_conf.py'' file...
MPLAYER_ARGS_DEF = '-fs -vo xv -aspect 16:9 -cache 20000' #OSD_STOP_WHEN_PLAYING = 1 #MPLAYER_VO_DEV_OPTS = 'xv' MPLAYER_NICE = 0 MPLAYER_AO_DEV = 'alsa:device=spdif' #STECUSTOM: modified in file /usr/lib/python2.4/site-packages/freevo/video/plugins/mplayer.py #and commented 6 lines starting with if self.version >= 1 and item['deinterlace']: #to avoid doing de/interlacing online.
if item.selected_audio != None: additional_args += [ '-aid', str(item.selected_audio) ] # if self.version >= 1 and item['deinterlace']: # additional_args += [ '-vf', config.MPLAYER_VF_INTERLACED ] # elif item['deinterlace']: # additional_args += [ '-vop', config.MPLAYER_VF_INTERLACED ] # elif self.version >= 1: # additional_args += [ '-vf', config.MPLAYER_VF_PROGRESSIVE ] mode = item.mimetype if not config.MPLAYER_ARGS.has_key(mode): mode = 'default'
2bcontinued...
Chapter 1 - Theory & hardware
Chapter 2 - Initial setup
Chapter 3 - Jukebox music setup
Chapter 4 - CPU throttling & Co.
Chapter 5 - Watch movies <= You are here
Back to Soundstation main