[LINUX] Script to decrease DVD read speed
#1
The DVD player in my XBMC HTPC makes a lot of noise. When I issue the command 'eject -x 4 /dev/cdrom', it falls back to reading a 4 speed and all the noise is gone. For testing purposes, I connect over ssh, make this setting and all works fine. Now after I change DVD's, the setting is discarded and I have to issue the 'eject' command again.

So, what I wanted to do was:
a) reduce the drive speed in general (by default for the entire system), but that doesn't seem possible
b) map a button on my remote to issue the 'eject -x 4 /dev/cdrom' command when in XBMC, so I just have to press the button to reduce the CD speed after inserting a new DVD

Now, I tried the following:
1) map an unused key (i.e. mytv) in 'remote.xml' to do the following:
<mytv>System.Exec('eject -x 4 /dev/cdrom')</mytv>

Now when I do that, XBMC is windowed and a terminal screen is displayed shortly (less than a second). I cannot resume XBMC and have to kill it from the command line. Also, the DVD read speed is not reduced.

I also tried <mytv>System.Exec('sh /home/name/.xbmc/scripts/setcdspeed.sh')</mytv> with 'setcdspeed.sh' being:

#! /bin/sh
eject -x 4 /dev/cdrom

But with the same result...

2) since the 'System.Exec' command didn't seem to work, I tried to use the 'RunScript' command, like this:

<mytv>RunScript(/home/name/.xbmc/scripts/setcdspeed.py)</mytv>

With setcdspeed.py being:

import os
os.popen("eject -x 4 /dev/cdrom")

But this doesn't seem to do anything either.

Can somebody shed some light on this?
I'm sure I'm doing something wrong, but I can't find what...

Thanks!
Reply
#2
This maybe?
http://ivman.sourceforge.net/
Reply
#3
I read about ivman (isn't it replaced by halevt?), but I think I'd rather use a script, because I often copy things from CD/DVD to my HTPC and I don't want that to be at 4 speed (I know I could just use 'eject -x 48 /dev/cdrom') to set it back to high speed.

Does anyone have an example of how to use ivman?
Reply
#4
Hi there, I have been looking at this also its doing my nut in cos im sporting a pc-dvd drive that spins way to fast.

I am tol the "hdparm -E4 /dev/dvd" works a treat and I to was thinking script but at the same time I could do with full speed when ripping and so I came up with the idea of setting one of the buttons up to issue the command while playing a dvd. I cant try it till the weekend but this is the plan.

Let me know what you think.............



I want to drop the speed of the dvd drive after sticking a dvd film in to watch like having a shut up button which is good because if its a data dvd or im ripping a dvd film the last thing I want is to drop the speed!

Since the buttons are used for different things depending on the window your in I will have to choose the right file to edit. I have xbmc setup to auto play when a dvd is inserted and so I could do with setting on of the buttons to issue the command while watching the film.I am under the impressions I can literally drop an executable command into the keymap....If its works ill kiss my own ass.


I need to edit...... VideoFullScreen.xml .......Which I believe is the keymap used while watching a Video?

Change if it exists?
<keyname>action</keyname>

To
<keyname>hdparm -E4 /dev/dvd</keyname>




eg..... if button 9 currently paused (I know it doesnt).

change
<number9>pause</number9>


to
<number9>hdparm -E4 /dev/dvd</number9>


Pressing 9 while watching a dvd should now hopefully drop the drive speed to 4x.


I posted this here but dont get much of a reply from this site.....
http://www.xbox-hq.com/html/modules.php?...333#167333
Reply
#5
Big Grin 
I use halevt on my Linux HTPC. halevt replaces ivman and is IMHO easier to configure. And ivman doesn't work anymore, so that leaves you no choice.

halevt is a daemon/service and should be available for most distributions (I use Gentoo and Ubuntu, and I can get it for both already). The /etc/halevt directory contains configuration files (XML files). A default file is provided.

I wrote the /etc/halevt/dvd-speed.xml file. This simple file basically tells halevt to execute the famous hdparm -E4 command on the appropriate device whenever a video DVD is inserted. Since it has nothing to do with XBMC, it always works, which is nice.

Here is the file:

Code:
<?xml version="1.0" encoding="UTF-8"?>

<!-- Author: Laurent Pireyn -->

<!DOCTYPE halevt:Configuration [

<!ENTITY DVD "hal.block.device &amp; hal.block.is_volume = true &amp; hal.volume.disc.is_videodvd = true">

]>

<halevt:Configuration version="0.1" xmlns:halevt="http://www.environnement.ens.fr/perso/dumas/halevt.html">

<halevt:Device match="&DVD;">
    <halevt:OnInit exec="/sbin/hdparm -E4 $hal.block.device$" />
</halevt:Device>

<halevt:Device match="&DVD;">
    <halevt:Insertion exec="/sbin/hdparm -E4 $hal.block.device$" />
</halevt:Device>

</halevt:Configuration>

This file could probably be improved by modifying the criteria to include audio CD and other media discs, but I don't have time to do it :-)

@alexhore This answers your PM I guess ;-)
Reply
#6
lpireyn Wrote:I use halevt on my Linux HTPC. halevt replaces ivman and is IMHO easier to configure. And ivman doesn't work anymore, so that leaves you no choice.

halevt is a daemon/service and should be available for most distributions (I use Gentoo and Ubuntu, and I can get it for both already). The /etc/halevt directory contains configuration files (XML files). A default file is provided.

I wrote the /etc/halevt/dvd-speed.xml file. This simple file basically tells halevt to execute the famous hdparm -E4 command on the appropriate device whenever a video DVD is inserted. Since it has nothing to do with XBMC, it always works, which is nice.

Here is the file:

Code:
<?xml version="1.0" encoding="UTF-8"?>

<!-- Author: Laurent Pireyn -->

<!DOCTYPE halevt:Configuration [

<!ENTITY DVD "hal.block.device &amp; hal.block.is_volume = true &amp; hal.volume.disc.is_videodvd = true">

]>

<halevt:Configuration version="0.1" xmlns:halevt="http://www.environnement.ens.fr/perso/dumas/halevt.html">

<halevt:Device match="&DVD;">
    <halevt:OnInit exec="/sbin/hdparm -E4 $hal.block.device$" />
</halevt:Device>

<halevt:Device match="&DVD;">
    <halevt:Insertion exec="/sbin/hdparm -E4 $hal.block.device$" />
</halevt:Device>

</halevt:Configuration>

This file could probably be improved by modifying the criteria to include audio CD and other media discs, but I don't have time to do it :-)

@alexhore This answers your PM I guess ;-)

Your the man! im gonna throw it together at the weekend and post some results for everyone.
Reply
#7
Im planning on playing with this tomorrow but im not sure how to get this set up. Im quite fresh when it comes to linux. I know how to ssh to the box and use apt to install halevt but I have no idea as to how im going to create this file.

As you say there is an example file.....

Do I need to edit the example file with the code word for word including all the < and /'s Blush.

I am guessing I need to edit your file with my drive locations, anything elseHuh?
Reply
#8
Scrap that last post im being an idiot, code is clever enough to work out which drive to drop the speed on and when so all I need to do is edit that file word for word. You are the man!
Nod
Reply
#9
I created a script to decrease DVD speed, mapped to a button on my remote
(<obc2>XBMC.RunScript(”/home/xbmc/.xbmc/slowdown.py”)</obc2>).

Slowdown.py is as follows:

import os
os.system(’sh /home/xbmc/.xbmc/slowdowncdrom.sh’)

And slowdowncdrom.sh contains:

#! /bin/sh
eject -x 4 /dev/cdrom

And now all works fine!
Reply
#10
both doenst work for me.

did apt-get install halevt and created the dvd-speed.xml in the /halevt folder


since this doenst work i opened the remote.xml and added the line

Code:
<FullscreenVideo>
    <remote>
      <zero>XBMC.RunScript(”/home/xbmc/.xbmc/slowdown.py”)</zero>

and created the .py and the .sh files in the .xbmc folder.

i tried the command
Code:
eject -x 4 /dev/cdrom
in puTTY ssh first, since this didnt work i tried to track down the name of the drive and /dev/sr0 finally worked. it was silent. i also was able to eject and mount the drive. so it works.

but the remotebutton/script thing doesnt.
Reply
#11
anyone?
Reply
#12
hellooo
Reply
#13
ichAlex Wrote:hellooo

Hi Alex, my xbox got shelved for a few months but dusted it off last night and gonna come back to sorting this.

Last time I tried I found myself unable to even ssh to the xbox but since then I have re-wired my entire house with gigabit ethanet and dropped xbox 360's in every room for media sharing finishing with a fresh network setup resolving any issues I had.

If your running stock xbmc like me then the fix should work for both of us depending on the drive you use as apparently some drives react to speed commands differantly or not at all in some cases.

Once I have a working fix for myself ill post it for you from start to finish in detail that way anyone can have a go at it.

Im hoping to get it to recognise the disk and drop the speed only if watching so that I can still rip dvd's at full speed.

Out of interest does yours play cd's ok as mine does not. It sounds like its skiping playing a few seconds the pausing then playing again and takes ages to rip suggesting the cd speed is way to low.....

Either way I am stating with a fresh install of xbmc and will log everything start to finish for any watching novice....

Watch this space
Reply
#14
hey there, thanks for the reply. but i'm running XBMC Live on a PC.
My Drive is an Sony SATA DVD Drive.

Never tried playing CDs as I "still" have a standalone CD Player
Reply
#15
ichAlex Wrote:hey there, thanks for the reply. but i'm running XBMC Live on a PC.
My Drive is an Sony SATA DVD Drive.

Never tried playing CDs as I "still" have a standalone CD Player

If its on a pc if might be worth posting in the specific sub-forum.
http://forum.xbmc.org/forumdisplay.php?fid=52

I am working to get lpireyn's idea working for me and any other xbox with a pc dvd drive.

He has sugested it should work on most distro's.

Just install halevt and add the file he posted if you havent tried already.

Im not sure what limitations there are when dealing with a live cd unless you have "fully installed it" from the live cd.

The good thing about his solution is that it checks all the drive to see what they are and what disk is in them then effectivly marks them as dvd drives with a dvd then issues the command to these drives only so the only issue you should have is your drive responding to the command.....
Reply

Logout Mark Read Team Forum Stats Members Help
[LINUX] Script to decrease DVD read speed0