Raspberry PI MJPEG stream to RCA (playing mjpeg stream!)


27 posts   Page 1 of 2   1, 2
by Xapepam » Tue Feb 12, 2013 8:32 pm
Hi guys! A lot of information about streaming with raspberry pi. But no information about PLAYING mjpeg, h264 stream!

Is it possible? Im trying in firefox (iceweasel) but its no use slowwww..

My idea: use raspberry to convert mjpeg stream from camera to DVR (rca out).
Its a simply: one cam, one stream, one play stream to rca video out.

How to play mjpeg stream(link example: http://tra-lalaa=stream&main) on raspberry pi with GPU accelerated?

Thanks.
Posts: 19
Joined: Tue Feb 12, 2013 6:15 am
by SirLagz » Wed Feb 13, 2013 2:49 am
vlc can play a stream. direct from the source too !
e.g /dev/video0
don't know about speed though
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044
Posts: 1704
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
by Xapepam » Wed Feb 13, 2013 5:22 am
No. /dev/video0 - is wrong.

Camera streaming from lan.

NO Usb camera directly attached to raspberry pi!

I have trying do this with VLC. Its working! But 0-1 fps in one minute! Its awesome slowwww!
Posts: 19
Joined: Tue Feb 12, 2013 6:15 am
by ghans » Wed Feb 13, 2013 7:07 am
You can try omxplayer , but MJPEG is one of the many
unaccelerated codecs (currently) ... AFAIK.


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: 4393
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by Xapepam » Wed Feb 13, 2013 8:10 am
http://www.cnx-software.com/tag/omxplayer/ - guy in this page written experimental method to plaing mjpeg files on omxplayer with mjpeg encoding.

Its works! Very fast work!

But on localy storage files.(via sdcard: sdb1/home/tra-la-la.MOV)

How Omxplayer get stream from web? Example: "omxplayer -o hdmi http://some IP/stream&mjpeg=main" - as browser? Is it possible?
Posts: 19
Joined: Tue Feb 12, 2013 6:15 am
by ghans » Wed Feb 13, 2013 8:37 am
Use mplayer to dump it to a named pipe , and
have omxplayer read from that.

Very neat find BTW , i wasn't aware of those experimental
omxplayer features.

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: 4393
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by Xapepam » Wed Feb 13, 2013 9:22 am
Use mplayer to dump it to a named pipe , and
have omxplayer read from that.
- please take me more detail. Im noob.
Posts: 19
Joined: Tue Feb 12, 2013 6:15 am
by Xapepam » Wed Feb 13, 2013 10:24 am
sudo mplayer -dumpvideo rtsp://ipnumber/stream -dumpfile /home/pi/stream1.mkv

No rtsp stream.. Im tell about simply http stream. A lot of camera make this simply stream, and have a link Example: http://213.110.198.66:555/aV6NQZzB?cont ... tream=main

How this to play? (Not in browser! Is not usable, very slow on PI)
Posts: 19
Joined: Tue Feb 12, 2013 6:15 am
by ghans » Wed Feb 13, 2013 10:58 am
Try this :

Code: Select all
mkfifo  /tmp/streampipe
mplayer  http://www.example.com/path?container=mjpeg&stream=main -dumpstream -dumpfile /tmp/streampipe 1>null 2>null &
omxplayer -r /tmp/streampipe


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: 4393
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by Xapepam » Wed Feb 13, 2013 11:58 am
mplayer http://www.example.com/path?container=mjpeg&stream=main -dumpstream -dumpfile /tmp/streampipe 1>null 2>null &

System answer:
mplayer: could not connect to socket
mplayer: No such file or directory
Posts: 19
Joined: Tue Feb 12, 2013 6:15 am
by ghans » Wed Feb 13, 2013 1:31 pm
Try this instead :

Code: Select all
mkfifo /tmp/stream.mjpeg
wget -O /tmp/stream.mjpeg http://213.110.198.66:555/aV6NQZzB?container=mjpeg&stream=main
omxplayer -r /tmp/stream.mjpeg


I gave an example URL , you had to subsitute it for a real one !


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: 4393
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by Xapepam » Wed Feb 13, 2013 1:42 pm
Did you execute all the commands i posted exactly
the same way ?


yes of course!


The mplayer url is a example URL ,
you have to subsitute it for a real one !


Im reading and undestand code. Also im undestand what im do. Im used working link, check before link in firefox browser on PC x86, after that im tested this link on raspberry pi..

mkfifo /tmp/stream.mjpeg
wget -O /tmp/stream.mjpeg http://213.110.198.66:555/aV6NQZzB?cont ... tream=main
omxplayer -r /tmp/stream.mjpeg


Genius!
But not work.
Wget start non stop downloading to file, but omxplayer cant view content of file..

Wait a minute! Idea!.
Posts: 19
Joined: Tue Feb 12, 2013 6:15 am
by ghans » Wed Feb 13, 2013 2:05 pm
Try appending

Code: Select all
&> /dev/null &


to the wget command.

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: 4393
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by Xapepam » Wed Feb 13, 2013 3:18 pm
ghans, this is great! Your last idea is WORKED!

Im see mjpeg stream from omxplayer!

Thank you very match!

But, Wget non-stop downloading file, and file in tmp has become bigger and bigger. How resolve this? Any idea?

P.S. Im so stupid!
Add &> /dev/null & - tadam! File in tmp = 0 kb ever! GREAT WORK! THANK YOU!

P.P.S. Guys! Who read this post for resolve mjpeg stream view. This http://www.cnx-software.com/tag/omxplayer/ - needed. Without this omxplayer dont undestand mjpeg stream!
Posts: 19
Joined: Tue Feb 12, 2013 6:15 am
by Xapepam » Wed Feb 13, 2013 5:16 pm
Total, step-by-step to view mjpeg stream.

Do this (here is detailed: http://www.cnx-software.com/tag/omxplayer/):

wget https://github.com/Hexxeh/rpi-update/ra ... rpi-update
chmod 755 rpi-update
sudo ./rpi-update

Add the following two lines to /boot/config.txt:

start_file=start_x.elf
fixup_file=fixup_x.elf

Install precompilled omxplayer with mjpeg support:

cd /
tar xzvf omxplayer-dist.tar.gz
cd omxplayer-dist
sudo cp * / -rf

Distr link: http://ubuntuone.com/77X6Mr23tdS2orm16tbzj4

Make this:

mkfifo /tmp/stream.mjpeg
wget -O /tmp/stream.mjpeg 'http://213.110.198.66:555/aV6NQZzB?container=mjpeg&stream=main' &> /dev/null &
omxplayer -r /tmp/stream.mjpeg

Go!

Im add in system autostart script. After im switch on raspberry last strings make automatics.

cd home
nano start_stream.sh

mkfifo /tmp/stream.mjpeg
wget -O /tmp/stream.mjpeg 'http://some_ip:some port/aV6NQZzB?container=mjpeg&stream=main' &> /dev/null &
omxplayer -r /tmp/stream.mjpeg

ctrl+O, ctrl+x

And put to rc.local
sh /home/start_stream.sh
Posts: 19
Joined: Tue Feb 12, 2013 6:15 am
by dom » Wed Feb 13, 2013 5:36 pm
Xapepam wrote:Total, step-by-step to view mjpeg stream.

Couple of simplifications:

Xapepam wrote:Do this (here is detailed: http://www.cnx-software.com/tag/omxplayer/):

wget https://github.com/Hexxeh/rpi-update/ra ... rpi-update
chmod 755 rpi-update
sudo ./rpi-update

Code: Select all
sudo apt-get update && sudo apt-get upgrade

has been updated recently, and gets firmware with MJPEG support

Xapepam wrote:Add the following two lines to /boot/config.txt:

start_file=start_x.elf
fixup_file=fixup_x.elf

while you need this for VP6/VP7/Theora, MPJEG support is included with default start.elf image.

Xapepam wrote:Install precompilled omxplayer with mjpeg support:

cd /
tar xzvf omxplayer-dist.tar.gz
cd omxplayer-dist
sudo cp * / -rf

Distr link: http://ubuntuone.com/77X6Mr23tdS2orm16tbzj4

The previous apt-get upgrade will have updated omxplayer to a version that supports MJPEG.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3997
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by Xapepam » Wed Feb 13, 2013 6:41 pm
Dom, thank you. All variants worked, but your little shortest and rightest :)
Posts: 19
Joined: Tue Feb 12, 2013 6:15 am
by Xapepam » Sun Feb 17, 2013 7:30 pm
Guys, again Im with little problem.

One stupid question: If stream will work with cgi auth, how to get it?

Example 1: wget -O /tmp/stream.mjpeg 'http://213.110.198.66:555/aV6NQZzB?container=mjpeg&stream=main' - this link work well.

Example 2: wget -O /tmp/stream.mjpeg 'http://some_IP:some_port/cgi-bin/CGIProxy.fcgi?usr=username&pwd=password&cmd=GetMJStream ' - this will not work.. :(

What command will help me in Example 2?

Thanks!
Posts: 19
Joined: Tue Feb 12, 2013 6:15 am
by ghans » Sun Feb 17, 2013 8:01 pm
That could be anything ... try changing the user-agent.

man wget should tell how.

Any googled Mozilla user-agent should work.

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: 4393
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by Xapepam » Sun Feb 17, 2013 10:54 pm
Im very noob :)

But im finded solution:

curl -s -o /tmp/stream.mjpeg 'http://http://some_ip/cgi-bin/CGIStream.cgi?cmd=GetMJStream&usr=username&pwd=password' &> /dev/null &

Works well! Thanks!
Posts: 19
Joined: Tue Feb 12, 2013 6:15 am
by Xapepam » Tue Feb 26, 2013 12:26 pm
I continue this subject..

Guys.
This works great,

Code: Select all
mkfifo /tmp/stream.mjpeg
wget -O /tmp/stream.mjpeg 'http://[u]SOME_IP[/u]:555/aV6NQZzB?container=mjpeg&stream=main' &> /dev/null &
omxplayer -r /tmp/stream.mjpeg


but if the link isn't available to downloading any more - omxplayer totaly hangs. Screen is totaly freeze.

Im put this code to rc.local and autostart streaming every boot. But im dont know how restart streaming after link is up, without manual reboot. (If needed i agree to automatic reboot.)

I need automaticaly start stream after link is down some times without my promt or ssh coonect. Please help. Thanks!

P.S. Ok. Im use wget timeout and win in this battle. Thanks all!
Posts: 19
Joined: Tue Feb 12, 2013 6:15 am
by alphyddan » Sun May 12, 2013 7:44 pm
omxplayer worked fine with mjpeg streaming from a network camera. Good performance in terms of images per second but I wonder why there is a 5 seconds lag? Is there some buffer that I should reduce?
Thanks.
Posts: 1
Joined: Sun May 12, 2013 7:40 pm
by Citroenboom » Mon Jun 10, 2013 12:02 pm
I've tried the method with:

> mkfifo test.fifo
> wget -O test.fifo http://example.com/stream.mp4 &
> omxplayer test.fifo

It works as expected. However, I ran into the following problem (or at least I think this causes my problem):

if the wget command terminates before omxplayer finishes playing the stream, omxplayer will instantly exit with "Have a nice day", probably thinking the stream is done.

Any ideas how to evade this problem?
Posts: 1
Joined: Mon Jun 10, 2013 11:59 am
by ghans » Mon Jun 10, 2013 4:45 pm
As a stream should never end , check if wget dies and restart it -
you can use a shell script for that.

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: 4393
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by fridamme » Thu Sep 05, 2013 1:58 pm
Hello all

I'm a pretty Newbie but very interested in this Topic. What is the actual Best way to use the Raspberry PI as player for an mjpeg stream?
And which OS do i have to use?

I tried different ways with raspian and also with RaspXBMC, but it didn't work out very well.
Thank you very much for your support!
Posts: 2
Joined: Thu Sep 05, 2013 1:46 pm