I build a video distribution system, where there is one server with a "playlist" of URLs, and multiple Raspberry PIs working as clients, fetching constantly playlist from the server and putting their local "videos" folder in sync with playlist. "Clients" can go offline anytime, but must be able to loop videos they have got so far. The system should work without any GUI, automatically upon startup.

The biggest problem I encountered so far is trying to play multiple .mp4 videos in a playlist without 1 second gaps. --loop would do, but I need to play multiple files in a row.

A simplified model of omxplayer "playlist" would be a script like

`omxplayer video1.mp4`
`omxplayer video2.mp4`
`omxplayer video3.mp4`

I am aware of hello_video option, but it still has 0,1s black gap and videos must be transcoded to "raw h264" – it doesn't fit me, as I don't want to add extra moving part in form of transcoding daemon (I'll have tens of GBs coming in .mp4).


create the following script in any directory:

# get rid of the cursor
setterm -cursor off

# set here the path to the directory containing your videos
# you can probably leave this alone
# our loop
while true; do
        if ps ax | grep -v grep | grep $Process > /dev/null
        sleep 1;
        for entry in $VideoLocation/*
                # -r for stretched over the entire location
                omxplayer -r $entry > /dev/null

Save the script and then make it executable:

sudo chmod +x mohammadsLoop.sh

Then we run it using the following command:

  • It doesn't solve the gap problem. – Mikhail Vasin Sep 19 '16 at 22:43
  • can you try it without the "sleep 1;" and tell me how long the delay is if any? – Mohammad Ali Sep 19 '16 at 22:44
  • You can see from my initial code sample that there is no extra "sleep" delay by design, the next video starts just after finish of the previous, but still it takes around a second or two to start the next video. – Mikhail Vasin Sep 19 '16 at 22:46
  • i believe that that would be un avoidable buffer time as the code i posted will start the next video immediately after the one before it has ended. and since the pi is only capable of handling a single video stream at any single time you really aren't able to buffer a video while another video is playing so your really out of options unless you want to interlace all of your clips together their really isn't much i can do for you – Mohammad Ali Sep 19 '16 at 22:48

If you get a black screen on your X11 desktop after Omxplayer is finished, you can use this command to restore your view:

xrefresh -display :0

Or you can use a small Bash script for video playback to do this every time

omxplayer "$@"
xrefresh -display :0

On Raspbian, xrefresh is part of the x11-xserver-utils package (apt-get install x11-xserver-utils).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.