Geal
Posts: 7
Joined: Mon Sep 03, 2012 2:00 pm

Re: seamless looping

Mon Sep 03, 2012 7:12 pm

NO WAIT!
Raspbmc

Been though so many I'm lost.

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

Re: seamless looping

Mon Sep 03, 2012 7:33 pm

Geal wrote:Soft float debian "wheezy"

Sorry if I look like a total noob, first time using linux. Well out of my depth on this one.

If I'm appearing to NOT be a noob, that's smoke and mirrors, I assure you. I only started to use linux to get this one problem solved, and got my son who knows some programming to do the heavy lifting even then. We haven't solved the issues that came up with the most recent version, so if you really need this looping code to work, you will need to look up the "squeeze" Debian distro from back in June. I'm continuing to use that until someone offers a solution for what is going wrong with the code. If you need specifics on the date and name of that distro, I think I might have included it a few posts back, but I wouldn't mind looking it up for you.

--Colby

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

Re: seamless looping

Tue Sep 04, 2012 3:06 pm

@colby, I too would be interested in this approach. I'm working on something to what you describe. When you add the seamless_video.sh script to the startup it does start up rather quickly and repeats. As was mentioned though, you can't break out of it. I also need to run some GPIO setup conditions and was working with wiringPi. I've upgraded the firmware to enable handling interrupts and that works fine.

The big problem that I have now is that I can't get anything else to run if seamless_video is running. If I try to create another thread in my GPIO C program to run video.bin I get a segmentation fault.

Do you think I could edit video.c to add in my GPIO commands without breaking it?

gsawkins
Posts: 1
Joined: Mon Oct 15, 2012 4:47 pm

Re: seamless looping

Mon Oct 15, 2012 4:51 pm

how does this work with 2 or 3 videos ? it there a break in loading next video

gmint
Posts: 1
Joined: Fri Oct 19, 2012 2:20 am

Re: seamless looping

Fri Oct 19, 2012 2:27 am

[quote= colbyparsons]Regarding a GUI, what I posted above is a simple solution in part because it is the first one we were able to come up with that actually did what we wanted, and also because it is meant to be as hands-off as possible so that someone who knows nothing at all about how to work with a Pi can plug it in and it will run. It has to be that way so that the videos I make can be installed in galleries. Even if the person running the gallery was fine with navigating a GUI ever day when they turned on the lights, inevitably something would happen that would make the GUI show and viewers would be looking at the GUI instead of the artwork -- like if the power went out and back on, or an intern forgot to get the video going for a while.
[/quote]

I absolutely, positively agree with everything you've said EXCEPT for the part about this being a small market. I think the potential for the Pi as a digital signage tool is huge. I've used AppleTVs in the past (still in service, actually) and I just got around to deploying my first Pi the other night. I haven't even gotten around to setting it up to auto-play a movie (just using XBMC for the time being) but if there ever was a tool for this job, the Pi is it.

The only thing I would add to your feature list would be something like automatic Dropbox support. I'd love to be able to just upload a video to dropbox, have the Pi download (not stream) it to the card and automatically play it. That would be heaven.

0_nvd_0
Posts: 29
Joined: Sun Oct 14, 2012 10:12 pm

Re: seamless looping

Thu Nov 15, 2012 5:16 pm

roblegge wrote:Unfortunately putting the code into the /etc/init.d folder to auto run on start up doesn't work. Can anyone help? The code itself runs ok when fired up manually.

Code: Select all

crontab -e
Add an entry:

Code: Select all

@reboot run-video
Make sure that the script "run-video" is executable "chmod +x run-video" and is in the "/bin" folder.
Add your commands to the script.

MTIA
Rob

renan
Posts: 4
Joined: Thu Nov 22, 2012 12:28 am

Re: seamless looping

Thu Nov 22, 2012 12:44 am

Hello,

I just have downloaded the new version of Raspbian “wheezy” (2012-10-28-wheezy-raspbian.zip.torrent), wrote the SD, boot it, and tried to compile the video.c, but its generate an error.

After the first login I did the commands:

cd /opt/vc/src/hello_pi/hello_video/
make

It just return a lot of lines and one error at the end.
I did the change from "break;" to "fseek(in, 0, SEEK_SET);" and it did not compile as well.

Anybody tried to compile it in this new version?
Is missing some step that I have not seen?

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5708
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: seamless looping

Thu Nov 22, 2012 11:22 am

You can build all the hello_pi apps with:

Code: Select all

cd /opt/vc/src/hello_pi/
./rebuild.sh

renan
Posts: 4
Joined: Thu Nov 22, 2012 12:28 am

Re: seamless looping

Sat Nov 24, 2012 12:07 am

Yes, it works! Tanks.

renan
Posts: 4
Joined: Thu Nov 22, 2012 12:28 am

Re: seamless looping

Sat Nov 24, 2012 11:46 am

I can't play any video, just the test.h264 demo.

I have downloaded several full HD demos from internet, all of them H.264 codec in conteiner mp4, mkv, m2ts. All videos I have tested plays well in omxplayer, but not in hello_video.bin. Some video start to play but just a lot of big pixels, blurred.

I found in this forum that the video should be in .h264, but I dont know if it is about the container or the codec.

I make a copy of the test.h264 demo and tried to play it in windows. It just dont recognize the format. No program can play it, even a video converter I have that recognize all formats could not read this file.

What kind of file, codec and container are you playing in hello_video.bin?

skeeballassault
Posts: 8
Joined: Thu Jun 28, 2012 5:43 pm

Re: seamless looping

Sat Nov 24, 2012 10:36 pm

Hey renan,

To get videos to play back with hello_video.bin, I use YAMB. It rips the video out of its container, allowing it to be played back using hello_video.bin.

Just extract the video stream, and that should be in a .h264 format.

Enjoy,
Skeeballassault

renan
Posts: 4
Joined: Thu Nov 22, 2012 12:28 am

Re: seamless looping

Tue Nov 27, 2012 12:19 am

That's it!

Tanks skeeballassault.

mkunes
Posts: 3
Joined: Thu Nov 29, 2012 4:26 pm

Re: seamless looping

Thu Nov 29, 2012 5:27 pm

I am in the same boat, have done hardly any linux programming and have found this quite difficult. I am turning an old plasma into a coal effect fire. The heat it gives off is almost the same as an electric fire and its only worth £40 on ebay, so not such a waste as may seem at first.

I found that if you go up a level of directory (from where the video.c file is), there is a readme file which tells you that you have to use the 'make' command on some libraries - I didn't see anybody mention that here. So if you edit the video.c file as instructed without doing the make thing in the directory above afterwards - nothing works. Anyhow I eventually got the test.h264 looping nicely - amazed at the quality of the video as I am using the composite input (plasma is from 2003 so no hdmi input). But I cant get my fire.h264 video running yet. I used Yamb to split my m2ts file taken from my panasonic HD camcorder and it is same resolution as the test file. When I put them both in Yamb test.h264 says AVC- Advanced Video Codec- Main@4.1-1920x1080 and my fire.h264 says AVC-Advanced Video Codec- High@L4.0 -1920 x 1080. So it looks like I need to convert my file in a slightly different way to get Main@4.1 instead of High@4.0 - anybody got a clue what this means or how I can acheive it? I am using 2012-10-28-wheezy-raspbian.img. Thank you for your patience.

mkunes
Posts: 3
Joined: Thu Nov 29, 2012 4:26 pm

Re: seamless looping

Fri Nov 30, 2012 1:12 pm

Panic almost over. I downloaded an h264 converter from Videolan at this link:- http://www.videolan.org/developers/x264.html and used the settings for Xbox with quality medium and unticked the cropping box (the croppinng worked as well but overfilled the screen).

During the first try it paused and installed AVsyth as well. Although it seems to output an MP4 file, there is a folder in your target directory called temporary files . In there is a file with XXXXXXX-output.h264. This is the file which works if you copy it to the hello_video folder.

Stranegly enough when I look at it in YAMB it still has the same file description as before so it seems it was nothing to do with the high/main thing as stated in my previous post.

I should emphasise that I don't know what I am doing at all (I don't think 'Newbie' suits an old geezer like me - how about 'Alzy') - I am from the day when you typed your lines of code into a machine which punched holes in a card and then you put this in another machine that typed out what you just punched in, called a verifyer I think. There was a huge bin next to this as the chances of you typing a line without a mistake were pretty small. When you had a stack of cards you thought were ok, down 11 floors and across the quad you stood in a queue and fed them into a machine which seemed to pull them through at incredible speed. Bit I guess the data transfer rate was a few hundred bytes per second at most. Then you waited in another queue for your print out, only to find that you had exceeded your memory allocation of 2 kilo bytes. Mind you it was quicker than using that vi editor :lol:

mkunes
Posts: 3
Joined: Thu Nov 29, 2012 4:26 pm

Re: seamless looping

Sat Dec 01, 2012 4:34 pm

Sorry I didn't spot that someone earlier had given the solution to the problem of having to rebuild the files first :oops: I finally got it looping with my own .h264 file on bootup. I also couldnt get it working by placing the .sh file in the init.d folder (2012-10-28-wheezy-raspbian.img). I used the crontab -e solution given above. I dont fully understand paths yet, so after a number of false starts, I gave the full path to the file in crontab, my entry was:-

@reboot /opt/vc/src/hello_pi/hello_video/hello_video.bin Fire4.h264

All that remains is to find a spare 5V rail in the back of the plasma to power the Pi.

rulevu
Posts: 1
Joined: Sun Dec 02, 2012 6:54 pm

Re: seamless looping

Sun Dec 02, 2012 7:05 pm

Colby, thank you for the great post :)
somebody find the solution to loop video with audio ?

r.

skeeballassault
Posts: 8
Joined: Thu Jun 28, 2012 5:43 pm

Re: seamless looping

Mon Dec 03, 2012 3:46 am

Hey rulevu,

I haven't tried it at the moment, but I'd assume you could use the audio half of the video as an MP3, and play it back with MPG123, using the --loop -1 option.

I'm sure it's a simple matter to set up a script to do so. I'll make one myself, and get back to you on that.

Cheers,
Skeeball

dwingus
Posts: 1
Joined: Mon Dec 03, 2012 4:33 am

Re: seamless looping

Mon Dec 03, 2012 4:49 am

Thanks everyone for the really helpful information. I too would be really interested in getting video and audio to seamlessly loop using hello_video

I've spent a few days figuring out the right conversion format for my video files so that they are raw H264 and thus playable in hello_video. however, it seems I can only get movies without an audio channel to convert correctly using ffmpegx on OS X -- i using the "h.264 mencoder" option in the ffmpegx presets. when i choose a movie that does not have an audio channel (remove it via QTPlayer for example) then I can get a raw ".264" file output that will work fine with hello_video. but if I try the same thing with a movie that has an audio channel then it always comes out of ffmpegx as a ".mp4" file. even if I tell ffmpegx to not encode audio. seems really strange . . anyway, that's more of an encoder issue but if anyone has a solution i'd love to know about it.

so . . i'm assuming that there is not currently an option for any type of media file that has both video and audio encoded together that will work with hello_video. Is that true? is raw H264 video only? if so, is there a way to sync (and loop) an external mp3, wav, etc . . file to play along with the raw H264? has anyone out there been able to take a hi-res video file that has video and audio and successfully loop the video using hello_video via HDMI? if so, it would be great to find out how you were able to do so. many thanks to all . . cheers

skeeballassault
Posts: 8
Joined: Thu Jun 28, 2012 5:43 pm

Re: seamless looping

Mon Dec 03, 2012 8:32 pm

Hey dwingus,

No, I don't think there will ever be a solution for playing video and audio from the same file on hello_video. However, I am currently trying to make a proper script which allows an mp3 (your sound) to be played behind your video. I'll post it when I've got it down, unless anyone else finds a better way.

Cheers,
Skeeball

sajal147
Posts: 12
Joined: Mon Dec 03, 2012 3:45 pm
Location: Mumbai

Re: seamless looping

Tue Dec 11, 2012 11:38 am

GeorgeIoak wrote:@colby, I too would be interested in this approach. I'm working on something to what you describe. When you add the seamless_video.sh script to the startup it does start up rather quickly and repeats. As was mentioned though, you can't break out of it. I also need to run some GPIO setup conditions and was working with wiringPi. I've upgraded the firmware to enable handling interrupts and that works fine.

The big problem that I have now is that I can't get anything else to run if seamless_video is running. If I try to create another thread in my GPIO C program to run video.bin I get a segmentation fault.

Do you think I could edit video.c to add in my GPIO commands without breaking it?
Hi,
I am working on the similar lines. So, I wanted to know if you were able to
1. Break out of the hello_video program on boot up ? how ?
2. Interface GPIO with hello_video program ?
I am planning to use PIR sensor to toggle between videos. Please let me know the process, if you were successful in executing it.
Thanks,

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

Re: seamless looping

Tue Dec 11, 2012 1:26 pm

Once it's running the only way I found to stop it was to open another terminal window and then kill the process or ssh in and kill the process.

Controlling from the GPIO pins is just like any other program control. I'm not at my RPi now but I'm sure an internet search will return what you're looking for. Search for how to get the process ID of the hello_video and store that in a variable. Once you have that you can use it to kill the program when something happens on a GPIO pin and then you just add logic to start the program again if you want.

ericdaigh
Posts: 9
Joined: Sat Jan 12, 2013 2:07 pm

Re: seamless looping

Sat Jan 12, 2013 2:10 pm

I'm wondering if something similar (the seamlessness being the elusive part) can be done within omxplayer. It's far more codec friendly, and would be great to not have to re-encode everything for hello_video. Anyone?

ericdaigh
Posts: 9
Joined: Sat Jan 12, 2013 2:07 pm

Re: seamless looping

Tue Jan 15, 2013 10:01 pm

Colby, Dom, anyone:

This other related thread (http://www.raspberrypi.org/phpBB3/viewt ... 34#p261334) looks promising as a way of sending something to hello_video (to stop the video is what i need) but it doesn't compile for me. I get an error about stray /240 and stray /302. I couldn't be more green at this code, but if someone is able to get this to work, it would be great.

What I'm trying to do is get Colby's innovation to start, via cron, and be able to stop the loop with something in a script, so that i can play another (different) video, also with hello_video.

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

Re: seamless looping

Tue Jan 15, 2013 11:49 pm

I'll have to dig into the code I wrote but basically what I ended up doing was when I launched the hello_video with the first video I captured the PID and then used that to kill the process and start the next video.

Not sure if this is what I ended up with but this is what I used to start the video and also how I captured the PID. You can use something like this to start and stop with different videos.

Code: Select all

#!/bin/sh
# /etc/init.d/seamless_video.sh
#
### BEGIN INIT INFO
# Provides:  seamless_video.sh
# Required-Start:
# Required-Stop:
# Default-Start:  2 3 4 5
# Default-Stop:  0 1 6
# Short-Description: video looper
# Description:
#
### END INIT INFO

export USER='pi'

case "$1" in

  start)
   echo "\nstart"
   cd /home/pi
   ./videoloop.bin /home/pi/video/* &
   ;;

  stop)
   echo "Stopping Video"
   VIDEO_PID=`ps auxwww | grep videoloop.bin | head -1 | awk '{print $2}'`
   kill -9 $VIDEO_PID
   echo "done\n"
   ;;

  *)
   exit 1
   ;;

esac
exit 0

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

Re: seamless looping

Sun Feb 10, 2013 4:49 pm

i am an art exhibition engineer and needed to use the RPi to loop a 1080p audio/video installation. it had to be idiot-proof - i.e. autostart (on powerup), the sound had to be synced and it was not permissible to display any type of logging. sounds trivial, and it is. here is what iu did:

0) during install set the RPi to medium overclocking and no xwindow
1) turn on autologin http://elinux.org/RPi_Debian_Auto_Login
2) on logged in state call autolooping script via /etc/init.d while dumping console to /dev/null
3) run autolooping script with rpi console workarounds
4) plug and play

caveat1: unless you don't care about audio sync, the audio needs to be PCM 16bit signed little endian - which ffmpeg has problems with. we ended up just using a finalcut mp4 x264 export because it can make the right format. as soon as i have worked out an ffmpeg solution, i will post it here.
caveat2: unless you don't care about the loud popping of audio at file begin and end, you need to route the audio through the hdmi and output it from there. luckily the projector we use can decode the audio and route it out to the amplifier.
caveat3: we faded the video to and from black to bridge the time between reloading the file. although this isn't "seamless", no one noticed the 800ms
caveat4: there is no "normal" way to end the process. during debugging the worst thing you can do is simply pull the power - which is why i would like to remind you of: http://en.wikipedia.org/wiki/Magic_SysRq_key

if there is interest, i can post the scripts i used.

Return to “Graphics, sound and multimedia”