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

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Aug 07, 2013 5:28 pm

Hi Ark,

Just tried your daemon setup but get the following error;

Code: Select all

sudo update-rc.d pi_cam defaults
update-rc.d: using dependency based boot sequencing
insserv: script pi_cam is not an executable regular file, skipped!

EDIT:
Okay - I've since done some Googling and the above seems to be a permissions issue. After changing owner, group and others to all have execute permission the error message dissapears. However the stream doesn't fire up after a reboot. The output I get is now;

Code: Select all

[email protected] ~ $ sudo update-rc.d pi_cam defaults
update-rc.d: using dependency based boot sequencing
[email protected] ~ $ 
Any ideas?

Ark
Posts: 4
Joined: Mon Aug 05, 2013 11:36 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Aug 07, 2013 9:34 pm

You can try to start and stop the script manually and see what it does.

Code: Select all

sudo /etc/init.d/pi_cam start

sudo /etc/init.d/pi_cam stop
You might need to remove > /dev/null 2>&1 from video.sh to get output on your shell to see error messages.

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

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 08, 2013 3:50 am

No idea if it’s still needed. I tried to make a no nonsense write-up of my Arch Linux nginx RTMP + HLS setup: YMMV

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

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 08, 2013 6:33 am

Ark wrote:You can try to start and stop the script manually and see what it does.

Code: Select all

sudo /etc/init.d/pi_cam start

sudo /etc/init.d/pi_cam stop
You might need to remove > /dev/null 2>&1 from video.sh to get output on your shell to see error messages.
This gives me the following;

Code: Select all

[email protected] ~ $ sudo /etc/init.d/pi_cam start
Starting PiCam: PiCam.
[email protected] ~ $ sudo /etc/init.d/pi_cam stop
Stopping PiCam: raspivid: no process found
PiCam.
[email protected] ~ $
and with /dev/null 2>&1 removed from video.sh i had a few syntax errors (unexpected &, and then unexpected new line) so amended video.sh to be;

Code: Select all

#!/bin/sh

raspivid -n -vs -t 0 -fps 25 -b 5000000 -vf -hf -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666
The error is now showing as;

Code: Select all

[email protected] ~ $ sudo /etc/init.d/pi_cam start
Starting PiCam: ffmpeg version N-54933-g1af9211 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jul 26 2013 01:44:26 with gcc 4.6 (Debian 4.6.3-14+rpi1)
  configuration:
  libavutil      52. 40.100 / 52. 40.100
  libavcodec     55. 19.100 / 55. 19.100
  libavformat    55. 12.102 / 55. 12.102
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 81.103 /  3. 81.103
  libswscale      2.  4.100 /  2.  4.100
  libswresample   0. 17.103 /  0. 17.103
pipe:: Invalid data found when processing input
PiCam.
[email protected] ~ $

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

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 08, 2013 6:34 am

towolf wrote:No idea if it’s still needed. I tried to make a no nonsense write-up of my Arch Linux nginx RTMP + HLS setup: YMMV
Thanks Towolf I've been following your input on another thread and so this will definitely be something I try when my new SD cards land on the doormat!

yeme
Posts: 7
Joined: Sun Jul 28, 2013 9:29 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 08, 2013 12:55 pm

Will someone supply html 5 code to center Strobe Player on the page.

Thanks

Ark
Posts: 4
Joined: Mon Aug 05, 2013 11:36 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 08, 2013 10:20 pm

seasider4374 wrote:
Ark wrote:You can try to start and stop the script manually and see what it does.

Code: Select all

sudo /etc/init.d/pi_cam start

sudo /etc/init.d/pi_cam stop
You might need to remove > /dev/null 2>&1 from video.sh to get output on your shell to see error messages.
This gives me the following;

Code: Select all

[email protected] ~ $ sudo /etc/init.d/pi_cam start
Starting PiCam: PiCam.
[email protected] ~ $ sudo /etc/init.d/pi_cam stop
Stopping PiCam: raspivid: no process found
PiCam.
[email protected] ~ $
and with /dev/null 2>&1 removed from video.sh i had a few syntax errors (unexpected &, and then unexpected new line) so amended video.sh to be;

Code: Select all

#!/bin/sh

raspivid -n -vs -t 0 -fps 25 -b 5000000 -vf -hf -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666
The error is now showing as;

Code: Select all

[email protected] ~ $ sudo /etc/init.d/pi_cam start
Starting PiCam: ffmpeg version N-54933-g1af9211 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jul 26 2013 01:44:26 with gcc 4.6 (Debian 4.6.3-14+rpi1)
  configuration:
  libavutil      52. 40.100 / 52. 40.100
  libavcodec     55. 19.100 / 55. 19.100
  libavformat    55. 12.102 / 55. 12.102
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 81.103 /  3. 81.103
  libswscale      2.  4.100 /  2.  4.100
  libswresample   0. 17.103 /  0. 17.103
pipe:: Invalid data found when processing input
PiCam.
[email protected] ~ $

Looks like your raspivid is playing up.

Try

Code: Select all

raspivid -n -vs -t 0 -fps 25 -b 5000000 -vf -hf 
to see if the specified options work.

You might want to update your distro to the latest release (I did that and didn't need a patched raspivid for unlimited recording):

Code: Select all

sudo apt-get update

wcopeland
Posts: 3
Joined: Sat Apr 06, 2013 1:14 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sat Aug 10, 2013 5:56 pm

Ark, thanks so much! I was pointing the video src in my javascript to mystream as opposed to myStream. I feel silly.

And Towolf, it is always nice when people take time to compile tuts, so even though I don't need it, thanks!

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

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sun Aug 11, 2013 6:40 am

Ark wrote:Looks like your raspivid is playing up.

Try

Code: Select all

raspivid -n -vs -t 0 -fps 25 -b 5000000 -vf -hf 
to see if the specified options work.
Thanks Ark - I changed by video.sh settings back to what I had always used to start the service manually and now all is fine - it fires up straight away with no input from me upon the power cable being plugged in. Thank you!

For reference my video.sh code is

Code: Select all

#!/bin/sh

raspivid -t 99999999 -w 1920 -h 1080 -fps 25 -b 1500000 -o - | ffmpeg -i - -vcodec copy -an -r 25 -f flv -metadata streamName=myStream tcp://0.0.0.0:6666 > /dev/null 2>&1 &

unnamed7
Posts: 42
Joined: Mon Jun 18, 2012 8:44 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Aug 14, 2013 5:11 pm

hi, i'am fighting with streaming and have some questions:
1. why stream is available under this link rtmp://rasp ip address/flvplayback/myStream - i mean bold part, it's some default crtmpserver link ?
2. should vlc be able to open this stream (rtmp://rasp ip address/flvplayback/myStream)? it's always saying that input is dead
3. is there some option to play rtmp via custom application ? for example https://itunes.apple.com/ru/app/fresh-v ... ?l=en&mt=8 - it says it streams rtmp but i tried it and i only get "unable to open" OR it's just some mistake and i can only watch hls on iphone/ipad
4. what is my best option to stream to ipad/iphone ? tried hls and rtsp = hls great quality but latency is like 13-16s, rtsp is not working to good, quality is worse than with hls but latency is 3s. There is no option to have stream like with rtmp on ios = great quality and almost no lag ?

houareau
Posts: 1
Joined: Wed Aug 14, 2013 10:08 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Aug 14, 2013 10:15 pm

Is it possible to start and stop the stream remotely from php? Basically issue this command and stop it from a html button.
raspivid -t -0 -w 1280 -h 768 -fps 25 -b 500000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666

dsala
Posts: 1
Joined: Fri Aug 30, 2013 7:03 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Fri Aug 30, 2013 7:30 pm

Sorry for the question, I'm new.
After install crtmpserver and reinstall ffmpeg from source, I run:

Code: Select all

raspivid -t 9999999 -w 960 -h 540 -fps 25 -b 500000 -vf -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666
and I obtain:

Code: Select all

ffmpeg version N-55805-g2312013 Copyright (c) 2000-2013 the FFmpeg developers
  built on Aug 27 2013 16:47:10 with gcc 4.6 (Debian 4.6.3-14+rpi1)
  configuration:
  libavutil      52. 42.100 / 52. 42.100
  libavcodec     55. 29.100 / 55. 29.100
  libavformat    55. 14.102 / 55. 14.102
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 82.102 /  3. 82.102
  libswscale      2.  5.100 /  2.  5.100
  libswresample   0. 17.103 /  0. 17.103
Input #0, h264, from 'pipe:':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p, 480x270, 25 fps, 25 tbr, 1200k tbn, 50 tbc
tcp://0.0.0.0:6666: Invalid argument
Does someone know the reason why tcp://0.0.0.0:6666 is an Invalid argument and some solution?
Edited: If I change url for tcp://127.0.0.1:6666, I obtain: Connection timed out
Thanks

EDITED:
Solved !!!, it was a bad setup in interfaces file. I'm new :oops: :mrgreen:
Now works perfectly.
Thank you very much for the superb tutorial.
Regards

Grumpybeard
Posts: 10
Joined: Sat Mar 02, 2013 2:04 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Sep 04, 2013 6:32 pm

This works awesome.

Thanks rayui and all other contributors for the effort, much appreciated!

madrian
Posts: 29
Joined: Tue Aug 28, 2012 6:48 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sun Sep 08, 2013 9:43 pm

I successfully installed crtmpserver and fffmpeg, but I get error:

[tcp @ 0x27c8db0] Connection to tcp://0.0.0.0:6666 failed: Connection refused
tcp://0.0.0.0:6666: Connection refused

raspbear58
Posts: 2
Joined: Thu Oct 11, 2012 9:28 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Tue Sep 10, 2013 5:42 pm

Hello all
I tried to follow the instructions in the beginning of this thread to download and compile, but twice I finished by

collect2: ld terminated with signal 9 [Getötet] make: ***
[ffmpeg-g] Fehler 1

after ./configure

I looked around and found messages about "out of memory". Can anybody show me things I could try or change? Thanks a lot, ub

AforAlex
Posts: 85
Joined: Thu May 31, 2012 7:56 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sun Sep 15, 2013 9:51 pm

Hi,

I've been going through the instructions, I've followed all the instructions and haven't received any errors.

The problem I am having is that when I open the html file I get the jwplayer windows and the loading 'wheel' just goes around.

I'm fairly sure that the camera is working, the red light on it comes on, Also it scrolls the fram/fps/size/time/bitrate which all looks reasonable and correct:

eg: frame=22577 fps=25 q=-1.0 size= 47274kB time=00:15:39:16 bitrate=420.7kbits/

I suspect the issue is that the jwplayer isn't picking up the stream. Does a physical file get created/written to anywhere so that I can check to see whether its happening? and is there some place in jwplayer than i can see where its looking to pick up the stream.

Any thoughts or suggests very much appreciated

Soulpatrol
Posts: 1
Joined: Tue Sep 17, 2013 3:20 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Tue Sep 17, 2013 3:23 pm

Great lil Tutorial me friend.
Thanks alot for that.
All you have to do to have a boadcast on the internet is to forward ports 80 (http) and 1935 (crtmpserver) from your raspberrypi to the outside world.
I forgot the crtmpserver be be NATted... also Thank for that info..

Keep on with such Tuts..


Soul

verb0ss
Posts: 1
Joined: Fri Aug 03, 2012 10:21 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Sep 19, 2013 2:49 pm

Hello everyone. I have really odd problem. It seems there is something wrong with my firewall configuration. My Raspberry is behind NAT on my home server which is behind adsl router. So lets say my home server is on 192.168.0.2 network and RPi is on 192.168.1.2. I have ports 80 and 1935 forwarded to my home server (192.168.0.2) and im able tu run strobeplayer and all works well. I have created rules for my firewall on adsl router and im able to access my http server from internet. It loads player but then i have message "We are unable to connect to the network. We apologise for inconvenience". Well if im able to see it from my home server address it means that firewall rules are correct and it has something to do with adsl router. I have checked my adsl router with NMap and it show port 1935 as open but somehow it cant access it from internet. Any idea what can it be?

Right. my further investigation revealed that the problem has something to do with DynDNS. If I use DNS to access my website it loads web page with player but RTMP has problems going through to the internet. If I use IP address only, everything works flawlessly. Strange because i can use other services (ssh, http) but not RTMP with DynDNS.

User avatar
howroyd
Posts: 39
Joined: Thu Aug 02, 2012 1:41 pm
Location: Loughborough
Contact: Website

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Sep 23, 2013 10:19 am

Hi all,

Really struggling and got minimal scalp left from head scratching.

Installed crtmpserver, all good no probs.
Installed ffmpeg from source, all good no probs.
jwplayer in /var/www/jwplayer as expected.

Run the stream results in this until I Ctrl-C it:

Code: Select all

[email protected] /var/www $ raspivid -t 9999999 -w 960 -h 540 -fps 25 -b 500000 -vf -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666
ffmpeg version N-56567-g601eab2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Sep 22 2013 20:05:59 with gcc 4.6 (Debian 4.6.3-14+rpi1)
  configuration:
  libavutil      52. 46.100 / 52. 46.100
  libavcodec     55. 33.100 / 55. 33.100
  libavformat    55. 18.102 / 55. 18.102
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 87.100 /  3. 87.100
  libswscale      2.  5.100 /  2.  5.100
  libswresample   0. 17.103 /  0. 17.103
Using apache, with a index.html like this:

Code: Select all

<html>
  <head>
    <title>Raspbi Camera RTMP stream test</title>
  </head>
  <body>
    <div id="video-jwplayer_wrapper" style="position: relative; display: block;$
      <object type="application/x-shockwave-flash" data="/jwplayer/jwplayer.fla$
        <param name="allowfullscreen" value="true">
        <param name="allowscriptaccess" value="always">
        <param name="seamlesstabbing" value="true">
        <param name="wmode" value="opaque">
      </object>
      <div id="video-jwplayer_aspect" style="display: none;"></div>
      <div id="video-jwplayer_jwpsrv" style="position: absolute; top: 0px; z-in$
    </div>

    <script src="/jwplayer/jwplayer.js"></script>

    <script type="text/javascript">
        <param name="wmode" value="opaque">
      </object>
      <div id="video-jwplayer_aspect" style="display: none;"></div>
      <div id="video-jwplayer_jwpsrv" style="position: absolute; top: 0px; z-in$
    </div>

    <script src="/jwplayer/jwplayer.js"></script>

    <script type="text/javascript">
    jwplayer('video-jwplayer').setup({
      flashplayer:"/jwplayer/jwplayer.flash.swf"
      , file:"rtmp://" + window.location.hostname + "/flvplayback/flv:myStream.$
      , autoStart: true
      , rtmp:{
        bufferlength:0.1
      }
      , deliveryType: "streaming"
      , width: 960
      , height: 540
      flashplayer:"/jwplayer/jwplayer.flash.swf"
      , file:"rtmp://" + window.location.hostname + "/flvplayback/flv:myStream.$
      , autoStart: true
      , rtmp:{
        bufferlength:0.1
      }
      , deliveryType: "streaming"
      , width: 960
      , height: 540
      , player: {
        modes: {
          linear: {
            controls:{
              stream:{
                manage:false
                , enabled: false
              }
            }
          }
        modes: {
          linear: {
            controls:{
              stream:{
                manage:false
                , enabled: false
              }
            }
          }
        }
      }
      , shows: {
        streamTimer: {
          enabled: true
          , tickRate: 100
        }
      }
    });
    </script>
</body>
</html>
crtmpserver log:

Code: Select all

<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">liveOrFlv</STR>
</MAP>
This results in "Error loading player: No playable sources found" in a black box when I go to my web browser.

I have also tried a few suggestions in this thread using strobe instead of jwplayer. Installed strobe in /var/www/strobe as expected.

Using an html file like this:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dt$
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>Strobe Media Playback</title>
        <script type="text/javascript" src="/strobe/lib/swfobject.js"></script>
       <script type="text/javascript">

           // Create a StrobeMediaPlayback configuration
          var parameters = {
                         src: "rtmp://" + window.location.hostname + "/flvplayback/myStream",
                                  autoPlay: true,
                         controlBarAutoHide: false,
                         playButtonOverlay: true,
                         showVideoInfoOverlayOnStartUp: false,
                                  optimizeBuffering : false,
                                  initialBufferTime : 0.1,
                                  expandedBufferTime : 0.1,
                                  minContinuousPlayback : 0.1,
                         poster: "strobe/images/poster.png"
                       };

          // Embed the player SWF:
          swfobject.embedSWF
             ( "/strobe/StrobeMediaPlayback.swf"
             , "strobeMediaPlayback"
                         showVideoInfoOverlayOnStartUp: false,
                                  optimizeBuffering : false,
                                  initialBufferTime : 0.1,
                                  expandedBufferTime : 0.1,
                                  minContinuousPlayback : 0.1,
                         poster: "strobe/images/poster.png"
                       };

          // Embed the player SWF:
          swfobject.embedSWF
             ( "/strobe/StrobeMediaPlayback.swf"
             , "strobeMediaPlayback"
             , 1280
             , 720
             , "10.1.0"
             , {}
             , parameters
             , { allowFullScreen: "true"}
             , { name: "strobeMediaPlayback" }
             );

        </script>
      </head>
      <body>

       <div id="strobeMediaPlayback">
          <p>Alternative content</p>
        </div>
      </body>
    </html>
All I get here on the webpage is "Alternative content".

Tried on safari and chrome.

Any ideas?

vicat
Posts: 1
Joined: Mon Sep 30, 2013 1:14 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Sep 30, 2013 1:48 pm

Great tutorial, thanks.
A pity it's flash complied. On html5 would be better, but so far is the fastest and more efficient solution I tried.
It works pretty good with about 1 sec. delay through the web using strobe. Thanks again.

midnight1111
Posts: 20
Joined: Sun Apr 07, 2013 4:13 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sun Oct 06, 2013 12:54 am

This is an excellent thread. I just wanted to know if anyone has tried streaming the H.264 HD video using transport stream over UDP/IP Multicast. This way it can be played real time by VLC on a PC.

Thanks Again.
Y-

aabento
Posts: 30
Joined: Sat Dec 29, 2012 3:09 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sun Oct 06, 2013 8:20 pm

Hi.
This is working fine in my network. :D Thanks

If I put in the browser the address http://myIPnetwork/strobe.html I can see the video stream with one second delay. :P :D
I use a Thomson TG784n router and wish to have access to stream over the internet. :?:

There are some How To here for doing this? :?: :?: :?:
Thank you.

aabento
Posts: 30
Joined: Sat Dec 29, 2012 3:09 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Oct 07, 2013 5:49 pm

Any answer? :roll:

Thanks. :D

raind33r
Posts: 6
Joined: Wed Jun 26, 2013 11:35 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Oct 07, 2013 8:02 pm

****************************************************************************************************************
Hi, followed your steps up to make and make install on latest Raspbian wheezy.
I get the following error when running "sudo make && make install"
collect2: ld returned 1 exit status
make: *** [ffmpeg_g] Error 1


Any ideas as to the problem?
****************************************************************************************************************

[quote="marcelp1"]Here is my setup that worked for me on 2013-05-25-wheezy-raspbian.zip image:


----------------------------------------------------------------------------------------------------------------------
# Install git-core and ffmpeg
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo apt-get install git-core
cd /usr/src
sudo mkdir ffmpeg
sudo chown `whoami`:users ffmpeg
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure


-------------------------------------------------------------------------------------------------------------------------------------------------------------
# GO TO GET SOME TEA, it takes ages after issuing the command below cca 3-4 hours
-------------------------------------------------------------------------------------------------------------------------------------------------------------
make &
sudo make install
Last edited by raind33r on Tue Oct 08, 2013 6:42 am, edited 1 time in total.

PsycoMEn
Posts: 25
Joined: Mon Aug 06, 2012 11:11 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Oct 07, 2013 8:13 pm

aabento wrote:Any answer? :roll:

Thanks. :D
FROM INTERNET

You need to open port 1935 and 80 to your RPi

You my open it in booth udp and tcp

Br

Return to “Camera board”