For a given playlist, I want to reproduce only first 10 seconds of each audio file in the playlist. I searched but I found nothing similar. Does exist a plugin? Is it possible in some way? Thank you!
2 Answers
This is straight forward. You have tagged this as VLC, so I'll use that as an example.
First you need a playlist, of course. Here is VLC's wiki to explain how to make a playlist. Make sure you save it to a file.
Then, from commandline, start VLC like this
vlc --playlist-autostart <path/to/playlist.xspf> --run-time=10
This will make vlc immediately play your list, each title for 10 seconds, then stop with VLC left open.
If you start your VLC not from the GUI of the host where the music is played, i.e. via SSH, you need to export the DISPLAY
variable, like this
export DISPLAY=:0; vlc --playlist-autostart <path/to/playlist.xspf> --run-time=10
If you want to VLC immediately close after finished playing, just add vlc://quit
to the end, like this
export DISPLAY=:0; vlc --playlist-autostart <path/to/playlist.xspf> --run-time=10 vlc://quit
I don't know exactly what your use-case is, but If you want this to be completely stealthy, with no VLC shown on the Desktop you could use the commandline frontend. Just substitute vlc with cvlc at the beginning, like this
export DISPLAY=:0; cvlc --playlist-autostart <path/to/playlist.xspf> --run-time=10 vlc://quit
There are of course some more options for playlist behaviour, like -L
for looping or -Z
for shuffle/random, and so on - you best look them up on the official VLC commandline documentation.
-
1I'm just disappointed it's taken me this many years to find
--run-time=
. Aug 20, 2020 at 22:22
The command line application MPlayer is your friend for this simple task:
mplayer -endpos 00:00:10 -playlist playlist.pls
Some explanation:
- -endpos 00:00:10 This allows MPlayer to stop at a given time or even given byte position. In this example 10 seconds playback is allowed from the beginning of the stream.
- -playlist Must be specified for MPlayer to deal with a playlist.
- playlist.pls MPlayer recognises ASX, Winamp, SMIL, or one-file-per-line format (such as the 'pls' example given here). Of course the correct path to the playlist file must be given.
There are many more switches that MPlayer can use to deal with playlists but the example given above should be enough to fulfill your requirements...