[SOLVED] VLC RTSP playlist to randomly loop videos in a directory

Came up with a solution for randomly playing video with XIBO and Android clients.
All I have to do to add more is drag and drop more files into a Windows share.

This solution allows me to drop .mp4 files into a windows share.
They are then trans-coded and copied to a local folder on a Linux server.
Afterwards the share is cleared of .mp4 files and the VLC playlist is regenerated.
The playlist is used to RTSP stream all the videos on a random loop with VLC CLI.

First installed VLC on a CENTOS server to do RTSP streaming with xspf playlist.
Mounted a CIFS share in the /mnt/ dir through FSTAB.
Then installed Handbreak CLI to normalize the videos to 1080p, keeping the stream playing smooth.

Below is the CLI command I use to stream the RTSP. (beware of wordwrap)

cvlc -I dummy --random --loop /var/Videos/files/playlist.xspf :sout=#gather:rtp{sdp=rtsp://:8554/} :network-caching=1500 :sout-all :sout-keep

Below are my crontab entries.
The first entry executes a script every 5 minutes for CLI Handbrake trans-coding.
This script also does file cleanup and recreates the playlist file.
The second entry starts the RTSP streaming, with the ‘vlcstreamer’ user, after server (re)boot.

  5 * * * * root (cd /home/scripts; ./handbrakeVids.sh)
  @reboot vlcstreamer cvlc -I dummy --random --loop /var/Videos/files/playlist.xspf :sout=#gather:rtp{sdp=rtsp://:8554/} :network-caching=1500 :sout-all :sout-keep

Here is a link to my bash scripts which I keep in /home/scripts.
Google Drive : bash.zip
These are used by the crontab and for manually restarting the stream after adding new videos.

1 Like