klant
Posts: 19
Joined: Mon Sep 24, 2012 8:29 pm
Location: Sweden

RTSP from a IP camera

Mon Sep 24, 2012 8:53 pm

I´m pretty new to RPI and linux...

Me Idea is to use the RPI to decode video live from a IP camera. It seems like the best way to have this done is by RTSP. I have tried the omxplayer but I doesn't get it to work but I got video in mplayer but then the video lag and I guess it because the mplayer doesn't use hw accelerating.

How can I get omxplayer to work with RTSP streams or maby there's a better program to use?

ghans
Posts: 7893
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: RTSP from a IP camera

Tue Sep 25, 2012 9:50 am

I think you can use mplayer to dump that stream to a named pipe
and then have omxplayer read from it.

Works very good with real CSS'ed DVDs and should be a good solution for streams
too.

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

klant
Posts: 19
Joined: Mon Sep 24, 2012 8:29 pm
Location: Sweden

Re: RTSP from a IP camera

Tue Sep 25, 2012 11:04 am

I read something about this as well. But like I sayed I'm new to linux and I will try to google it, but if you know a good guide how to set it up please let me know :D

Thanks for the tips

Will report if I get it to work...

klant
Posts: 19
Joined: Mon Sep 24, 2012 8:29 pm
Location: Sweden

Re: RTSP from a IP camera

Tue Sep 25, 2012 11:20 am

I found some good info but i get this:


pi@raspberrypi ~ $ sudo mplayer rtsp://10.158.224.8/stream1 -dumpstream -dumpfile /home/pi/Desktop/test.asf
MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing rtsp://10.158.224.8/stream1.
Connecting to server 10.158.224.8[10.158.224.8]: 554...

rtsp_session: unsupported RTSP server. Server type is 'unknown'.
STREAM_LIVE555, URL: rtsp://10.158.224.8/stream1
Stream not seekable!
Stream not seekable!
dump: 0 bytes written to '/home/pi/Desktop/test.asf'.
Core dumped ;)

Exiting... (End of file)


Any idees?

klant
Posts: 19
Joined: Mon Sep 24, 2012 8:29 pm
Location: Sweden

Re: RTSP from a IP camera

Wed Sep 26, 2012 9:42 am

I tested this:


pi@raspberrypi ~ $ sudo mplayer -dumpvideo rtsp://10.158.224.6/stream1 dumpfile /home/pi/Desktop/test.mkv
MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing rtsp://10.158.224.6/stream1.
Connecting to server 10.158.224.6[10.158.224.6]: 554...

rtsp_session: unsupported RTSP server. Server type is 'unknown'.
STREAM_LIVE555, URL: rtsp://10.158.224.6/stream1
Stream not seekable!
file format detected.
Initiated "video/H264" RTP subsession on port 46562
demux_rtp: Guessed the video frame rate as 15 frames-per-second.
(If this is wrong, use the "-fps <frame-rate>" option instead.)
VIDEO: [H264] 0x0 0bpp 15.000 fps 0.0 kbps ( 0.0 kbyte/s)
dump: 29491015 bytes written

It starts to dump but I get no file om the desktop, may by same one can help me know?

klant
Posts: 19
Joined: Mon Sep 24, 2012 8:29 pm
Location: Sweden

Re: RTSP from a IP camera

Wed Sep 26, 2012 10:11 am

Hi I found the dump of the video and it worked to play in omxplayer. Now the trouble is that the file dump getting larger and larger there no end to the stream becourse it from a camera...

What to do?

ghans
Posts: 7893
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: RTSP from a IP camera

Wed Sep 26, 2012 10:45 am

Try CTRL-C or do

Code: Select all

pidof mplayer
and then use the resulting number with

Code: Select all

kill insertyournumberhere
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

klant
Posts: 19
Joined: Mon Sep 24, 2012 8:29 pm
Location: Sweden

Re: RTSP from a IP camera

Wed Sep 26, 2012 2:55 pm

I don't want to kill the mplayer, I want the file to be max 50mb or soo.

I'm not interested in having aloot of recorded material just the live video feed.

veijo
Posts: 2
Joined: Tue Dec 27, 2011 3:32 pm

Re: RTSP from a IP camera

Wed Sep 26, 2012 8:13 pm

Try using a named pipe instead of a regular file. You can create the pipe using

Code: Select all

mknod ~/stream1.mkv p
Then use the pipe as the output for mplayer and as the input for omxplayer.

klant
Posts: 19
Joined: Mon Sep 24, 2012 8:29 pm
Location: Sweden

Re: RTSP from a IP camera

Thu Sep 27, 2012 12:58 pm

It worked fine! Thanx for the help:)

If anyone like to test this then do like this:

1. Install mplayer

Code: Select all

sudo apt-get install mplayer
2. Install omxplayer

Code: Select all

sudo apt-get install omxplayer
3. Make a pipe

Code: Select all

mknod /home/pi/stream1.mkv p
4. Start dumping the rtsp stream using mplayer

Code: Select all

sudo mplayer -dumpvideo rtsp://ipnumber/stream -dumpfile /home/pi/stream1.mkv
5. Start the omxplayer and display video

Code: Select all

sudo omxplayer /home/pi/stream1.mkv

dekopi
Posts: 1
Joined: Mon Oct 08, 2012 7:30 am

Re: RTSP from a IP camera

Mon Oct 08, 2012 7:56 am

Thanks for this, I was looking for this also. :D

The first 2 starts I got his message and after 4 or 5 seconds it stopped

Code: Select all

pi@raspberrypi ~ $ sudo mplayer -dumpvideo rtsp://192.168.1.98/deko-high.sdp -dumpfile /home/pi/dekostream.mkv 
MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing rtsp://192.168.1.98/deko-high.sdp.
Connecting to server 172.22.1.98[172.22.1.98]: 554...

A single media stream only is supported atm.
rtsp_session: unsupported RTSP server. Server type is 'unknown'.
STREAM_LIVE555, URL: rtsp://192.168.1.98/deko-high.sdp
Stream not seekable!
 file format detected.
Initiated "video/H264" RTP subsession on port 51766
Initiated "audio/G726-32" RTP subsession on port 43472
demux_rtp: Failed to guess the video frame rate
Unknown MPlayer format code for MIME type "audio/G726-32"
VIDEO:  [H264]  0x0  0bpp  0.000 fps    0.0 kbps ( 0.0 kbyte/s)
dump: 255963 bytes written
dump: 5100862 bytes written to '/home/pi/dekostream.mkv'.
Core dumped ;)

Exiting... (End of file)
Now I want to put this code in a bash file, to start this stream with the start of the raspberry pi.

Has someone an idea how to check if the process is still working and if not that it automatically restarts?

larsadehlin
Posts: 1
Joined: Sat Feb 02, 2013 10:09 pm
Location: Sweden

Re: RTSP from a IP camera

Sat Feb 02, 2013 10:40 pm

I've worked as a computer programmer for almost 10 years but switched career 8 years ago. Now I work within the security sector but lately I've been missing the mental challenge of software development. So, this afternoon I sat down and pondered - is there a way to fetch a stream from an ip camera to a computer screen without using a full sized computer. Sure, after a few hours of surfing I realize there is a few commercial alternatives, most of them as expensive as full sized video server. Not quite what I was looking for.

Out walking the dog I started to spec what I needed. A small computer, preferably Linux based, 10/100 ethernet access, something that doesn't generate excess heat, that's small (i.e. could be hidden) and can put video on a standard screen.

Back home I googled and found the Raspberry Pi. A few searches later I found this forum and then this topic. After reading klants posts I realise that he and I probably have the same idea. Now I'm considering buying a set ;)
Modo Fac

ff35
Posts: 2
Joined: Mon Feb 04, 2013 12:54 pm

Re: RTSP from a IP camera

Mon Feb 04, 2013 12:57 pm

Dear klant,

Thank you for the solution. I have applied the steps you gave and it works. But there is a great latency around 5 seconds. I have tried to reduce the buffer size of mplayer with -cache option, but it didn't work. Do you know what can I do to decrease the latency?

Thanks in advance,
Fikret

Stemby
Posts: 6
Joined: Wed Mar 20, 2013 5:55 am

Re: RTSP from a IP camera

Wed Mar 20, 2013 6:08 am

@ff35:
It seems OMXPlayer supports RTSP natively now:

https://github.com/huceke/omxplayer/issues/67

So I think you no longer have to dump your stream with MPlayer.

Could you test it, please? How much latency do you get in average?

Thank you!

klant
Posts: 19
Joined: Mon Sep 24, 2012 8:29 pm
Location: Sweden

Re: RTSP from a IP camera

Wed Mar 20, 2013 7:52 am

Thats correct, it supports rtsp direct now. The latency is a problem... If I have a 1080p stream it's about 4-8sec delay:/ I can't get less, soo if anyone else can please let me know.

Stemby
Posts: 6
Joined: Wed Mar 20, 2013 5:55 am

Re: RTSP from a IP camera

Wed Mar 20, 2013 5:48 pm

klant wrote:The latency is a problem... If I have a 1080p stream it's about 4-8sec delay:/
:shock:

Damn, with this latency I have to find another solution.
if anyone else can please let me know.
+1

Thank you for your statement.

jstokes5
Posts: 14
Joined: Wed Mar 27, 2013 2:30 am

Re: RTSP from a IP camera

Sun May 19, 2013 2:41 am

Can someone help a newly awakened RPI enthusiast? I'm excited that omxplayer supports rtsp:// but have little idea of how to get it to work.

I would love an example of an omxplayer command that points to an IP camera with a user and password.

I've tried....
omxplayer -o hdmi rtsp://192.168.0.104:888/user="admin"&pwd="mypassword"

but all I get is the raspian commandline telling me that the service is running. No video.

What's wrong?

klant
Posts: 19
Joined: Mon Sep 24, 2012 8:29 pm
Location: Sweden

Re: RTSP from a IP camera

Sun May 19, 2013 9:34 am

Have you video in vlc when you try rtsp://192.168.0.104:888/user="admin"&pwd="mypassword"

Fells like the port 888 is wrong... With camera model are you using?

jstokes5
Posts: 14
Joined: Wed Mar 27, 2013 2:30 am

Re: RTSP from a IP camera

Wed May 22, 2013 12:10 pm

Foscam Fi9821w.

I'm still stuck. They say the latest revision of omxplayer can work directly with a h.264 stream but I can't get it right. It runs but doesn't render the video. The screen still just shows the raspian commandline interface.

jstokes5
Posts: 14
Joined: Wed Mar 27, 2013 2:30 am

Re: RTSP from a IP camera

Wed May 22, 2013 12:12 pm

The port is arbitrary. I set it to 1004 and 2345 on the camera and tried a few other things and it didn't help. I'm at a loss. I might go back to the idea of using mplayer to make a dump file and playing it from that with omxplayer.

klant
Posts: 19
Joined: Mon Sep 24, 2012 8:29 pm
Location: Sweden

Re: RTSP from a IP camera

Wed May 22, 2013 12:16 pm

When for exampel Pelco use the 554 port for RTSP there is where the communication is but the video is sent on a radom port at something like 3700-3900 so if you get the video working in vlc then you sould be able to get the video in omxplayer. What kind brand are the camera?

jstokes5
Posts: 14
Joined: Wed Mar 27, 2013 2:30 am

Re: RTSP from a IP camera

Wed May 22, 2013 12:35 pm

Foscam Fi9821w

klant
Posts: 19
Joined: Mon Sep 24, 2012 8:29 pm
Location: Sweden

Re: RTSP from a IP camera

Wed May 22, 2013 1:18 pm


jstokes5
Posts: 14
Joined: Wed Mar 27, 2013 2:30 am

Re: RTSP from a IP camera

Sun Jun 02, 2013 10:05 am

I got it working. The Foscam Fi9821W wanted the URL with the user and pwd embedded. The whole command looks like this:

sudo omxplayer -o hdmi rtsp://<user>:<pwd>@192.168.0.102:88/videoMain

Run as root | App | Audio to hdmi | Real time streaming protocol | Camera login | IP address | Port | Stream

Note that the port number is the http port not the media port - my biggest mistake. It works well but lags behind the camera by (4 to 8 seconds).

Other people have the same problem. If anyone has an idea on how to reduce the lag, please reply.

pem
Posts: 13
Joined: Wed Oct 16, 2013 7:26 am

Re: RTSP from a IP camera

Tue Jun 03, 2014 10:18 am

Hello you can use the live option with omxplayer like

Code: Select all

omxplayer -o hdmi --live rtsp://user:passwd@adress/flux
but you just reduce the latency from 10s (or more) to 2s (or 1.5s).
I've tried to reduce it with the buffer size but it-s don't work because omxplayer wait to full the buffer before play the video..
If anyone have a solution to use raspy for real time video player for rtsp flux I'll be very grateful :)

Return to “General discussion”