colbyparsons
Posts: 22
Joined: Fri Jan 27, 2012 7:42 pm

Re: seamless looping

Sun Feb 10, 2013 6:36 pm

Yeah, I would be interested. And can you tell us the exact version of Debian you used?

Thanks!

--Colby

GeorgeIoak
Posts: 43
Joined: Thu Aug 30, 2012 1:50 am

Re: seamless looping

Sun Feb 10, 2013 7:30 pm

Yes, your work sounds interesting to me too!

denjell
Posts: 25
Joined: Sun Feb 10, 2013 4:00 pm

Re: seamless looping

Sun Feb 10, 2013 11:38 pm

the rpi i used is installed right now, but i need to go to the gallery tomorrow anyway. I'll copy out the important stuff and make a script that should patch a fresh installation. i am using the december 2012 raspian (without running apt-get update).

of course it is not the right way to do it, but it works. in my opinion using omxplayer is not a good solution, but it *works*. theoretically if you know the exact frame length (time) of the clip you want to run, a simple time counter running in parallel (i.e. a script calls the player and also simultaneously begins the time counter) could be used to skip back to the beginning of the already playing video just before the video ends. this could be done programmatically or with a dirty offset and hardcoding of the duration. (i.e. experimentation)

omx has the problem that it dumps the stream when the file ends and needs to reload the metadata in the file so that it knows how it should address the video. this takes a few hundred milliseconds - which accounts for the lack of seamlessness.

the quest continues...

denjell
Posts: 25
Joined: Sun Feb 10, 2013 4:00 pm

Re: seamless looping

Mon Feb 11, 2013 11:36 pm

so i deleted the untested script because i tested it and it didn't work. sorry if anyone lost their patience. here is a tested (and corrected) version of the autoloop omx patch that does what it is supposed to.

1) no login
2) autostart
3) autoloop media file
4) silent logging

RTFM.

Code: Select all

#!/bin/bash
# autoloop-patch.sh

# autoloop patch for raspbian
# v.0.2
# Raspberry Pi Forum User denjell
# http://www.raspberrypi.org/phpBB3/memberlist.php?mode=viewprofile&u=56730

# copyleft 2013 / no guarantees of fitness for any purpose

# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


# READ THIS FIRST BEFORE RUNNING THE FILE!
# ----------------------------------------

# this script creates 2 files on your system and modifies /etc/inittab.
# 1) /etc/init.d/startup
# 2) /home/{user}/autoloop.sh
# 3) /etc/inittab

# it assumes general knowledge of stuff like debian and media files / codecs
# it should work on most raspians, however I recommend a clean image.

# Step0: follow the instructions here to make your RPi distro:
# http://elinux.org/RPi_Easy_SD_Card_Setup
# choose medium overclocking
# do not activate the window manager (ie only command line interface)

# Step1: place this script in your /home/%user folder (on the Rpi)
# type: (without the quotes)
# "nano /home/pi/autoloop-patch.sh"
# copy this script with ctl-c
# paste it in into the nano editor with shift-ctl-v
# save it with ctl-x

# Step2: place your media file in /home/pi or whatever:
# e.g. /home/pi/movie.mp4
# it must be h264 video and PCM 16bit signed little endian audio stream

# Step3: type (without the quotes and use your user name instead of pi):
# "sudo bash /home/pi/autoloop-patch.sh /home/pi/movie.mp4"
# you can run this script anytime you want a new film to loop
# it will re-run the setup and restart your RPi.

# Step4: how to exit the loop.
# http://en.wikipedia.org/wiki/Magic_SysRq_key

# This works for me. However, I cannot guarantee it will work for you.
# I do not manage a help desk, and this patch is provided "as is".
# Good luck. Have fun. Do stuff.

#find the user
user=${PWD##*/}
file=$1

# create the startup script
sudo echo "#! /bin/sh

case \$1 in
  start)
    sudo bash /home/"${user}"/omx-loop.sh "${file}" >/dev/null 2>&1
    ;;
esac

exit 0" > /etc/init.d/startup.sh
sudo chmod 755 /etc/init.d/startup.sh
sudo update-rc.d startup.sh defaults -nn
echo "/etc/init.d/startup created and initialized"


echo "#!/bin/sh

SERVICE='omxplayer'
	while true; do
		setterm -blank off -powerdown off > /dev/tty0
		clear > /dev/tty0
		setterm -cursor off > /dev/tty0
		echo;echo;echo;echo;echo;echo;
		clear > /dev/tty0

		if ps ax | grep -v grep | grep \$SERVICE > /dev/null
			then
				echo; # sleep 1
			else
				echo;echo;echo;echo;echo;echo;
				omxplayer -o hdmi \$1 & > /dev/null
				clear > /dev/tty0

		fi
	done" > /home/${user}/omx-loop.sh
echo "/home/pi/omx-loop.sh created"
sudo chmod 755  /home/${user}/omx-loop.sh

# remove the old inittab
sudo rm /etc/inittab

# write a new inittab
sudo echo "
# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $
# modified by denjell

# The default runlevel.
id:2:initdefault: 

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
# z6:6:respawn:/sbin/sulogin

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop

# 1:2345:respawn:/sbin/getty --noclear 38400 tty1 
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

#Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100" > '/etc/inittab'

echo "it seems we got this far."

read -p "Restart System Now? (y/n) " RESP
if [ "$RESP" = "y" ]; then
	echo "Restarting."
	sudo reboot
fi 
   echo "You must restart your system to initialize autostarting autoloop."

Brendanflynn
Posts: 5
Joined: Sun Feb 24, 2013 8:08 pm

Re: seamless looping

Sun Feb 24, 2013 10:20 pm

All of you are fantastic. I am about to buy two Pi's for playing video loops on two separate dell vga screens for my end of degree show in art college. Didn't think their was going to be so many complications. Thanks to you guys for working them through. If any tips please tell...

denjell
Posts: 25
Joined: Sun Feb 10, 2013 4:00 pm

Re: seamless looping

Mon Feb 25, 2013 2:56 pm

@Brendanflynn:

You will have a problem syncing unless your videos are EXACTLY the same length (hh:mm:ss:ff) and you use EXACTLY the same hardware with the same image and patch and SD Card from the same manufacturer with the same speed.

After you get them set up with the script I gave you, turn them on at the exact same time (i.e. with a power strip that has an on/off switch.) Even then, you will probably notice some type of frame dropping sooner or later...

Good luck.

Brendanflynn
Posts: 5
Joined: Sun Feb 24, 2013 8:08 pm

Re: seamless looping

Mon Feb 25, 2013 3:04 pm

That's fine. Never mentioned syncing, I just need them playing. They will do that right? I just ordered two Raspberries today. Model B 512mb. I should get them looping a video on vga screens. Know in theory how to get them running on vga. Thought from here I would have answers to looping the video? Don't need to synce, just need to play on loop.

denjell
Posts: 25
Joined: Sun Feb 10, 2013 4:00 pm

Re: seamless looping

Mon Feb 25, 2013 3:56 pm

sure - they'll play and loop, just follow the instructions here:
http://www.raspberrypi.org/phpBB3/viewt ... 37#p285237

(and use an HDMI -> vga adapter)

and feel free to PM me if you have any specific problems.
good luck.

Brendanflynn
Posts: 5
Joined: Sun Feb 24, 2013 8:08 pm

Re: seamless looping

Mon Feb 25, 2013 4:06 pm

Tanx a lot,

That's all I need and yea will get adapter. Have found setup for it, needs some hacking in config file. Still should work so happy days. Lets hope I can follow the above instructions ok. Still need to flash sd cards :) so lots to do. :) thanks again.

colbyparsons
Posts: 22
Joined: Fri Jan 27, 2012 7:42 pm

Re: seamless looping

Mon Feb 25, 2013 4:16 pm

Brendan,

You have two options for looping from this forum:

1. a looping method with sound but a slight break -- I haven't tried this one, but it was recently posted (by denjell I think), and sounds like a great option for showing regular video that has a beginning and an end. If you do a fade in and fade out, the break should be no problem.

2. a seamless looping method with no sound -- this is one that I got my son's help (and others) to figure out for my own artwork, because I sometimes need the video to be perfectly seamless, with no hesitation at all at the break. The downside is that we never figured out how to add sound, and since I didn't need it, we stopped trying. We have also not managed to update it to work with anything past the Squeeze version of Linux Debian, so you would need to download the one from 6-13-2012. I can provide more info if this is the solution you need. I have just in the past week or so had to re-familiarize myself with the process because I have shows coming up where I will need to have 8 projectors run by 8 pi's. I finally figured out how to get everything set up on one SD card and then duplicate it. That requires two identical cards by the way because they need to have the same exact number of data blocks available -- which in practice is hard to be sure of unless you get two of the same brand, same speed, same capacity, same everything. Sure was nice not to have to do the whole setup 8 times!

If you are using audio, you should know that the headphone jack originally had a clicking problem -- I think they might have done a hardware fix on the latest models that fixed the issue but haven't really followed that. HDMI has been a more reliable way to get sound through though, but then obviously you would need equipment that lets you take advantage of that, such as a projector with audio out.

Just out of curiosity, where are you graduating from?

--Colby

Brendanflynn
Posts: 5
Joined: Sun Feb 24, 2013 8:08 pm

Re: seamless looping

Mon Feb 25, 2013 4:50 pm

Tanxs Colby,

I am finishing up in Cluain Mhuire in G.M.I.T. I haven't figured sound or no sound yet. All depends on the scape of the room. Also where is your exhibition send me a link would be nice to know.

monnte
Posts: 8
Joined: Fri Mar 08, 2013 9:11 pm

Re: seamless looping

Fri Mar 08, 2013 9:32 pm

Good work Daniel !!!
could someone make full image file and post it ?

denjell
Posts: 25
Joined: Sun Feb 10, 2013 4:00 pm

Re: seamless looping

Mon Mar 11, 2013 4:44 pm

the idea behind the patch is that you don't need a full image and can just patch your existing raspbian...

monnte
Posts: 8
Joined: Fri Mar 08, 2013 9:11 pm

Re: seamless looping

Wed Mar 13, 2013 10:54 pm

Any ideas tryid it 3 times ?

[email protected] ~ $ sudo bash /home/pi/autoloop-patch.sh /home/pi/movie.mp4
update-rc.d: using dependency based boot sequencing
insserv: warning: script 'K01startup.sh' missing LSB tags and overrides
insserv: warning: script 'startup.sh' missing LSB tags and overrides
/etc/init.d/startup created and initialized
/home/pi/omx-loop.sh created
chmod: invalid mode: `755 '
Try `chmod --help' for more information.
it seems we got this far.
Restart System Now? (y/n)
/home/pi/autoloop-patch.sh: line 168: $'\302\240': command not found
[email protected] ~ $

denjell
Posts: 25
Joined: Sun Feb 10, 2013 4:00 pm

Re: seamless looping

Sun Mar 17, 2013 6:37 pm

first of all, chmod 755 IS a valid mode.
secondly, $'\302\240' is another name for nbsp (non-breaking space) -> which tells me you got some kind of problem with your encoding, you probably are not using UTF-8...


see my next post.
Last edited by denjell on Tue Mar 19, 2013 11:20 am, edited 1 time in total.

georgealex
Posts: 3
Joined: Mon Mar 18, 2013 11:16 pm

Re: seamless looping

Mon Mar 18, 2013 11:27 pm

Hi all, pretty new to this. I've created and run the script via Terminal, and been prompted to reboot. however after selecting Y I get the error below. Any thoughts?
seems to be the same or similar to above. I'm totally lost at this stage so any help would be greatly appreciated.
thanks!

[email protected] ~ $ nano /home/pi/autoloop-patch.sh
[email protected] ~ $ sudo bash /home/pi/autoloop-patch.sh /home/pi/movie.mp4
update-rc.d: using dependency based boot sequencing
insserv: warning: script 'K01startup.sh' missing LSB tags and overrides
insserv: warning: script 'startup.sh' missing LSB tags and overrides
/etc/init.d/startup created and initialized
/home/pi/omx-loop.sh created
chmod: invalid mode: `755 '
Try `chmod --help' for more information.
it seems we got this far.
Restart System Now? (y/n) y
/home/pi/autoloop-patch.sh: line 104: $'\302\240': command not found
/home/pi/autoloop-patch.sh: line 105: $'\302\240': command not found
/home/pi/autoloop-patch.sh: line 107: $'\302\240': command not found
/home/pi/autoloop-patch.sh: line 116: syntax error near unexpected token `start'
/home/pi/autoloop-patch.sh: line 116: ` start)'

denjell
Posts: 25
Joined: Sun Feb 10, 2013 4:00 pm

Re: seamless looping

Mon Mar 18, 2013 11:56 pm

i just checked and it seems that somehow a corruption appeared in line 70.

let me know if this works:

Code: Select all

#!bin/sh
# autoloop-patch.sh

# autoloop patch for raspbian
# v.0.1
# Raspberry Pi Forum User denjell
# http://www.raspberrypi.org/phpBB3/memberlist.php?mode=viewprofile&u=56730

# copyleft 2013 / no guarantees of fitness for any purpose

# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


# READ THIS FIRST BEFORE RUNNING THE FILE!
# ----------------------------------------

# this script creates 2 files on your system and modifies /etc/inittab.
# 1) /etc/init.d/startup
# 2) /home/{user}/autoloop.sh
# 3) /etc/inittab

# it assumes general knowledge of stuff like debian and media files / codecs
# it should work on most raspians, however I recommend a clean image.

# Step0: follow the instructions here to make your RPi distro:
# http://elinux.org/RPi_Easy_SD_Card_Setup
# choose medium overclocking
# do not activate the window manager (ie only command line interface)

# Step1: place this script in your /home/%user folder (on the Rpi)
# type: (without the quotes)
# "nano /home/pi/autoloop-patch.sh"
# copy this script with ctl-c
# paste it in into the nano editor with shift-ctl-v
# save it with ctl-x

# Step2: place your media file in /home/pi or whatever:
# e.g. /home/pi/movie.mp4
# it must be h264 video and PCM 16bit signed little endian audio stream

# Step3: type (without the quotes and use your user name instead of pi):
# "sudo bash /home/pi/autoloop-patch.sh /home/pi/movie.mp4"
# you can run this script anytime you want a new film to loop
# it will re-run the setup and restart your RPi.

# Step4: how to exit the loop.
# http://en.wikipedia.org/wiki/Magic_SysRq_key

# This works for me. However, I cannot guarantee it will work for you.
# I do not manage a help desk, and this patch is provided "as is".
# Good luck. Have fun. Do stuff.

#find the user
user=${PWD##*/}
file=$1

# create the startup script
echo "#! /bin/sh

case '$1' in
  start)
    sudo bash /home/"${user}"/omx-loop.sh "${file}" >/dev/null 2>&1
    ;;
esac

exit 0" > /etc/init.d/startup.sh
sudo chmod 755 /etc/init.d/startup.sh
sudo update-rc.d startup.sh defaults
echo "/etc/init.d/startup created and initialized"


echo "#!/bin/sh

SERVICE='omxplayer'
	while true; do
		setterm -blank off -powerdown off > /dev/tty0
		clear > /dev/tty0
		setterm -cursor off > /dev/tty0
		echo;echo;echo;echo;echo;echo;
		clear > /dev/tty0

		if ps ax | grep -v grep | grep \$SERVICE > /dev/null
			then
				echo; # sleep 1
			else
				echo;echo;echo;echo;echo;echo;
				omxplayer -o hdmi \$1 & > /dev/null
				clear > /dev/tty0

		fi
	done" > /home/${user}/omx-loop.sh
echo "/home/pi/omx-loop.sh created"
sudo chmod 755  /home/${user}/omx-loop.sh

# remove the old inittab
sudo rm /etc/inittab

# write a new inittab
sudo echo "
# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $
# modified by denjell

# The default runlevel.
id:2:initdefault: 

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
# z6:6:respawn:/sbin/sulogin

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop

# 1:2345:respawn:/sbin/getty --noclear 38400 tty1 
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

#Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100" > '/etc/inittab'

echo "it seems we got this far."

read -p "Restart System Now? (y/n) " RESP
if [ "$RESP" = "y" ]; then

	echo "Restarting."
	sudo reboot
fi 
   echo "You must restart your system to initialize autostarting autoloop."

georgealex
Posts: 3
Joined: Mon Mar 18, 2013 11:16 pm

Re: seamless looping

Tue Mar 19, 2013 1:11 am

Hi, thanks for that. just tried it - I'm now getting this however?
As I said I have very limited knowledge about what I'm doing so can't really even to begin to figure out the error.

Code: Select all

[email protected] ~ $ sudo bash /home/pi/autoloop-patch.sh /home/pi/movie.mp4
update-rc.d: using dependency based boot sequencing
insserv: warning: script 'K01startup.sh' missing LSB tags and overrides
insserv: warning: script 'startup.sh' missing LSB tags and overrides
/etc/init.d/startup created and initialized
/home/pi/omx-loop.sh created
chmod: invalid mode: `755 '
Try `chmod --help' for more information.
it seems we got this far.
Restart System Now? (y/n) y
/home/pi/autoloop-patch.sh: line 104: $'\302\240': command not found
/home/pi/autoloop-patch.sh: line 105: $'\302\240': command not found
/home/pi/autoloop-patch.sh: line 107: $'\302\240': command not found

denjell wrote:i just checked and it seems that somehow a corruption appeared in line 70.

let me know if this works:

Code: Select all

#!bin/sh
# autoloop-patch.sh

# autoloop patch for raspbian
# v.0.1
# Raspberry Pi Forum User denjell
# http://www.raspberrypi.org/phpBB3/memberlist.php?mode=viewprofile&u=56730

# copyleft 2013 / no guarantees of fitness for any purpose

# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


# READ THIS FIRST BEFORE RUNNING THE FILE!
# ----------------------------------------

# this script creates 2 files on your system and modifies /etc/inittab.
# 1) /etc/init.d/startup
# 2) /home/{user}/autoloop.sh
# 3) /etc/inittab

# it assumes general knowledge of stuff like debian and media files / codecs
# it should work on most raspians, however I recommend a clean image.

# Step0: follow the instructions here to make your RPi distro:
# http://elinux.org/RPi_Easy_SD_Card_Setup
# choose medium overclocking
# do not activate the window manager (ie only command line interface)

# Step1: place this script in your /home/%user folder (on the Rpi)
# type: (without the quotes)
# "nano /home/pi/autoloop-patch.sh"
# copy this script with ctl-c
# paste it in into the nano editor with shift-ctl-v
# save it with ctl-x

# Step2: place your media file in /home/pi or whatever:
# e.g. /home/pi/movie.mp4
# it must be h264 video and PCM 16bit signed little endian audio stream

# Step3: type (without the quotes and use your user name instead of pi):
# "sudo bash /home/pi/autoloop-patch.sh /home/pi/movie.mp4"
# you can run this script anytime you want a new film to loop
# it will re-run the setup and restart your RPi.

# Step4: how to exit the loop.
# http://en.wikipedia.org/wiki/Magic_SysRq_key

# This works for me. However, I cannot guarantee it will work for you.
# I do not manage a help desk, and this patch is provided "as is".
# Good luck. Have fun. Do stuff.

#find the user
user=${PWD##*/}
file=$1

# create the startup script
echo "#! /bin/sh

case '$1' in
  start)
    sudo bash /home/"${user}"/omx-loop.sh "${file}" >/dev/null 2>&1
    ;;
esac

exit 0" > /etc/init.d/startup.sh
sudo chmod 755 /etc/init.d/startup.sh
sudo update-rc.d startup.sh defaults
echo "/etc/init.d/startup created and initialized"


echo "#!/bin/sh

SERVICE='omxplayer'
	while true; do
		setterm -blank off -powerdown off > /dev/tty0
		clear > /dev/tty0
		setterm -cursor off > /dev/tty0
		echo;echo;echo;echo;echo;echo;
		clear > /dev/tty0

		if ps ax | grep -v grep | grep \$SERVICE > /dev/null
			then
				echo; # sleep 1
			else
				echo;echo;echo;echo;echo;echo;
				omxplayer -o hdmi \$1 & > /dev/null
				clear > /dev/tty0

		fi
	done" > /home/${user}/omx-loop.sh
echo "/home/pi/omx-loop.sh created"
sudo chmod 755  /home/${user}/omx-loop.sh

# remove the old inittab
sudo rm /etc/inittab

# write a new inittab
sudo echo "
# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $
# modified by denjell

# The default runlevel.
id:2:initdefault: 

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
# z6:6:respawn:/sbin/sulogin

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop

# 1:2345:respawn:/sbin/getty --noclear 38400 tty1 
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

#Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100" > '/etc/inittab'

echo "it seems we got this far."

read -p "Restart System Now? (y/n) " RESP
if [ "$RESP" = "y" ]; then

	echo "Restarting."
	sudo reboot
fi 
   echo "You must restart your system to initialize autostarting autoloop."

monnte
Posts: 8
Joined: Fri Mar 08, 2013 9:11 pm

Re: seamless looping

Tue Mar 19, 2013 8:24 am

Hello again, It is good Daniel that you treid doing something nice for us , but not everyone has to know the code to do some player from Raspberry pi, finally I found a soliution which is so nice to use , and it has Image slideshow option plus Video , and web. the app is called http://www.screenlyapp.com/
I`m ready know for buying 10 raspberrys for our gallery, as we where looking with what small to change normal pc coimputers for Video looping in our gallery ...
Thanks ScreenlyApp ;)

denjell
Posts: 25
Joined: Sun Feb 10, 2013 4:00 pm

Re: seamless looping

Tue Mar 19, 2013 10:45 am

Raspberry Pi is a great way to "get your feet wet" in the world of programming. Indeed, that is why it was developed - to offer the public a low-cost alternative to learning programming and using embedded computing. As an artist and curator myself, I appreciate the low cost and flexibility that RPi offers. Of course it comes with a steep learning curve, and those not familiar with anything other than GUI interfaces are likely to get frustrated quickly.

So whatever happens, don't give up and please keep us informed about your experience with screenly, ok?

denjell
Posts: 25
Joined: Sun Feb 10, 2013 4:00 pm

Re: seamless looping

Tue Mar 19, 2013 11:39 am

i am a little confused... are you using the december 2012 raspian? here is one last "correction"...

Code: Select all

#!/bin/bash
# autoloop-patch.sh

# autoloop patch for raspbian
# v.0.2
# Raspberry Pi Forum User denjell
# http://www.raspberrypi.org/phpBB3/memberlist.php?mode=viewprofile&u=56730

# copyleft 2013 / no guarantees of fitness for any purpose

# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


# READ THIS FIRST BEFORE RUNNING THE FILE!
# ----------------------------------------

# this script creates 2 files on your system and modifies /etc/inittab.
# 1) /etc/init.d/startup
# 2) /home/{user}/autoloop.sh
# 3) /etc/inittab

# it assumes general knowledge of stuff like debian and media files / codecs
# it should work on most raspians, however I recommend a clean image.

# Step0: follow the instructions here to make your RPi distro:
# http://elinux.org/RPi_Easy_SD_Card_Setup
# choose medium overclocking
# do not activate the window manager (ie only command line interface)

# Step1: place this script in your /home/%user folder (on the Rpi)
# type: (without the quotes)
# "nano /home/pi/autoloop-patch.sh"
# copy this script with ctl-c
# paste it in into the nano editor with shift-ctl-v
# save it with ctl-x

# Step2: place your media file in /home/pi or whatever:
# e.g. /home/pi/movie.mp4
# it must be h264 video and PCM 16bit signed little endian audio stream

# Step3: type (without the quotes and use your user name instead of pi):
# "sudo bash /home/pi/autoloop-patch.sh /home/pi/movie.mp4"
# you can run this script anytime you want a new film to loop
# it will re-run the setup and restart your RPi.

# Step4: how to exit the loop.
# http://en.wikipedia.org/wiki/Magic_SysRq_key

# This works for me. However, I cannot guarantee it will work for you.
# I do not manage a help desk, and this patch is provided "as is".
# Good luck. Have fun. Do stuff.

#find the user
user=${PWD##*/}
file=$1

# create the startup script
sudo echo "#!/bin/sh

case \$1 in
  start)
    sudo bash /home/"${user}"/omx-loop.sh "${file}" >/dev/null 2>&1
    ;;
esac

exit 0" > /etc/init.d/startup.sh
sudo chmod 755 /etc/init.d/startup.sh
sudo update-rc.d startup.sh defaults -nn
echo "/etc/init.d/startup created and initialized"


echo "#!/bin/sh

SERVICE='omxplayer'
   while true; do
      setterm -blank off -powerdown off > /dev/tty0
      clear > /dev/tty0
      setterm -cursor off > /dev/tty0
      echo;echo;echo;echo;echo;echo;
      clear > /dev/tty0

      if ps ax | grep -v grep | grep \$SERVICE > /dev/null
         then
            echo; # sleep 1
         else
            echo;echo;echo;echo;echo;echo;
            omxplayer -o hdmi \$1 & > /dev/null
            clear > /dev/tty0

      fi
   done" > /home/${user}/omx-loop.sh
echo "/home/pi/omx-loop.sh created"
sudo chmod 755  /home/${user}/omx-loop.sh

# remove the old inittab
sudo rm /etc/inittab

# write a new inittab
sudo echo "
# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $
# modified by denjell

# The default runlevel.
id:2:initdefault: 

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
# z6:6:respawn:/sbin/sulogin

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop

# 1:2345:respawn:/sbin/getty --noclear 38400 tty1 
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

#Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100" > '/etc/inittab'

echo "it seems we got this far."

read -p "Restart System Now? (y/n) " RESP
if [ "$RESP" = "y" ]; then
   echo "Restarting."
   sudo reboot
fi 
   echo "You must restart your system to initialize autostarting autoloop."

monnte
Posts: 8
Joined: Fri Mar 08, 2013 9:11 pm

Re: seamless looping

Tue Mar 19, 2013 5:31 pm

I hope it is gone work, i have istalled it only on one raspbian, tomorow i hope to get the other ordered, and exibition will start at friday , so i will test 7 Raspberry pis as Players for video looping, i hope raspberry can take two months non stop playing, as i see now it is easy to use, but had to restart once, to upload video file , seems the app get stuck sometimes, but after plug in plug of the power it started to work, the nice thing is that you are controling the app From Web , so it is posble to hide it somethere, and control it remotely.
And does it work smooth with your script, did you hade any problems, some stuck video or something ? How long you are using it ?

denjell
Posts: 25
Joined: Sun Feb 10, 2013 4:00 pm

Re: seamless looping

Tue Mar 19, 2013 5:40 pm

no - no stuck video. and once it ran it just ran... the installation went for 19 days straight. when the show closed in the evenings we actually just turned off the video projector and amp and left the RPi running. the nice thing about these kind of scripts is that if you lose power, as soon as the RPi gets power back it will autostart. good luck.

artboxalex
Posts: 1
Joined: Sun Mar 24, 2013 6:07 am

Re: seamless looping

Sun Mar 24, 2013 6:25 am

denjell wrote:no - no stuck video. and once it ran it just ran... the installation went for 19 days straight. when the show closed in the evenings we actually just turned off the video projector and amp and left the RPi running. the nice thing about these kind of scripts is that if you lose power, as soon as the RPi gets power back it will autostart. good luck.
I am running Denjell's script as a test and it works as promised, no freezing issues, etc. I wish it handled playback seamlessly (with no gap between loops), if it did... then it would be perfect IMHO.

Thank you Denjell for sharing that script.
--
Artbox - technology that meets art's requirements
www.artbox.net.au

monnte
Posts: 8
Joined: Fri Mar 08, 2013 9:11 pm

Re: seamless looping

Tue Mar 26, 2013 2:38 pm

Hi all of ya,
The same problem with the updated script , chmode invalid , and the same errors,
Where can i get the 2012.12 version of raspbian to try , i`m trying with latest version , maybe thats the diference ?

Return to “Graphics, sound and multimedia”