Playing DVDs by running script
#1
Hi
I am new here, I am trying to figure out how to do this. I have XBMC on a raspberry pi and I run a simple command to basically read the contents of a usb dvd rom drive and dumps it to a file called dvd.mpg which when clicked will play the main movie of a DVD. The problem I am having is how to do this in 1 step...Currently I have to ssh into my raspberry pi, run the command and then go to the dvd.mpg file in XBMC and click it...I would prefer to be able to just click a file in XBMC and then have it run the command and then play the movie automagically...Does anyone have an idea how this can be done?
this is how I am doing it and it works perfectly on all dvds but I don't like the 2 step process...

mplayer dvd://1 -dumpstream -dumpfile /media/LARGEFILES/dvd.mpg

Thanks in advance for any ideas
Reply
#2
This is a real simple add on I made to launch steam but if you edit it it should do what you want, plus if you use the skin confluenece you can have it on the home screen.

http://forum.xbmc.org/showthread.php?tid...id=1338734


The flowing line could be modified and included in your script to start playback.

curl --data-binary '{ "jsonrpc": "2.0", "method": "Player.Open", "params":{"item": {"file": "/media/br0/BDMV/index.bdmv"}}, "id": "1" }' -H 'content-type: application/json;' http://localhost:7777/jsonrpc
Reply
#3
Hi teeedubb
thanks for the idea...
please correct me if i am wrong...
your line seems to not work, can you advise me please?

/home/pi/.xbmc/addons/script.PlayDVD# cat default.py
import os
os.system('mplayer dvd://1 -dumpstream -dumpfile /media/LARGEFILES/dvd.mpg')
curl --data-binary '{ "jsonrpc": "2.0", "method": "Player.Open", "params":{"item": {"file": "/media/LARGEFILES/dvd.mpg"}}, "id": "1" }' -H 'content-type: application/json;' http://localhost:7777/jsonrpc
Reply
#4
Is it ripping the DVD? Also the http address and port at the end of the curl command needs to be modified to suit your machine. Also jsonrpc needs to be enabled - http://wiki.xbmc.org/index.php?title=JSO...g_JSON-RPC

You can try the command first via terminal.
Reply
#5
Yes I don't think 7777 is the usual rpc port is it?

Also dvd://1 is the first title, which may or may not be the movie.

A better script would look at all the titles and guess that the longest one is the movie.

Does the rpi not play dvd's by itself or something?
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#6
well rpi is supposed to play dvds, some builds do and this raspbmc build i am using does on some older dvds but not on new ones...i prefer it to others that i have used because it doesnt crash as much and works better with most addons...that being said, i know that openelec plays dvds with no problems, i just dont want to have to keep switching os if i want to play a movie...hence this workaround

as for dvd://1, i am too inexperienced to be able to figure out how to look up the longest file and output that to be able to dump, if you have any suggestions i would greatly appreciate it Big Grin
maybe something along the lines of
du -xak /media/<DVD_NAME>|sort -n|tail -5
but i am not certain how to figure out how to find the dvd name and input it there and then what to do with the output to find the longest one and play it...

as for the localhost:port, yes i was stupid, i didnt bother to check Big Grin, i assume i should use /var/run/rpcbind.sock port...but it keeps changing....so any ideas there?
Reply
#7
so after doing some searching (friends werent helpfull) i have come up with this modification but it still isnt working..

import os
os.system('nohup mplayer dvd://1 -dumpstream -dumpfile /media/LARGEFILES/dvd.mpg 1>/dev/null 2>/dev/null </dev/null & sh /home/pi/.xbmc/addons/script.PlayDVD/play /media/LARGEFILES/dvd.mpg')

where play script is
curl -g localhost:8080/jsonrpc?request=\{\"jsonrpc\":\"2.0\",\"method\":\"Player.Open\",\"params\":\{\"item\":\{\"file\":\"$1\"\}\},\"id\":\"1\"\}

it works in that i can get mplayer to dumpfiles directly from xbmc..but I am trying to get it to dump files and then play files in the same script/command
this kind of works due to the fact that i can do everything from xbmc, not from terminal....any ideas would be most helpfull...Smile
Reply
#8
Does running your commands from the terminal work? Both ripping and starting playback?
Reply
#9
hi teeedub
from terminal it does work to both rip and play, but running it internally from xbmc directly it only starts ripping the dvd,
if i navigate to the dvd.mpg file i can click it to get it to play the rip...
when i check ps-ef | grep -i mplayer i see both arguments running (if i remove nohup and &)...so it seems to me it should be working but no output to tv
Reply
#10
Maybe you need to pause until mplayer has dumped some more data?
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#11
The locations of the dvd rips doesn't change right? Try and keep the script all in the default.py and not using the variable $1.
Reply
#12
yes but the second command will execute immediately after the other starts and backgrounds, if there is no data (because mplayer takes a while to do it's thing, especially if it needs to do decryption stuff) then the second command will fail.

Try a 30 second delay between the two commands, if that fixes it decrease the delay by 5 sec at a time until it stops working, then add a bit more for exigencies.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#13
yeah my bad about the ampersand, one ampersand will background the 1st process and run the second - Ive learnt something today Big Grin

Ontop of nick suggested, enable debug logging in xbmc and have a browse through that after running the addon... may shed some light on it..
Reply
#14
i thought that as well, so i waited for 10-15 mins and no luck...but once i click the dvd.mpg file it starts right away, and it is only dumping about 10 seconds lead, not the whole movie at once

i am thinking it may be something to do with localhost:8080 since it is internally running, not through a terminal...

but thanks for the suggestions, i will try them when i get home...
Reply
#15
one other question please, how could i scan the dvd and be able to pick out other titles instead of just dvd://1...like if i had a dvd from a tv series so there are many files...
Reply

Logout Mark Read Team Forum Stats Members Help
Playing DVDs by running script0