| Author |
Message |
steve_s

Joined: 26 May 2008 Posts: 1543 Location: Austin, TX, USA
|
Posted: Thu 14 Jul 2011, 16:22 Post subject:
Want a Bash script to open mplayer then play a file |
|
Ok, that sounds crazy in the subject 'cause all mplayer users know you can just run:
then the file name and it will run the file.
But due to the speed of my computer (what there is of it) I have given a lot of parameters to mplayer and I seem to keep adding more:
| Code: |
mplayer -vo x11 -zoom -aspect 4:3 filename.avi
|
I'm wondering how to set up a bash script that has all my parameters then allows me to run the file I want. For example, if the script were titled 'video-play' it would something like:
| Code: |
video-play filename.avi
|
As I write it now I don't know the one key parts of the script, the part that will allow me to input data after the script, to run it. So I write the bash for mplayer with all the parameters, without the file I want to run, but it of course kicks back even if I type in the file I want afterwards.
Would one of you bash/script wizards tell me how to do this, pretty please?
|
|
Back to top
|
|
 |
jpeps
Joined: 31 May 2008 Posts: 2421
|
Posted: Thu 14 Jul 2011, 16:32 Post subject:
|
|
$1 is for args (filename)
| Code: |
#!/bin/sh
DEF="-vo x11 -zoom -aspect 4:3"
mplayer ${DEF} "$1"
|
Last edited by jpeps on Thu 14 Jul 2011, 16:50; edited 3 times in total
|
|
Back to top
|
|
 |
puppyluvr

Joined: 06 Jan 2008 Posts: 3052 Location: Chickasha Oklahoma
|
Posted: Thu 14 Jul 2011, 16:36 Post subject:
|
|
Hello,
Using a variable as above wont solve the filename issue, but this will..
At the end of your script, add
"$@"
including the quotes..
EX: mplayer -vo x11 -zoom -aspect 4:3 "$@"
Then put the script on the desktop, and drop your files on it....
_________________ "Close the "Windows", and open your eyes, to a whole new world"
http://puppylinuxstuff.meownplanet.net/puppyluvr/
http://theplpd.webs.com/
Nothing but Puppy since 2.15CE...
|
|
Back to top
|
|
 |
steve_s

Joined: 26 May 2008 Posts: 1543 Location: Austin, TX, USA
|
Posted: Thu 14 Jul 2011, 16:42 Post subject:
|
|
Perfect, jpeps, thank you! That is all I needed...
I tried yours but for some reason it kicks back that -vo isn't a recognized command...something about my spacing or something, I'm sure, but this worked great:
| Code: |
#!/bin/bash
mplayer -vo x11 -zoom -nortc -nocache -lavdopts fast -aspect 4:3 "$1"
|
save the script in whatever name I want, in this case video-play, then I run whatever file I want with it like this:
| Code: |
video-play moviefile.avi
|
and it plays the movie great! Now I can add parameters as I want without having to remember every last little one. Thanks again.
Last edited by steve_s on Thu 14 Jul 2011, 16:54; edited 1 time in total
|
|
Back to top
|
|
 |
steve_s

Joined: 26 May 2008 Posts: 1543 Location: Austin, TX, USA
|
Posted: Thu 14 Jul 2011, 16:44 Post subject:
|
|
| puppyluvr wrote: | Hello,
Using a variable as above wont solve the filename issue, but this will..
At the end of your script, add
"$@"
including the quotes..
EX: mplayer -vo x11 -zoom -aspect 4:3 "$@"
Then put the script on the desktop, and drop your files on it.... |
Thanks, puppyluvr, I'm checking that out too! Very appreciated...kinda like that drop it on the desktop idea...
|
|
Back to top
|
|
 |
jpeps
Joined: 31 May 2008 Posts: 2421
|
Posted: Thu 14 Jul 2011, 16:51 Post subject:
|
|
Needed ${DEF} ....I edited the script.
|
|
Back to top
|
|
 |
steve_s

Joined: 26 May 2008 Posts: 1543 Location: Austin, TX, USA
|
Posted: Thu 14 Jul 2011, 17:01 Post subject:
|
|
Since I kinda like the definition stuff being seperate, the script now looks like this (added that last mod from jpeps and will probably continue to make changes in mplayer definitions until I get the format I want):
| Code: |
#!/bin/bash
DEF="-vo xv -zoom -nortc -nocache -lavdopts fast -aspect 4:3"
mplayer ${DEF} "$@"
|
Thanks!
|
|
Back to top
|
|
 |
Bruce B

Joined: 18 May 2005 Posts: 10817 Location: The Peoples Republic of California
|
Posted: Thu 14 Jul 2011, 18:29 Post subject:
|
|
I could be mistaken. I think we needed a loop or something like it to play the second and third videos. Depending I suppose on how the script is run.
| Code: | #!/bin/bash
DEF="-vo xv -zoom -nortc -nocache -lavdopts fast -aspect 4:3"
for i in "$@" ; do
mplayer ${DEF} "$i"
done |
~
_________________ New! Puppy Linux Links Page
|
|
Back to top
|
|
 |
Dougal

Joined: 19 Oct 2005 Posts: 2505 Location: Hell more grotesque than any medieval woodcut
|
Posted: Fri 15 Jul 2011, 15:51 Post subject:
|
|
An even simper way would be to add to your ~/.bashrc: | Code: | | alias mplayer='mplayer -vo xv -zoom -nortc -nocache -lavdopts fast -aspect 4:3' |
_________________ What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind
|
|
Back to top
|
|
 |
big_bass

Joined: 13 Aug 2007 Posts: 1736
|
Posted: Sat 16 Jul 2011, 00:18 Post subject:
|
|
why not one more option so you see there are many ways to get there
edit this file
/usr/local/bin/defaultmediaplayer
to look like this
| Code: | #!/bin/bash
#exec gxineshell "$@"
#exec /usr/bin/gmplayer -msglevel all=-1 "$@" &
#exec vlc -vvv "$@"
exec mplayer -vo xv -zoom -nortc -nocache -lavdopts fast -aspect 4:3 "$@"
|
_________________ slackware 14
|
|
Back to top
|
|
 |
steve_s

Joined: 26 May 2008 Posts: 1543 Location: Austin, TX, USA
|
Posted: Sat 16 Jul 2011, 10:47 Post subject:
|
|
You guys rock...man I love this forum.
|
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 7018 Location: qld
|
Posted: Sat 16 Jul 2011, 22:04 Post subject:
|
|
Hi steve_s
I don't know about many mplayer options but I do know you can at least put sound and video options in your ~/.mplayer/config file. (I'm fairly sure you can put others in there too). It should be faster than bash.
eg: vo=x11
_________________ keep the faith .. 
|
|
Back to top
|
|
 |
steve_s

Joined: 26 May 2008 Posts: 1543 Location: Austin, TX, USA
|
Posted: Sun 17 Jul 2011, 19:17 Post subject:
|
|
| 01micko wrote: | Hi steve_s
I don't know about many mplayer options but I do know you can at least put sound and video options in your ~/.mplayer/config file. (I'm fairly sure you can put others in there too). It should be faster than bash.
eg: vo=x11 |
Thanks, micko!
|
|
Back to top
|
|
 |
GatorDog

Joined: 12 Sep 2006 Posts: 136
|
Posted: Tue 19 Jul 2011, 02:15 Post subject:
Bacon video-play Subject description: video-play app written in BaCon |
|
This isn't a bash script and it is overkill in the extreme.
FWIW here is a BaCon program for video-play.
http://www.murga-linux.com/puppy/viewtopic.php?t=69647&start=11
rod
| Description |
screen shot |
| Filesize |
354.71 KB |
| Viewed |
634 Time(s) |

|
|
|
Back to top
|
|
 |
|