LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-15-2009, 08:55 AM   #1
magoot
Member
 
Registered: Feb 2005
Location: Finland
Distribution: Debian testing
Posts: 38

Rep: Reputation: 15
mplayer custom hotkeys?


Hi guys!

I have a question about mplayer. I'm going trough and cleaning up a lot of small videoclips at work and deleting perhaps 1/3 of them. However it's quite annoying having to first mplayer <filename>, look at the clip a few seconds, exit mplayer, rm <filename> and then playing the next file.

I have looked around for mplayer and hotkeys, I picture it would be smooth to have something like the delete key simply rm the file that's currently playing. That way i could "mplayer *.avi" and simply delete the files i want or jump forward to the next clip with page up.

Is there any way to do this or something similar?

Best regards
MagooT
 
Old 09-15-2009, 09:07 PM   #2
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
Hi,

Try to use SMPLAYER - this is front-end to MPlayer - and much much easier to configure and customize.
 
Old 09-16-2009, 02:48 AM   #3
magoot
Member
 
Registered: Feb 2005
Location: Finland
Distribution: Debian testing
Posts: 38

Original Poster
Rep: Reputation: 15
Hi, thanks for your reply. I will have a look and see if smplayer can be configured in the way i want
 
Old 09-16-2009, 11:30 AM   #4
bpringlemeir
LQ Newbie
 
Registered: Apr 2007
Posts: 6

Rep: Reputation: 0
menu.conf

The menu.conf file has some key binding entries. This is an XML file that is used for menus. The file 'input.conf' is a simplier format that is of the form "<key> <function> <parameters>". These keys are active when a menu is not up. For example,

0 volume 1
9 volume -1

The 'volume' command alters the audio output. The 1, -1 specify by which value to step the volume.

On a debian system there is,
/usr/share/doc/mplayer/examples/input.conf

The file in ~/.mplayer/input.conf will usually take priority.

The commands are documented in 'slave.txt'.

http://www.mplayerhq.hu/DOCS/tech/slave.txt

Best of luck.
 
Old 09-16-2009, 01:21 PM   #5
magoot
Member
 
Registered: Feb 2005
Location: Finland
Distribution: Debian testing
Posts: 38

Original Poster
Rep: Reputation: 15
Thanks, that helped a lot.
I tried using a line like
DEL rm "${filename}"

but that didn't work, the filename-variable doesn't seem to work in that context (i saw it somewhere in the input.conf-example).


However this is a solution that seems to work for me, i made a shellscript like so:

Code:
#!/bin/sh
ps -ef |grep mplayer |grep -v grep | awk '{print "rm " $9}' |sh
echo "DELETED!"
And then in input.conf
Code:
DEL run /usr/local/bin/delmpfile.sh
It still needs some tweaking, would be nice if the file stopped playing and jumped to the next when the command is run, but I'm not sure how to accomplish that... gonna keep trying

EDIT: That didn't work, it only worked when playing a single file at a time, not when using mplayer *.avi. Have to figure something else out...

Last edited by magoot; 09-16-2009 at 01:26 PM.
 
Old 09-16-2009, 07:38 PM   #6
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
Hi, I understood what do you want.

You need a script, which does the following:

Takes the file name: my.script <file_name>
Opens it with any video player.
Waits for key pressed: D (delete) or L (leave)
Closes video player and then delete or leave file.
"May be" opens next file from directory.

But, I don't know scripting well enough to write it. You can talk to appropriate person or just read about it.
That would do you want.

Thanks
 
Old 09-23-2009, 09:46 AM   #7
bpringlemeir
LQ Newbie
 
Registered: Apr 2007
Posts: 6

Rep: Reputation: 0
Preview keep/delete.

If the object is only to preview some avi files and keep or delete them, then the 'slave.txt' has a quit command. The quit command takes an arguement which is the return code. A script involking mplayer can inspect this value and then perform the appropriate action.

[example]
#!/bin/sh
/usr/bin/mplayer "$@"
if [ $? != 0 ]
then
rm $1
fi
[/example]

This script can be invoked like,

find . -name '*.avi' -exec my_script.sh {} \;

to batch a bunch of files. The suggestion of wrapping mplayer is very useful. If the OP wants this functionality available while playing. Ie, a seldom used feature to delete the avi and proceed to the next file, then this doesn't work so well. A change to he script to add the file name to '/tmp/mplayer_kill_list' and the wrapper could iterate over any of these to delete the files when finished; as you probably wouldn't care when the file is deleted. This might also allow the chance to kill the process so the kill list wasn't deleted and/or you may prefer to run a post script to act on the list of files in the kill list.

hth,
Bill Pringlemeir.
 
Old 09-23-2009, 10:01 AM   #8
bpringlemeir
LQ Newbie
 
Registered: Apr 2007
Posts: 6

Rep: Reputation: 0
How to get the filename?

The command,

ls -l /proc/`pgrep -n mplayer`/fd/3 | cut -d\> -f1

gives a filename currently open by mplayer. If you have multiple users, etc, you can tweak the pgrep command to limit the mplayer instances. However, I think that most people only have one instance. The number '3' is a guess at the avi file. It could be different depending on your setup. Normally mplayer will only have the video it is playing open, but things might be different if you use sub-titles, etc.

It looks like the OP was sending argument nine as the file name.

fwiw,
Bill Pringlemeir.
 
Old 09-27-2009, 01:09 PM   #9
magoot
Member
 
Registered: Feb 2005
Location: Finland
Distribution: Debian testing
Posts: 38

Original Poster
Rep: Reputation: 15
Thank you for all the replies, bpringlemeir's suggestion seems to work exactly like i want, just added "DEL quit 1" in input.conf and i can now alter between deleting the file with DELETE or simply quitting with ESC.

Sweet! Thanks!
 
Old 09-27-2009, 01:22 PM   #10
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,036

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
Be careful though.

I never looked into the exit statuses for mplayer, but more than probably it will return non-zero for any arbritrary error, that could mean that if it fails playing a file your wrapper will probably wipe it without any warning at all... Id rather use a well defined exit status, for example 666 or whatever you prefer, and check for that concrete number, instead of checking for != 0

Last edited by i92guboj; 09-27-2009 at 01:23 PM.
 
  


Reply

Tags
hotkey, mplayer


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating custom headers to match a custom kernel utanja Debian 2 06-08-2007 03:15 PM
Custom kernel image on custom slack build using CUSS nykey Slackware 2 07-15-2006 03:05 AM
gmplayer or mplayer with custom keys sadarax Linux - Software 1 03-06-2006 12:34 AM
custom geforce video card--custom module? bandofmercy Linux - Hardware 3 10-14-2004 06:52 PM
Hotkeys Thray Linux - General 4 04-05-2004 06:25 PM


All times are GMT -5. The time now is 08:23 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration