micpi
Posts: 6
Joined: Wed Jun 12, 2013 9:36 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sat Jul 20, 2013 8:52 am

Some strange behavior I could not understand and also found no answer.

I already installed crtmpserver, rebuild ffmpeg. Camera module works fine. Crtmpserver have same settings described here in flyplayback.
So I start stream into crtmpserver with :

Code: Select all

raspivid -t 9999999 -w 960 -h 540 -fps 25 -b 500000 -vf -o - | ffmpeg -i - -vcodec copy -an -r 25 -f flv -metadata streamName=myStream tcp://0.0.0.0:6666
This also works fine. After all I want to see the cam on Win7 with flv-media-player on Win7 and use the rtnp adress:

rtmp://10.0.0.213/flvplayback/flv:myStream.flv
(raspi is on 10.0.0.213)

I only get black screen. Thats all. When I take a look into the log No "file" found ?

Thanks for a hint.

Here is also the log part:
8272:3:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/protocols/liveflv/inboundliveflvprotocol.cpp:184:SignalInputData:Stream metadata:
<MAP name="" isArray="true">
<MAP name="__index__value__0" isArray="true">
<DOUBLE name="duration">0.000</DOUBLE>
<STR name="encoder">Lavf55.12.102</STR>
<DOUBLE name="filesize">0.000</DOUBLE>
<DOUBLE name="framerate">25.000</DOUBLE>
<DOUBLE name="height">540.000</DOUBLE>
<STR name="streamName">myStream</STR>
<DOUBLE name="videocodecid">7.000</DOUBLE>
<DOUBLE name="videodatarate">0.000</DOUBLE>
<DOUBLE name="width">960.000</DOUBLE>
</MAP>
</MAP>
1374308272:6:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/protocols/liveflv/innetliveflvstream.cpp:246:InitializeVideoCapabilities:Cached the h264 video codec initialization: 36
1374308319:3:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/netio/epoll/tcpacceptor.cpp:154:Accept:Client connected: 10.0.0.63:47086 -> 0.0.0.0:1935
1374308319:4:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/netio/epoll/iohandlermanager.cpp:100:RegisterIOHandler:Handlers count changed: 8->9 IOHT_TCP_CARRIER
1374308319:6:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/applications/appselector/src/rtmpappprotocolhandler.cpp:81:ProcessInvokeConnect:Selected application: flvplayback
1374308319:6:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/application/baseclientapplication.cpp:216:UnRegisterProtocol:Protocol CTCP(12) <-> TCP(6) <-> [IR(7)] unregistered from application: appselector
1374308319:3:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/application/baseclientapplication.cpp:227:SignalStreamRegistered:Stream NR(5) with name `` registered to application `flvplayback` from protocol IR(7)
1374308319:3:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/application/baseclientapplication.cpp:238:SignalStreamUnRegistered:Stream NR(5) with name `` unregistered from application `flvplayback` from protocol IR(7)
1374308319:3:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/application/baseclientapplication.cpp:227:SignalStreamRegistered:Stream NR(6) with name `` registered to application `flvplayback` from protocol IR(7)
1374308319:3:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp:892:ProcessInvokePlay:Play request for stream name `flv:myStream.flv`. Start: -2; length: -1
1374308319:2:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp:1919:TryLinkToLiveStream:No live streams found: `flv:myStream.flv` or `flv:myStream.flv`
1374308319:0:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/protocols/rtmp/streaming/infilertmpstream.cpp:262:GetInstance:File not found. fullPath: ``
1374308319:0:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/protocols/rtmp/basertmpprotocol.cpp:505:CreateIFS:Unable to get file stream. Metadata:
<MAP name="" isArray="false">
<INT32 name="clientSideBuffer">30</INT32>
<BOOL name="externSeekGenerator">false</BOOL>
<STR name="fileName">myStream.flv</STR>
<STR name="fullPath"></STR>
<BOOL name="keyframeSeek">false</BOOL>
<STR name="mediaDir">/var/lib/crtmpserver/mediaFolder/</STR>
<BOOL name="renameBadFiles">false</BOOL>
<STR name="requestedStreamName">flv:myStream.flv</STR>
<MAP name="rtmpMeta" isArray="false">
<STR name="Server">C++ RTMP Server (http://www.rtmpd.com)</STR>
</MAP>
<UINT32 name="seekGranularity">0</UINT32>
<STR name="streamType">flv</STR>
</MAP>
1374308319:2:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp:1966:TryLinkToFileStream:No file streams found: flv:myStream.flv
1374308319:2:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp:919:ProcessInvokePlay:We are going to wait for the live stream `flv:myStream.flv`
1374308319:3:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/application/baseclientapplication.cpp:238:SignalStreamUnRegistered:Stream NR(6) with name `` unregistered from application `flvplayback` from protocol IR(7)
1374308319:3:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/application/baseclientapplication.cpp:227:SignalStreamRegistered:Stream ONR4R(7) with name `flv:myStream.flv` registered to application `flvplayback` from protocol IR(7)
1374308319:2:/build/crtmpserver-W2XmBu/crtmpserver-1.0~dfsg/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp:507:ProcessUsrCtrl:User control message type: RM_USRCTRL_TYPE_STREAM_SET_BUFFER_LENGTH

alexcroox
Posts: 18
Joined: Sun Jun 02, 2013 10:57 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sun Jul 21, 2013 5:30 pm

I can also confirm the 6 second delay, using the same setup and posting to the same server with a shitty £5 USB camera the delay is < 1 second. Perhaps piping raspvid to ffmpeg is causing the delay? Or limitations of the camera hardware?

Knightlorish
Posts: 23
Joined: Fri Jun 21, 2013 4:21 pm
Location: Northumberland, UK.

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Jul 22, 2013 4:07 pm

This works very nicely with a pc browser but since it's Flash video, it doesn't work with an iPad. I'm trying to get my head around the ffmpeg syntax to see whether it's simple enough to change the output stream to html5 or something else. Has anyone had any success with this?

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Jul 22, 2013 11:28 pm

Knightlorish wrote:This works very nicely with a pc browser but since it's Flash video, it doesn't work with an iPad. I'm trying to get my head around the ffmpeg syntax to see whether it's simple enough to change the output stream to html5 or something else. Has anyone had any success with this?
Look into nginx-rtmp. It works very well. Sub second delay for RTMP and few second delay for Apple HLS.

alexcroox
Posts: 18
Joined: Sun Jun 02, 2013 10:57 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Jul 22, 2013 11:33 pm

towolf can you confirm this is with a remote server? I can get a 1 second delay with crmtpserver and a cheap USB webcam streaming to JWplayer, but as soon as use the actual camera module with the same setup I can't get it below 3-6 second delay. It actually takes around 5/6 seconds to start the video feed with the module so I wonder if that has anything to do with it.

Also are there any instructions on how to install that patched raspvid file? I'm a little lost as to what to do with it :(

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Jul 22, 2013 11:42 pm

Yes, but I followed ppumkins advise to use strobemediaplayback flash player. He has clues here: http://pkula.blogspot.co.uk/2013/06/liv ... ry-pi.html

My setup differs somewhat but the gist is the same. Note that it has quite a high CPU load in my browser. Maybe it’s using smaller chunks or less buffering.

eggster
Posts: 15
Joined: Thu May 31, 2012 4:35 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Tue Jul 23, 2013 3:25 am

I cannot, for the life of me get this to work correctly. I've managed to troubleshoot it down to issues either with the Crtmpserver or jwplayer. Any clues how I can troubleshoot the two? I've tried to use rtmpdump, but even this doesn't work for me. FFMeg is able to dump to a flv file that vlc can open, so its not an ffmeg issue..

micpi
Posts: 6
Joined: Wed Jun 12, 2013 9:36 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Jul 24, 2013 9:20 am

I'm only able to get crtmpserver output running von playerjw and I think the prob ist following

Accessing with playerjw, the server logs:

<MAP name="" isArray="true">
<MAP name="__index__value__0" isArray="true">
<DOUBLE name="duration">0.000</DOUBLE>
<STR name="encoder">Lavf55.12.102</STR>
<DOUBLE name="filesize">0.000</DOUBLE>
<DOUBLE name="framerate">25.000</DOUBLE>
<DOUBLE name="height">540.000</DOUBLE>
<STR name="streamName">myStream</STR>
<DOUBLE name="videocodecid">7.000</DOUBLE>
<DOUBLE name="videodatarate">0.000</DOUBLE>
<DOUBLE name="width">960.000</DOUBLE>
</MAP>
</MAP>

Everthing is fine and you can see the "live" (with delay) in your browser.

Accesing with rtmpdump / or vnc produce following:

<MAP name="" isArray="false">
<INT32 name="clientSideBuffer">30</INT32>
<BOOL name="externSeekGenerator">false</BOOL>
<STR name="fileName">myStream.flv</STR>
<STR name="fullPath"></STR>
<BOOL name="keyframeSeek">false</BOOL>
<STR name="mediaDir">/var/lib/crtmpserver/mediaFolder/</STR>
<BOOL name="renameBadFiles">false</BOOL>
<STR name="requestedStreamName">myStream</STR>
<MAP name="rtmpMeta" isArray="false">
<STR name="Server">C++ RTMP Server (http://www.rtmpd.com)</STR>
</MAP>
<UINT32 name="seekGranularity">0</UINT32>
<STR name="streamType">flv</STR>
</MAP>

It seems that there is no metatag "streamName" to send from VLC or rtmpdump, so crtmpserver could not find the stream.

micpi
Posts: 6
Joined: Wed Jun 12, 2013 9:36 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Jul 24, 2013 10:51 am

Access with rtmpdump solved. I found this hint her https://groups.google.com/forum/#!msg/c ... 6vBR0UZXAJ.

There must be a "live" parameter set in the request, otherwise the crtmpserver search for file request.

So this will work with crtmpserver & rtmpdump:

Code: Select all

rtmpdump -r "rtmp://<your Rasp-IP>/flvplayback/myStream" --live -o foo.flv
Same with ffplay:

Code: Select all

ffplay -an "rtmp://<your Rasp-IP>/flvplayback/myStream live=1"
With this it is possible to see the video Stream AND record it for surveillance tasks.
Searching for a Outdoor Case for the Raspi+Cam? I found a Camera dummy for 8€ at ebay. With some mods the raspi annd camera module fits in the case. Hope to send later some pics.

Eljey
Posts: 1
Joined: Wed Jul 24, 2013 6:05 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Jul 24, 2013 6:23 pm

Have some one get this working with udp?

alexcroox
Posts: 18
Joined: Sun Jun 02, 2013 10:57 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Jul 24, 2013 9:20 pm

Fixed my 6 second lag issue by switching to strobemediaplayer. Amazing how a different client can make all the difference! (I was amazed when switching from flowplayer to JW player and now I'm amazed at the improvement again! Does it go deeper? :P)

eggster
Posts: 15
Joined: Thu May 31, 2012 4:35 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Jul 25, 2013 3:34 am

I finally got this working and can confirm jwplayer has a nasty 5-6 second delay whereas strobemediaplayer does not.

abgesoffen
Posts: 4
Joined: Thu Jul 25, 2013 7:50 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Jul 25, 2013 7:57 pm

thanks for this nice tutorial. i managed to set it up in about 20 minutes. however, what is not working is to access the streaming site from 'the outside'.

so if i access the stream from within the home network say

192.168.2.44/stream.html

it works just fine.

when i now configure my router to forward outside port 8080 to 80 at 192.168.2.44 and do

www.outsideaccess.com:8080/stream.html

the stream is not showing up.

can this be a problem of the low upload rate? i have about 1Mbit/s up. any idea?

btw: the log directory is now setup when apt-get install the streaming server.

thx
abgesoffen

abgesoffen
Posts: 4
Joined: Thu Jul 25, 2013 7:50 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Jul 25, 2013 7:58 pm

thanks for this nice tutorial. i managed to set it up in about 20 minutes. however, what is not working is to access the streaming site from 'the outside'.

so if i access the stream from within the home network say

192.168.2.44/stream.html

it works just fine.

when i now configure my router to forward outside port 8080 to 80 at 192.168.2.44 and do

http://www.outsideaccess.com:8080/stream.html

the stream is not showing up.

can this be a problem of the low upload rate? i have about 1Mbit/s up. any idea?

btw: the log directory is now setup when apt-get install the streaming server.

thx
abgesoffen

abgesoffen
Posts: 4
Joined: Thu Jul 25, 2013 7:50 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Jul 25, 2013 8:35 pm

ok, now i got it. it's alway better to understand what's going on.

so besides forwarding the http one also has to forward rtmp. so i configured 2 nat rules in my router

for http: outside 8079 ---> inside 80
for rtmp: outside 1935 ---> inside 1935

thanks anyway

abgesoffen
Posts: 4
Joined: Thu Jul 25, 2013 7:50 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Jul 25, 2013 8:51 pm

eggster wrote:I finally got this working and can confirm jwplayer has a nasty 5-6 second delay whereas strobemediaplayer does not.
i could now reduce the lag with jwplayer by simply setting

clientSideBuffer=5, --in seconds, between 5 and 30

in

/etc/crtmpserver/applications/flvplayback.lua

plus reduced fps and size

raspivid -t 9999999 -w 480 -h 270 -fps 15 -b 500000 -vf -o - | ffmpeg -i - -vcodec copy -an -r 15 -f flv -metadata streamName=myStream tcp://0.0.0.0:6666

at what quality is strobemediaplayer streaming? 25fps and 960x520?

popeye007
Posts: 8
Joined: Wed Jul 24, 2013 9:18 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Fri Jul 26, 2013 9:50 am

Hi,

have a problem. i have install the jwplayer on my raspberry with nginx.

in my firefox is the massege.

could not load plugins: File not found

help pleace.

popeye007
Posts: 8
Joined: Wed Jul 24, 2013 9:18 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Fri Jul 26, 2013 11:14 am

ok it works. You need an internet connection to download the pulgin for Firefoxe for the first start of the Firefoxe jwplayer.

The video is very good, unfortunately I have a delay of 5-6 seconds.

What is the reason that I can make it better.

Use the raspberry as wireless ad-hoc and then with the PC to look at browser

alexcroox
Posts: 18
Joined: Sun Jun 02, 2013 10:57 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Fri Jul 26, 2013 11:24 am

popeye007 wrote:ok it works. You need an internet connection to download the pulgin for Firefoxe for the first start of the Firefoxe jwplayer.

The video is very good, unfortunately I have a delay of 5-6 seconds.

What is the reason that I can make it better.

Use the raspberry as wireless ad-hoc and then with the PC to look at browser
Use strobemediaplayer, JW player has 5-6 second delay from the pi module. You can try to change some crmtpserver settings if you are using that to help it as explained a few posts up.

popeye007
Posts: 8
Joined: Wed Jul 24, 2013 9:18 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Fri Jul 26, 2013 12:18 pm

Thanks, but the link above is dead

do you have a manual like I have to do as?

I need ffmpeg for new make?


seasider4374
Posts: 10
Joined: Sat Jun 29, 2013 8:28 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Fri Jul 26, 2013 10:02 pm

Just want to say a huge thanks for this guide - miles better than my previous experiments with Motion and MJPEG-Streamer.

As a complete noob to Linux the instructions worked straight out of the box for me with a couple of exceptions.

First amend the "-t -1" setting to "-t 9999999" as per the comments in the first page.

Secondly ensure you sudo cp (not just cp) when copying the jwplayer files into /var/www/jwplayer.

I do get a significant lag over Wifi (much more than 6 seconds - more like 1 minute whilst only 3 metres from a 54Mbps router) but the framerate and image quality far exceeds the Motion and MJPEG-Streamer I've used before.

I'll be sure to make a backup image of my now working SD card and then experiment further with nginx and Strobe Media Playback but again a huge thanks to Rayui for getting me this far in my journey!

seasider4374
Posts: 10
Joined: Sat Jun 29, 2013 8:28 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sat Jul 27, 2013 9:28 pm

Anyone able to help with a couple of queries?

1) How to I install the patched Raspivid file to enable unlimited streaming?
2) Any pointers on the HTML code needed to get StrobeMediaPlayback working instead of JWPlayer would be greatly appreciated...

Thanks,

Seasider4374

rayui
Posts: 13
Joined: Wed Oct 10, 2012 5:07 pm
Location: London
Contact: Website

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Tue Jul 30, 2013 2:45 pm

I'm very glad to see this post has been so helpful to so many people. I have had a little free time and implemented a version of the how-to using Strobe Media Player. It works fantastically well in place of JWPlayer so I'll soon be updating the how-to to use that instead. Many thanks to @towolf for surfacing this - it's added great value to my project so can't wait to re-share this. If you're interested in what I'm using the camera for, here are some URLs:

Camera on Raspberry Pi race car: http://imgur.com/a/WSL6B
Video of race car pre-camera: https://www.youtube.com/watch?v=JX7vGxqzVCo
Slides from MLOC.JS presentation: http://www.slideshare.net/rayui/scaling ... ersepctive

eggster
Posts: 15
Joined: Thu May 31, 2012 4:35 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Tue Jul 30, 2013 4:25 pm

rayui wrote:I'm very glad to see this post has been so helpful to so many people.
Thank you for putting this thread together. It has been very helpful getting this setup on my end.

Return to “Camera board”