3

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).

0

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
VideoLocation="/mohammads/dank/meme/videos" 
# you can probably leave this alone
Process="omxplayer"
# our loop
while true; do
        if ps ax | grep -v grep | grep $Process > /dev/null
        then
        sleep 1;
else
        for entry in $VideoLocation/*
        do
                clear
                # -r for stretched over the entire location
                omxplayer -r $entry > /dev/null
        done
fi
done

Save the script and then make it executable:

sudo chmod +x mohammadsLoop.sh

Then we run it using the following command:

./mohammadsLoop.sh
  • 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
0

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

#/bin/bash
omxplayer "$@"
xrefresh -display :0

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

0

So I tried the xrefresh thing on its own but I had no luck. I did some more research and I found something that made the gap a bit smoother.

I used xterm also,

sudo apt-get install xterm

and I modified my script:

#!/bin/bash
VIDEOPATH="/home/pi/Desktop/videos"
while true; 
do
  for videos in $VIDEOPATH/*
    do
      xterm -fullscreen -fg white -bg black -e omxplayer -o hdmi -r "$videos"
      xrefresh -display :0
    done
done

Further information here.

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.