mesotes
Posts: 2
Joined: Tue Mar 04, 2014 2:14 pm

uv4l + gstreamer(-omx) + nginx(-rtmp-module) = livestream

Tue Mar 04, 2014 3:59 pm

hello dear raspi users,

This is my third day in a row researching the possibility to build a hardware accelerated live stream solution with said components. Though I'm very nooby (which is a huge part of the problem too), I am able to search thoroughly and happened to find several guides which helped me:

ppumkins guide found here for installing and configuring nginx with the rtmp module
http://pkula.blogspot.co.uk/2013/06/liv ... ry-pi.html

prebuilt binaries of gstreamer with omx plugin from a fine gentleman in this very forum
http://www.raspberrypi.org/phpBB3/viewt ... 34#p293634

and installed them this way:
http://wiki.matthiasbock.net/index.php/ ... ty_package

a gstreamer pipe from the nginx-rtmp-module creator himself
http://nginx-rtmp.blogspot.co.at/2013/0 ... ry-pi.html

which uses the v4l2 aka uv4l driver found here
http://www.linux-projects.org/modules/news/

and finally, again ppumpkin, who had the exact same problem as I did (and still have!)
https://github.com/arut/nginx-rtmp-module/issues/284

with uv4l
for this, one has to load the driver first, since there is nothing mentioned on the nginx-rtmp blog,
i tried using the same parameters as found in the gst-launch command

Code: Select all

uv4l --driver raspicam --auto-video_nr --encoding rgba --width 640 --height 480 --framerate 15 --bitrate 1000000 --system_rr --mem-lock --extension-presence=1

gst-launch-1.0 v4l2src  ! "video/x-raw,width=640,height=480,framerate=15/1" ! omxh264enc target-bitrate=1000000 control-rate=variable ! video/x-h264,profile=high ! h264parse ! queue ! flvmux name=mux ! rtmpsink location='rtmp://localhost/rtmp/live'
no errors are thrown and it seems to be working, though the raspicam seems to reset itself due to the red LED flashing in regular intervals, with the command below this doesnt happen. looks like a watchdog timer thing. after a while though, it times out with the following error:

with raspivid

Code: Select all

raspivid -t 0 -w 640 -h 480 -fps 15 -hf -b 1000000 -o - | \
gst-launch-1.0 fdsrc ! "video/x-raw,width=640,height=480,framerate=15/1" ! omxh264enc target-bitrate=1000000 control-rate=variable ! video/x-h264,profile=high ! h264parse config-interval=2 ! queue ! flvmux name=mux ! rtmpsink location='rtmp://localhost/rtmp/live'
this one doesnt time out like the other one and the LED of the camera shines constantly and there is a preview on my screen.
update: this one gives me an error saying that writing the input to the openmax buffer wasnt possible.
same as here: https://github.com/arut/nginx-rtmp-module/issues/284 (as you can see I added the mentioned config-interval but it still doesnt work)

still in both cases i am unable to connect (inside my local LAN), though I'm unsure if the rtmpsink location is also my actual url to provide my rtmp player with (in my case windows, smplayer).

notes:
for further improvement i would like to add hls and a webpage with a flash player in it.. but once i can verify that it works, these 2 things seem not that important for now
Last edited by mesotes on Tue Mar 04, 2014 10:13 pm, edited 2 times in total.

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

Re: uv4l + gstreamer(-omx) + nginx(-rtmp-module) = livestrea

Tue Mar 04, 2014 8:24 pm

If you want you can follow my recipe from here: http://ftp.tuebingen.mpg.de/pub/kyb/tow ... -streaming

Make sure you change the hostnames and/or IP addresses in the appropriate places.

I think uv4l is good for nothing now that a proper kernel driver is available.

mesotes
Posts: 2
Joined: Tue Mar 04, 2014 2:14 pm

Re: uv4l + gstreamer(-omx) + nginx(-rtmp-module) = livestrea

Tue Mar 04, 2014 10:07 pm

towolf wrote:If you want you can follow my recipe from here: http://ftp.tuebingen.mpg.de/pub/kyb/tow ... -streaming

Make sure you change the hostnames and/or IP addresses in the appropriate places.

I think uv4l is good for nothing now that a proper kernel driver is available.
hi towolf!

i already came across your solution but after browsing that one thread on this forum, i'm worried that I can't handle archlinux :/
with rasbian there might be more guides or whatnot and not too much exotic errors/commands to fix things. at least thats my impression..
and I guess (hope) there shouldn't be too much missing in my solution..

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

Re: uv4l + gstreamer(-omx) + nginx(-rtmp-module) = livestrea

Tue Mar 04, 2014 11:18 pm

Wait, your raspivid to gst-launch line is completely wrong.

This

Code: Select all

raspivid -t 0 -w 640 -h 480 -fps 15 -hf -b 1000000 -o - | \
gst-launch-1.0 fdsrc ! "video/x-raw,width=640,height=480,framerate=15/1" ! omxh264enc target-bitrate=1000000 control-rate=variable ! video/x-h264,profile=high ! h264parse config-interval=2 ! queue ! flvmux name=mux ! rtmpsink location='rtmp://localhost/rtmp/live'
should be this

Code: Select all

raspivid -t 0 -w 640 -h 480 -fps 15 -hf -b 1000000 -o - | \
gst-launch-1.0 fdsrc ! h264parse config-interval=2 ! flvmux ! rtmpsink location='rtmp://localhost/rtmp/live live=1'
raspivid already emits h264, there’s no reason to encode it again. The line you copy&pasted was reading from a camera emitting raw video; raspivid doesn’t, it copies raw h264 to stdout. gst-launch fdsrc accepts raw h264 on stdin and merely need to package it up and serve as a feed to nginx-rtmp.

No need for omxh264enc anywhere at all.

vetoketju
Posts: 1
Joined: Mon Jun 09, 2014 7:38 pm

Re: uv4l + gstreamer(-omx) + nginx(-rtmp-module) = livestrea

Mon Jun 09, 2014 7:51 pm

I tried piping raspivid to fdsrc, but that doesn't work. After using the failing command I tried to use raspivid with fileoutput and it will output just one black frame. I thinks it caused a harware lock or something. Then I found this https://github.com/thaytan/gst-rpicamsrc and it works like a charm! note that I used Gstreamer 1.2 version.

Code: Select all

gst-launch-1.0 rpicamsrc bitrate=1000000 ! video/x-h264,width=1280,height=720,framerate=15/1,profile=high ! h264parse ! flvmux ! rtmpsink location='rtmp://localhost/rtmp/live live=1'
Here is my results: http://rpiquadcopter.blogspot.com/2014/ ... video.html

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 12 guests