ethanol100
Posts: 590
Joined: Wed Oct 02, 2013 12:28 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Jan 29, 2014 6:18 pm

Could you change the option -t -1 to -t 0 in the raspivid command? You can try, if raspivid is creating a video file first and try to play the output.

Code: Select all

raspivid -t 0 -w 960 -h 540 -fps 25 -b 500000 -vf -o test.h264
omxplayer test.h264
(you need to kill it using Ctrl+c after some time)

And if the output works, you can try again to pipe it to ffmeg.

Code: Select all

raspivid -t 0 -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

Laurence997
Posts: 3
Joined: Thu Jan 23, 2014 3:59 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Jan 29, 2014 11:18 pm

Laurence997 wrote: I have managed to get the video to stream to a web browser using JWPlayer and Strobe Media Player as described, at full resolution and 25fps, however I need to view the stream on a raspberry pi
I managed to get a full hd feed, 25fps, to stream live from pi to pi with a delay of 1.54s, which makes no difference to me, by using rtmpdump and omxplayer, using the live option on both. I was using the live option on rtmpdump before, but not omxplayer. I also increased the size of the gpu memory split to help decoding.
Now I've set it up so that it displays the feed on screen by default when it's turned on. Cpu usage is typically below 10% (model a), though obviously most of the work is being done by the gpu. I'll put up the exact commands I used and the other changes I made as soon as I get a chance.

Next on my list is to try to protect the life of the sd card from all the write operations, and also trying to overlay a timestamp on the video at the server side so that if the feed freezes, due to WiFi dropout or whatever, that it'll be noticed. It would be nice to have some nanny script in place to make sure that if the feed does drop that it'll restart automatically.

Once I've figured out the bugs I'll work on having multiple pi's with cameras send feeds back to one screen with a controller to choose the feed required, and I might add functionality that grabs a couple of frames per second from the stream and plays back an hour's worth of video in a minute or so. I know that there are very few cases where this would be useful, but I'll be using the cameras to monitor cows in labour, and watching their movement over a period of time can tell a lot about when they are likely to calf. I think it should be achievable with ffmpeg too, though I could be wrong.

xvanic04
Posts: 4
Joined: Sun Dec 01, 2013 9:39 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Jan 30, 2014 8:33 am

it works. thank you for your help.

toogaze
Posts: 2
Joined: Sun Oct 27, 2013 5:16 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Jan 30, 2014 6:50 pm

So I'm following this tutorial, and I just wanted to make a note that I had to reinstall cmake to get that last raspivid piped command to work.

But I'm also getting an error that tells me it cannot connect to 0.0.0.0, 127.0.0.1, or any other IP I put in over port 6666. I am thinking this is due to my school's firewall access, but any other suggestions would be appreciated.

tvjon
Posts: 753
Joined: Mon Jan 07, 2013 9:11 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sat Feb 01, 2014 8:15 am

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


To be honest I'm thinking about using netcat as is described on the foundations camera intro (http://www.raspberrypi.org/camera#). I would like to be able to stream to webpages and phones like rtmp allows, and there is more that I could do with this method of streaming, but I need to be able to stream pi to pi, so that might be the better option.
Laurence,

If you're mainly interested in LAN attached Rpi's,

http://www.raspberrypi.org/forum/viewto ... 43&t=67990

would be much simpler to implement. Works with several receiving Rpi's too.

Nice to see you're keeping a watchful eye on your cows :)

toogaze
Posts: 2
Joined: Sun Oct 27, 2013 5:16 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sat Feb 01, 2014 9:38 pm

toogaze wrote:So I'm following this tutorial, and I just wanted to make a note that I had to reinstall cmake to get that last raspivid piped command to work.

But I'm also getting an error that tells me it cannot connect to 0.0.0.0, 127.0.0.1, or any other IP I put in over port 6666. I am thinking this is due to my school's firewall access, but any other suggestions would be appreciated.
Okay, I fixed this. I had to change the port that my webserver was running on. I'm getting about 5-6 second delay though. Is there a way I could reduce the length of delay?
Few other questions. Is there a way to add a timestamp to the video feed? And is there a way to use ffmpeg to encode a .mp4 file for HTML5 use, and if not is there a way to use the same configuration for flv but stream in HTML5, without using JWPlayer or another flash player?

ruthmann88
Posts: 2
Joined: Thu Feb 13, 2014 3:05 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Feb 13, 2014 3:15 pm

I got everything running great based on the instructions on the first page. My only questions are:
I want to view it using VLC media player on another raspberry pi that I have on the network. The only problem is no matter what network address I use it cannot load the file. (ex. I've tried simply http://192.168.0.106, rtmp://192.168.0.106/flvplayback/mystream, http://192.168.0.106/myStream..flv) but nothing works. Any ideas?

Thank you

ChefBorjan
Posts: 6
Joined: Tue Jan 15, 2013 10:22 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Tue Mar 04, 2014 3:33 pm

Hi there.

I've been following these steps, and was compelling FFMPEG (at the initial 'make' step) when my pi appears to have crashed (was multitasking like an impatient idiot!)

I'm not too familiar with linux still, what do I need to do now? Do I need to clean up files? Or can I just run make again?

lenlutz
Posts: 2
Joined: Fri Apr 04, 2014 5:36 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Fri Apr 04, 2014 5:50 pm

i followed the instructions to a "t".
(http://www.raspberrypi.org/forums/viewt ... &start=100)
i am able to get raspvid to work
i am able to see the jwplayer on a client machine
when i run:
raspivid -t 0 -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
OR
raspivid -t 0 -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:1935

i see ffpeg start... then i get:

Connection to tcp://0.0.0.0:xxxx failed

Im SURE this is because crtmpserrver is NOT running.
when i type
/etc/init.d/crtmpserver start, it appears to start
But, it dies immediately (and /etc/init.d/crtmpserver stats indicates that).
i HAVE made the recommended mods to the config file.
i even loaded crtmpserv on a second pi, and the results are the same...

Ive been a few days at it, and feel like ive age a year....

lenlutz
Posts: 2
Joined: Fri Apr 04, 2014 5:36 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Apr 07, 2014 3:13 pm

the instruction indicate that the crtmpserver config file
/etc/crtmpserver/applications/flvplayback.lua
needs to be updates with:

validateHandshake=false,
keyframeSeek=false,
seekGranularity=0.1
clientSideBuffer=30

i was able to run crtmpserver with this option:
/usr/sbin/crtmpserver --use-implicit-console-appender /etc/crtmpserver/crtmpserver.lua
on the screen i got:
"Error parsing file /etc/crtmpserver/crtmpserver.lua: /etc/crtmpserver/applications/flvplayback.lua:61: '}' expected (to close '{' at line 2) near 'clientSideBuffer'"
it indicated an error in the config file

i change it to :
validateHandshake=false,
keyframeSeek=false,
seekGranularity=0.1,
clientSideBuffer=30,
(NOTE the comma at then end of EACH line)

and guess-a-what ???? crtmpserrver Now runs

sofaman
Posts: 15
Joined: Sun Aug 05, 2012 3:10 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Apr 17, 2014 7:39 am

Hi,

I can get it to run but only for 5 seconds then it just stops. Any ideas?

Code: Select all

[email protected] /usr/src $ raspivid -t 9999999 -w 800 -h 600 -fps 15 -b 500000 -vf -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://192.168.0.120:750
ffmpeg version N-55110-g121fc05 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jul 31 2013 02:04:09 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. 82.100 /  3. 82.100
  libswscale      2.  4.100 /  2.  4.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, 800x600, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Output #0, flv, to 'tcp://192.168.0.120:750':
  Metadata:
    streamName      : myStream
    encoder         : Lavf55.12.102
    Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 800x600, q=2-31, 25 fps, 1k tbn, 1200k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
[email protected] /usr/src $  size=     459kB time=00:00:08.88 bitrate= 423.7kbits/s    
Thanks

Sofa

ruthmann88
Posts: 2
Joined: Thu Feb 13, 2014 3:05 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed May 28, 2014 5:31 pm

Following these instructions, I was able to successfully get everything running smoothly. Thank you everyone.

I have a question. If I would like to save the last 24 hours, of the stream, what would be the best way to accomplish this?

I used this command:

raspivid -t -0 -w 1280 -h 720 -fps 25 -b 500000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666 -an -r 25 -f flv stream.flv

However; it drastically reduced quality and increased lag quite a bit. Any other suggestions?

ooda55
Posts: 1
Joined: Sun Jun 29, 2014 9:29 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sun Jun 29, 2014 9:32 pm

dsala wrote: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
What exactly did you have to change on your interfaces file?
I did have this all working then messed with the interfaces file as wifi stopped working. I now get the "tcp://0.0.0.0:6666: Invalid argument" message

My interfaces file contains:

Code: Select all

auto wlan0

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Any thoughts?

Thiago Moreira
Posts: 2
Joined: Tue Sep 16, 2014 7:28 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Tue Sep 16, 2014 8:22 pm

Hi there!

It seems to work great! But I dont know how to play the stream on my windows 8 side!

I use the comand on the RPi:

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 udp://<MY-WINDOWS8-PC-IP>:6666 
I try to execute a bat file on my windows 8 witch contains

Code: Select all

 ffplay.exe  udp://192.168.6.181:6666/ 
But nothing happens. I'd apreciatte some help.

atmosx
Posts: 24
Joined: Mon Aug 06, 2012 1:36 pm
Location: Greece

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Sep 24, 2014 11:42 am

Is there any possibility to stream H26d4 mp4 instead of FLV? I can't see the video in my iOs devices which is a major drawback :-(

mist-ers
Posts: 2
Joined: Mon Sep 29, 2014 7:47 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Sep 29, 2014 7:58 pm

Hi Laurence997

you said that you managed to set up a configuration for streaming pi2pi with omxplayer. I already tried different configurations. Right now im using
raspivid & ffmpeg (flv codec) -> external server (crtmp server) -> receive via rtmpdum & omxplayer (gpumem 256)

The Problem is that the delay is increasing over time as well as the rtmpdump fifo is increasing. Did you manage to set up a stable delay if yes what should i do to achieve a stable delay. Already tried to add the live parameter for omxplayer and rtmpdump

Could you please give me a hint

many thanks

allanheel
Posts: 8
Joined: Wed Oct 01, 2014 12:51 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Tue Nov 04, 2014 3:39 pm

Hi,

Can you confirm this is all running on your Raspberry or are you using a separate device for your webserver? I would like to run it all on the Raspberry. I assume the 0.0.0.0 would have to be changed to the ip address of my Raspberry?

rjbailey95066
Posts: 16
Joined: Wed Dec 24, 2014 3:49 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Dec 24, 2014 9:42 pm

Thanks for all the information and tips, people. Sadly I haven't gotten this to work. It's an old thread, and I don't know if things have changed since the original post, but I'm unsuccessful with the ffmpeg recompile--there are no H.264 accelerations, and the CPU stays at 50-90% for only 5-10 frames/sec. I thought the GPU in the RPi was supposed to take most of the load. Mine isn't.

It's possible the magic is in the options for ./configure, but why are options not necessary for the rest of you? What am I missing?

rjbailey95066
Posts: 16
Joined: Wed Dec 24, 2014 3:49 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Dec 31, 2014 12:51 am

sithlord2 wrote:
dostei wrote:when i start the command:
raspivid -t -1 -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
after some time i got following error message:

Code: Select all

Failed to update header with correct duration.
[email protected] 0x2880210 Failed tu pdate header with correct filesize
Whats wrong here??
Seems I have the same issue too. It stops broadcasting after +- 3 hours.
Happens to me every time after ca. 254K frames @ 25 fps = 2.8 hours.

Has anybody found a way around this problem?

dkruchala
Posts: 2
Joined: Sun Jan 25, 2015 5:00 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sun Jan 25, 2015 5:05 pm

Hi, when i try to make ffmpeg i get something like this and it ends with error:

Code: Select all

libavformat/ffmdec.c: In function ‘ffm_close’:
libavformat/ffmdec.c:231:9: warning: ‘rc_eq’ is deprecated (declared at ./libavcodec/avcodec.h:2307) [-Wdeprecated-declarations]
libavformat/ffmdec.c: In function ‘ffm2_read_header’:
libavformat/ffmdec.c:345:13: warning: ‘rc_eq’ is deprecated (declared at ./libavcodec/avcodec.h:2307) [-Wdeprecated-declarations]
libavformat/ffmdec.c:362:13: warning: ‘rc_buffer_aggressivity’ is deprecated (declared at ./libavcodec/avcodec.h:2329) [-Wdeprecated-declarations]
libavformat/ffmdec.c: In function ‘ffm_read_header’:
libavformat/ffmdec.c:517:13: warning: ‘rc_eq’ is deprecated (declared at ./libavcodec/avcodec.h:2307) [-Wdeprecated-declarations]
libavformat/ffmdec.c:534:13: warning: ‘rc_buffer_aggressivity’ is deprecated (declared at ./libavcodec/avcodec.h:2329) [-Wdeprecated-declarations]
libavformat/ffmdec.c:419:16: warning: ‘f_stau’ may be used uninitialized in this function [-Wuninitialized]
libavformat/ffmdec.c:264:37: note: ‘f_stau’ was declared here
libavformat/ffmdec.c:404:16: warning: ‘f_stvi’ may be used uninitialized in this function [-Wuninitialized]
libavformat/ffmdec.c:264:29: note: ‘f_stvi’ was declared here
libavformat/ffmdec.c:387:16: warning: ‘f_cprv’ may be used uninitialized in this function [-Wuninitialized]
libavformat/ffmdec.c:264:21: note: ‘f_cprv’ was declared here
libavformat/ffmdec.c:383:29: warning: ‘codec’ may be used uninitialized in this function [-Wuninitialized]
libavformat/ffmdec.c:262:21: note: ‘codec’ was declared here
libavformat/ffmdec.c:430:49: warning: ‘st’ may be used uninitialized in this function [-Wuninitialized]
libavformat/ffmdec.c:260:15: note: ‘st’ was declared here

NAffourtit
Posts: 2
Joined: Thu Feb 12, 2015 9:58 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Feb 12, 2015 10:04 pm

If anyone had this error: "tcp://0.0.0.0:6666: Invalid argument" and don't know how to solve the interfaces file read the following.
After I installed a dongle I modified interfaces with 'sudo nano /etc/network/interfaces' and the stream command didn't work when I specified a static IP. I forgot to include the broadcast address. For me the following setting solved the problem:
iface lo inet loopback
iface eth0 inet static
address 192.168.1.61
netmask 255.255.255.0
network 192.168.1.254
gateway 192.168.1.254
broadcast 192.168.1.255

allow-hotplug wlan0
auto wlan0
iface wlan0 inet static
address 192.168.1.64
netmask 255.255.255.0
network 192.168.1.254
wpa-ssid "Your SSID"
wpa-psk "Your password"

Endriu
Posts: 3
Joined: Sat Apr 11, 2015 2:45 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Tue Apr 14, 2015 5:47 pm

Hi, I have a problem :roll:
Streaming:
RPI 2 (RPI camera) -> VPS - my page (JWPlayer 6.12.4956).
My delay of a few minutes :shock:
I'm using this code to send the Raspberry on VPS:

raspivid -t -1 -w 770 -h 433 -fps 30 -b 2000000 -vf -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream rtmp://IP/myapp/Stream

Stream: 770x433, 30 FPS, 2 Mbit

What's the matter ? :roll:

Stevie D
Posts: 1
Joined: Tue Dec 08, 2015 10:31 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Tue Dec 08, 2015 10:40 am

What a fantastic source of information this is :-)

Having set everything up successfully, ffmpeg, jwplayer, apache2 etc. etc. I just thought I'd throw in my two-penneth.

I had my camera pointing out the window watching something, but wanted to zoom in on a specific area of the image.

Having found this in the official pi camera documentation, I tried adding it to the command and bingo, I'm zoomed:

-roi 0.5,0.5,0.25,0.25

the full document is: https://www.raspberrypi.org/wp-content/ ... tation.pdf

DarthX
Posts: 1
Joined: Tue Jul 12, 2016 1:16 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Tue Jul 12, 2016 1:24 pm

Hi,

I would really appreciate your help. After following the tutorial, when I run the command,

raspivid -t -1 -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

I am getting a message "Segmentation fault"

Could you please shed some light on this?

raistlinmolina
Posts: 4
Joined: Wed Feb 08, 2017 12:21 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Feb 08, 2017 12:24 pm

Nice post, thanks for sharing, I think it's what I need and going to give it a try.

What I have noiticed is that http://www.longtailvideo.com/ is no longer free and I don't see how to download the player.

Is there any other similar player we can use?.


Thanks

Return to “Camera board”