View Full Version : [SOLVED] How can I play random videos in a directory from the terminal...
Rytron
March 9th, 2012, 10:36 AM
Hi.
How can I play random (shuffle) videos in a directory from the terminal? I'd also like it to auto make a playlist of 10 files.
Thanks.
nothingspecial
March 9th, 2012, 10:40 AM
Assuming your videos are in your Videos folder
mplayer -quiet -shuffle -playlist <(find ~/Videos -type f)
You can skip past any you don't want to watch with >
Note: That will play any media file in your Videos folder.
dandnsmith
March 9th, 2012, 10:43 AM
Didn't see there was a reply until I attempted one.
Rytron
March 9th, 2012, 11:49 AM
mplayer -quiet -shuffle -playlist <(find ~/Videos -type f)
How can I use it to play videos in the current directory? Can it also look into sub directories?
dandnsmith
March 9th, 2012, 04:41 PM
mplayer -quiet -shuffle -playlist <(find . -type f)
That should get the current directory, and is easy to extend to recursive search if it isn't going to do it anyway - I suggest looking at the man page for find
Rytron
March 9th, 2012, 06:21 PM
mplayer -quiet -shuffle -playlist <(find . -type f)
That should get the current directory, and is easy to extend to recursive search if it isn't going to do it anyway - I suggest looking at the man page for find
I ran the above command inside a folder with 3 movie files (has 3 parts and has no sub folders). Got this error:
player -quiet -shuffle -playlist <(find . -type f)
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing /dev/fd/./1201 PM (Part 23).mp4.
File not found: '/dev/fd/./1201 PM (Part 23).mp4'
Failed to open /dev/fd/./1201 PM (Part 23).mp4.
dandnsmith
March 10th, 2012, 11:20 AM
You haven't provided a list of the files, but I'd hazard a guess that the problem is the space(s) within the filename. You could quickly check this manually. If it is so, then you need to quote the filename(s) before passing them to mplayer - I cannot quickly see how this should be done, but I'm sure someone else can provide an answer (which may call for a for-loop to be built in to quote each filename before passing on).
nothingspecial
March 10th, 2012, 01:26 PM
To play all the files in the current directory randomly just do
mplayer -quiet -shuffle *
If there are subdirectories you can use
mplayer -quiet -shuffle {*,*/*} to go one level deep.
Rytron
March 10th, 2012, 05:21 PM
You haven't provided a list of the files, but I'd hazard a guess that the problem is the space(s) within the filename. You could quickly check this manually. If it is so, then you need to quote the filename(s) before passing them to mplayer - I cannot quickly see how this should be done, but I'm sure someone else can provide an answer (which may call for a for-loop to be built in to quote each filename before passing on).
There are too many files to list.
Rytron
March 10th, 2012, 05:43 PM
To play all the files in the current directory randomly just do
mplayer -quiet -shuffle *
If there are subdirectories you can use
mplayer -quiet -shuffle {*,*/*} to go one level deep.
Excellent stuff! ;)
Powered by vBulletin® Version 4.2.2 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.