Showing webcam feeds


19 posts
by rfindlater » Tue Feb 12, 2013 4:45 pm
Hi folks,

I'm using a Raspberry Pi (for the first time!) for a university project. I want to have an online webcam feed (one from a zoo/wildlife park to be specific) constantly streaming to my Pi where it will be shown on an attached LED/LCD screen. What would be the best way to do this?
Posts: 9
Joined: Tue Feb 12, 2013 4:26 pm
by audioscience » Sat Feb 16, 2013 1:42 am
If you only need to view a webcam feed then you just have to load up the cam feed through a web browser like Midori, just as you would on any other computer.
Posts: 9
Joined: Sat Jan 19, 2013 9:45 pm
by shuckle » Sat Feb 16, 2013 6:39 am
For me midori did not work. It crashed after 10 minutes or so. I am now using icewiesel and it works There is small memory leak as swap page usage grows slowly.
I can only get 1 fps for the other camera and 2 fps from the other. Cpu usage is about 90% all the time. So this is not easy to do.
Posts: 445
Joined: Sun Aug 26, 2012 11:49 am
by ghans » Sat Feb 16, 2013 8:20 am
The latest omxplayer has MJPEG acceleration :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=63&t=33473#p286956

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Posts: 4755
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by BerryPicker » Tue Feb 19, 2013 11:23 am
ghans wrote:The latest omxplayer has MJPEG acceleration

Having set a server to stream MJPEG from a webcam with MJPG-streamer, on the same pi (different terminal) I tried
omxplayer http://raspberrypi:8080/?action=stream
but it did not show a picture.
Is there a particular option, resolution or framerate needed to make omxplayer show the webcam picture?
Posts: 128
Joined: Tue Oct 16, 2012 3:03 pm
Location: The East of England
by ghans » Tue Feb 19, 2013 11:35 am
Check the linked thread.


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Posts: 4755
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by rfindlater » Wed Feb 20, 2013 7:29 pm
ghans, will omxplayer play a flash video? The webcam feeds I want to use require Adobe flash player; I've looked into using Gnash but have heard it’s slow and doesn't support accelerated video.

I've also looked into the thread you linked me to; do I need to know the file format(s) to use those examples?

If it helps I'm planning on using feeds from one of the following websites:
http://www.sdzsafaripark.org/video/elephant_cam.html
http://www.savethemanatee.org/savethemanateecam.html
Posts: 9
Joined: Tue Feb 12, 2013 4:26 pm
by SN » Wed Feb 20, 2013 9:09 pm
Do you really want a live videostream? I use a update-every-5-seconds still approach and have no problems and haven't for over 100 days
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?
User avatar
Posts: 1008
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
by ghans » Wed Feb 20, 2013 9:55 pm
if you can get the underlying "real" video stream , rtmpdump might be of great use.


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Posts: 4755
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by rfindlater » Thu Feb 21, 2013 4:03 pm
SN, I definitely want a live videostream - my aim for the uni project is to give the impression of the animal being there. If it wasn't such an essential part of my project I definitely would have considered that approach though!

ghans; by the “real” video stream do you mean the ‘main’ hosting site (such as camzone for the elephant feed) or the actual data feed that goes to this site?
I’ve also had a brief look into rtmpdump; am I right in thinking that by “piping” it to omxplayer I’d effectively be able to play it without flash or any significant lag?
Posts: 9
Joined: Tue Feb 12, 2013 4:26 pm
by ghans » Fri Feb 22, 2013 1:00 pm
I have not investigated further.
Your piping approach seems workable.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Posts: 4755
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by rfindlater » Sat Feb 23, 2013 12:48 pm
I had a go at using rtmp to pipe the video to omxplayer but still seem to be having issues. I entered the following command(s):

Code: Select all
mkfifo /tmp/mystdin
Rtmpdump –r rtmp://cdn.livestream.com/embed/savethemanateecam –o /tmp/mystdin | omxplayer –o /tmp/mystdin

Upon entering this the screen goes black aside from the omxplayer options and scroll bar. The following error message also appears:

"ERROR: RTMP_Connect0, failed to connect socket. 110 (Connection timed out)"

I'm pretty sure I have the right URL as before I would get a message saying that I needed to specify one. Does anyone have any ideas what I'm doing wrong?

EDIT: I'm running RTMPdump v2.4, if that helps.
Posts: 9
Joined: Tue Feb 12, 2013 4:26 pm
by rfindlater » Sat Feb 23, 2013 4:37 pm
Excuse the double post - I couldn't edit my previous one. I doubt that the cause could be an issue with my Wi-fi dongle as I have switched it from the USB hub to one of the Pi's USB sockets to no avail - trying in the command interface also hasn't helped. I know for a fact that my Pi is connected to the internet as I have downloaded updates and rtmp with no issues whatsoever.

I will try again on my home internet connection (I am currently working on my university one) and see if there is any difference - I doubt there will be considering I'm having no other internet issues. Will adding another command help?
Posts: 9
Joined: Tue Feb 12, 2013 4:26 pm
by rfindlater » Mon Feb 25, 2013 11:45 am
Since my last post I've found that Livestream (the host for one of the webcam feeds) doesn't support rtmp. It's a real shame - it sounded like it would have been perfect for the job otherwise. I would try the other webcam but I haven't heard any response about permission yet.

I'll do some searching for ways of playing .swf files through the Pi.
Posts: 9
Joined: Tue Feb 12, 2013 4:26 pm
by rfindlater » Wed Feb 27, 2013 3:32 pm
Through a bit of hacking the HTML for the source (https://cdn.livestream.com/grid/LSPlaye ... manateecam) one of my coursemates has managed to find an mp4 and m3u8 file (which would solve all the issues I’m having with getting the swf file to play in my browser). How can I get an “absolute” URL from this?

http://xsavethemanateecamx.api.channel. ... aylist.mp4
http://xsavethemanateecamx.api.channel. ... ylist.m3u8
Posts: 9
Joined: Tue Feb 12, 2013 4:26 pm
by ghans » Sun Mar 03, 2013 5:57 pm
Both links give a 404 for me.
Are they dynamic or using some kind of auth / useragent check ?


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Posts: 4755
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by rfindlater » Mon Mar 04, 2013 4:14 pm
I got 404s for those too; my coursemate thinks they are dynamic but I don't really know myself. Regardless I decided to switch over to another feed which worked well with rtmp - I'll leave the information up for anyone interested in trying to work around the incompatibility Livestream has with rtmpdump. Thanks for all of your help!
Posts: 9
Joined: Tue Feb 12, 2013 4:26 pm
by ghans » Tue Mar 05, 2013 8:06 am
Thank you for that. Perhaps the wiki would be a good place for it ?

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Posts: 4755
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by rfindlater » Mon Apr 01, 2013 3:55 pm
ghans, I'll keep that in mind - I've got another issue to resolve in the meantime though!

As my project will be exhibited at both my degree show and an exhibition I decided to download the webcam feeds and play them in a matter that seems live, allowing me to circumvent any issues with internet connections or broken cameras. I am using RFID tags to switch between two webcam feeds through a Python script; the starting point of the videos are determined by how long the script has been running.

For some reason my script only plays the videos with a delay when done through the Python interface; using the start-up command line to call the script always plays the videos from the beginning. Am I using commands or functions that don't work with the start-up command line? What else could be the cause of this?

Code: Select all
#!/usr/bin/env python
# Allows script to run by itself
# RFID webcam viewer written by Rory Findlater

from subprocess import Popen, PIPE, STDOUT, call # imports needed modules
import time
import math
prog_start = time.clock
pipe = open(‘/dev/ttyUSB0’,’r’) # opens a pipe for USB to read

while 1: # loops until initial stream selected
    if “4” in pipe.read(1): # looks in pipe for value in RFID code
        call([‘clear’, ‘>’, ‘/dev/tty1’]) # clears screen so no text shows during video transition
        Playtembe = Popen([‘omxplayer’, ‘/home/pi/Tembe.mp4’], stdout=PIPE, stdin=PIPE, stderr=PIPE)
        Playtembe0N = 1
        break
        # Turn Tembe on

    elif “7” in pipe.read(1):
        call([‘clear’, ‘>’, ‘/dev/tty1’])
        Playidube =  Popen([‘omxplayer’, ‘/home/pi/Idube.mp4’], stdout=PIPE, stdin=PIPE, stderr=PIPE)
        PlayidubeON = 1
        break
        # Turn Idube on

while 1: # loop for selecting streams
        if “4” in pipe.read(1) and PlayidubeON == 1:
            Playidube.communicate(input=’q’)[0]
            PlayidubeON = 0
            # Turn Idube off

            CurrentTimeRaw = time.clock() – prog_start
            CurrentTime3 = CurrentTimeRaw / 3
            Current Time = str(math.cell(CurrentTime3 *100))

            call([‘clear’, ‘>’, ‘/dev/tty1’])
            Playtembe = Popen([‘omxplayer’, ‘/home/pi/Tembe.mp4’], stdout=PIPE, stdin=PIPE, stderr=PIPE)
            Playtembe0N = 1
            # Turn Tembe on

        elif “7” in pipe.read(1) and PlaytembeON == 1:
            Playtembe.communicate(input=’q’)[0]
            PlaytembeON = 0
            # Turn Tembe off

            CurrentTimeRaw = time.clock() – prog_start
            CurrentTime3 = CurrentTimeRaw / 3
            Current Time = str(math.cell(CurrentTime3 *100))

            call([‘clear’, ‘>’, ‘/dev/tty1’])
            PlayIdube = Popen([‘omxplayer’, ‘/home/pi/Idube.mp4’], stdout=PIPE, stdin=PIPE, stderr=PIPE)
            PlayIdube0N = 1
            # Turn Idube on


Posts: 9
Joined: Tue Feb 12, 2013 4:26 pm