Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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.
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.
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...
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.
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.
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.