Close
0%
0%

RPiLooper

Raspberry Pi powered seamless video looper

Similar projects worth following
Update: new image for RPi2 released, check links.

Challenge: Find a low cost way to seamlessly loop high resolution video.

We looked at some options, and decided that the Raspberry Pi would be our platform of choice, based primarily on cost (we would need about 15 different looping videos). There are a few Pi distributions out there doing a great job of making a Pi-powered kiosk easy to pull off, but all of them share a glaring flaw: big gaps between video loops. For our purposes, we needed our video to instantly restart when it ended with no indication of an interruption. This is useful for art installations and emulating video sources for demos, among other things. As a result, the ready-to-go options weren't suitable so we rolled our own.

Basically, we're using a very slightly modified version of hello_video to launch a video file prior to the login screen.

Posting so that other folks with little to no linux chops who are looking for a similar solution can follow along.

Step 1 - Install Raspbian

Start with the Raspbian distro from the raspberrypi.org downloads page:http://downloads.raspberrypi.org/raspbian_latest

Raspbian setup instructions:

To use an image file, you will need to unzip it and write it to a suitable (2GB or larger, 4GB or larger for Raspbian) SD card using the UNIX tool dd. Windows users should use Win32DiskImager. Do not try to drag and drop or otherwise copy over the image without using dd or Win32DiskImager – it won’t work. If you’re still not clear on what to do, the community on the Raspberry Pi Wiki has written a guide for beginners on how to set up your SD card.

Go ahead and boot up your fresh Raspbian install. Make sure to connect a network cable to your DHCP enabled network, along with a monitor, mouse, and keyboard prior to booting. You’ll get a configuration screen the first time which will let you change the password and make some other changes.

You can expand the filesystem if you want, but we'll be loading our video onto an external drive.

Do the Change User Password thing too. Remember, you’re changing the password for the “pi” user here.

Hit Finish, and when it asks if you want to reboot, hit Yes.

Once you’re booted up, go ahead and run ifconfig and record the ip address (which you’ll have only if you’ve connected your raspberry pi to a network with a DHCP server). You will want to know this later to SSH in to your pi to make changes, if necessary.

Step 2 - Rebuild hello_pi code examples

Navigate to the /opt/vc/src/hello_pi directory and run the rebuild.sh script as follows:

cd /opt/vc/src/hello_pi/<br><br><span>sudo ./rebuild.sh</span>

Step 3 - Update hello_video.bin

Update the hello_video source code to loop any video played with hello_video.bin:

cd /opt/vc/src/hello_pi/hello_video/<br><br><span>sudo pico video.c</span>

Scroll down to around line 120, and look for the following lines of code:

if(!data_len)<br><span>break;</span>

Replace the above with this:

if(!data_len)<br><span>fseek(in, 0, SEEK_SET);</span>

Note that correct capitalization is important. Use Ctrl+O to save, and Ctrl+X to exit.

Now, while still in the /opt/vc/src/hello_pi/hello_video/ directory, use the make command to compile the code:

sudo make

Step 4 - Mount USB drive

Go ahead and load a video on a USB drive, using another computer. The drive should be formatted in fat32, and only .h264 or .m4v video files will work with this solution. As with others in the thread referenced above, I suggest using Yamb to rip the video out of the container. Once finished with Yamb, you will have a file with an .h264 or .m4v suffix. Let’s say this video of yours is called testvideo.h264.

Insert your USB thumb drive, and check your /dev folder to see where it shows up. Mine was at /dev/sda1. Oh, make sure you have only one USB drive inserted.

cd /dev<br><br><span>ls</span>

You'll probably see entries for sda and sda1. You may instead see sba and sba1 (I observed that on one raspbian build I was testing).

Create a folder to which your USB drive will be mounted, and then proceed with the mount.

cd /mnt

<span>sudo mkdir usb<br><br></span><span>mount /dev/sda1 /mnt/usb</span>

Go ahead and make sure this worked.

cd /mnt/usb

<span>ls</span>

You should see the files on your USB drive listed. If so, you're good!

Now let's make this drive mount to /mnt/usb every time we boot:

sudo pico /etc/fstab

Add the following at the end:

/dev/sda1	/media/usb	vfat	defaults	0	0

Ctrl + O to save, Ctrl + X to exit.

If you ran into trouble here, refer to these instructions: http://kwilson.me.uk/blog/force-your-raspberry-pi-to-mount-an-external-usb-drive-every-time-it-starts-up/

Step 6 - Play a test video

Now try playing your video with your updated hello_video code:

cd /opt/vc/src/hello_pi/hello_video/
<span>
./hello_video.bin /mnt/usb/testvideo.h264</span>

You should see your video, and it should loop seamlessly. A shorter video is going to be easier to test with, unless you want to sit through a movie to test it.

You can kill the process with Ctrl+C.

Step...

Read more »

  • 1 × Raspberry Pi Model B

  • RPiLooper V2-Bplus available for RPi B+

    ohthedave12/03/2014 at 14:57 0 comments

    I've made a downloadable image compatible with Raspberry Pi model B+ available here, along with instructions: http://curioustechnologist.com/post/104242571716/rpilooper-v2-b-seamless-video-looper-for

    Cheers!

  • Downloadable image available

    ohthedave06/27/2014 at 14:44 0 comments

    Created an image of v2, which makes it super simple to get up and running. Image link and instructions are here: http://curioustechnologist.com/post/88679377976/seamlessly-looping-raspberry-pi-video-kiosk

  • Converting video files into a compatible format

    ohthedave06/13/2014 at 15:31 0 comments

    One thing RPiLooper is picky about is the format of the video it is fed. Here’s a method of converting your video into a usable format.

    1. Download and install Avidemux: http://fixounet.free.fr/avidemux/download.html
    2. Open your video file with Avidemux.
    3. Set Video Output to Mpeg4 AVC (x264)
    4. Configure Video Output - under the General tab, change the Encoding Mode to Constant Quantiser (Single Pass), and shift the Quantizer slider down to a value of 5. (You can play around with values here, as the lower the value is the larger the file will be - 5 works for me). Don’t change anything else.
    5. Set Output Format to Video Only. No configuration changes are necessary here.
    6. Save your file.
    7. Profit.

  • v2 - automount and play video from USB

    ohthedave04/01/2014 at 19:39 0 comments

    The first version played videos directly from the SD card, which worked as intended. However, it was difficult to change the video that was playing, and also made the replication process a little difficult. We need a good 10-12 of these running, each with a different video loop, so our preference is to get one Pi functioning just how we need, pull the image off the SD card, and push an identical image onto 10-12 new cards with minimal (or zero) modifications. By auto-mounting a usb drive on boot and pointing our player at the new location, we achieved that goal.

    Step 1 - Install Raspbian

    Start with the Raspbian distro from the raspberrypi.org downloads page:http://downloads.raspberrypi.org/raspbian_latest

    Raspbian setup instructions:

    To use an image file, you will need to unzip it and write it to a suitable (2GB or larger, 4GB or larger for Raspbian) SD card using the UNIX tool dd. Windows users should use Win32DiskImager. Do not try to drag and drop or otherwise copy over the image without using dd or Win32DiskImager – it won’t work. If you’re still not clear on what to do, the community on the Raspberry Pi Wiki has written a guide for beginners on how to set up your SD card.

    Go ahead and boot up your fresh Raspbian install. Make sure to connect a network cable to your DHCP enabled network, along with a monitor, mouse, and keyboard prior to booting. You’ll get a configuration screen the first time which will let you change the password and make some other changes.

    You can expand the filesystem if you want, but we'll be loading our video onto an external drive.

    Do the Change User Password thing too. Remember, you’re changing the password for the “pi” user here.

    Hit Finish, and when it asks if you want to reboot, hit Yes.

    Once you’re booted up, go ahead and run ifconfig and record the ip address (which you’ll have only if you’ve connected your raspberry pi to a network with a DHCP server). You will want to know this later to SSH in to your pi to make changes, if necessary.

    Step 2 - Rebuild hello_pi code examples

    Navigate to the /opt/vc/src/hello_pi directory and run the rebuild.sh script as follows:

    cd /opt/vc/src/hello_pi/<br><br><span>sudo ./rebuild.sh</span>

    Step 3 - Update hello_video.bin

    Update the hello_video source code to loop any video played with hello_video.bin:

    cd /opt/vc/src/hello_pi/hello_video/<br><br><span>sudo pico video.c</span>

    Scroll down to around line 120, and look for the following lines of code:

    if(!data_len)<br><span>break;</span>

    Replace the above with this:

    if(!data_len)<br><span>fseek(in, 0, SEEK_SET);</span>

    Note that correct capitalization is important. Use Ctrl+O to save, and Ctrl+X to exit.

    Now, while still in the /opt/vc/src/hello_pi/hello_video/ directory, use the make command to compile the code:

    sudo make

    Step 4 - Mount USB drive

    Go ahead and load a video on a USB drive, using another computer. The drive should be formatted in fat32, and only .h264 or .m4v video files will work with this solution. As with others in the thread referenced above, I suggest using Yamb to rip the video out of the container. Once finished with Yamb, you will have a file with an .h264 or .m4v suffix. Let’s say this video of yours is called testvideo.h264.

    Insert your USB thumb drive, and check your /dev folder to see where it shows up. Mine was at /dev/sda1.  Oh, make sure you have only one USB drive inserted.

    cd /dev<br><br><span>ls</span>

    You'll probably see entries for sda and sda1. You may instead see sba and sba1 (I observed that on one raspbian build I was testing).

    Create a folder to which your USB drive will be mounted, and then proceed with the mount.

    cd /mnt
    
    <span>sudo mkdir usb<br><br></span><span>mount /dev/sda1 /mnt/usb</span>

    Go ahead and make sure this worked.

    cd /mnt/usb
    
    <span>ls</span>

    You should see the files on your USB drive listed. If so, you're good! 

    Now let's make this drive mount to /mnt/usb every time we boot:

    sudo pico /etc/fstab

    Add the following at the end:

    /dev/sda1	/media/usb	vfat	defaults	0	0

    Ctrl...

    Read more »

  • v1 working

    ohthedave03/27/2014 at 15:05 0 comments

    So the first version is up and running just fine. A few modifications wouldn't hurt:

    1. Would be nice to mount a usb thumb drive and play a video from there. Should be easy, just need to see how consistent the drive mapping ends up being.

    2. Could use some polishing. Would be nice to package it up instead of using a hack.

View all 5 project logs

Enjoy this project?

Share

Discussions

Craig Hissett wrote 07/01/2015 at 12:14 point

What a great project!

I'm currently working on a video playing project involving a raspberry Pi and have been struggling to work out the playing side of things.

I may have to rethink my use of Python!

  Are you sure? yes | no

Adam Di Carlo wrote 04/16/2014 at 20:06 point
I've got a git fork over at https://github.com/adicarlo/RaspberryPi-firmware-video which patches hello_video.bin in a different way. Rather than seeking back on a single video it continuously loops over all arguments, playing each then looping around again.

I could do a clean fork with *only* this change, if you like. The master fork on that repos is pursing a system that lets you switch from one video to the next (or prior) using a GPIO rising edge, e.g., a tactile button. Some problems remaining to fix there tho.

  Are you sure? yes | no

ohthedave wrote 06/13/2014 at 15:30 point
Oo, that's interesting.. yes, I'd be interested in checking that out!

  Are you sure? yes | no

Eric Evenchick wrote 03/27/2014 at 16:00 point
Wow, nice to see that a quick modification to the demo got video looping seamlessly. It would be really nice to see this packed up so that you just drop a file over SCP and it starts looping.

  Are you sure? yes | no

ohthedave wrote 04/01/2014 at 19:59 point
The more automated the better! I did just modify it so that the video can be placed on a usb drive - makes it easier to change the loop, and now I can pop this image onto as many Pi's as I want with no modifications.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates