mpromonet
Posts: 13
Joined: Sun Sep 02, 2012 9:04 am

WebRTC streaming of raspicam

Sat Jun 17, 2017 3:43 pm

Hi,

I was searching about a way to stream the raspicam using WebRTC, trying to learn a bit more about WebRTC stuff.
In the different things I read, I notice these articles :
The janus-gateway solution is very-nice using h264 stream compressed by the GPU, but using raspivid piped to gstreamer is awkward and inefficient.
The uv4l is nice but closed source.

Then sometimes ago, I started to build a WebRTC streamer based on the WebRTC project.
There is still works to do, like improve sound support, work with datachannels, bring interoperability with Jitsi...
But as it is starts to work, maybe it could be interesting for others developpers.

The project for Raspberry Pi can be built using an Ubuntu trusty proceeding like this :
  • Install raspberry cross-compiler:

    Code: Select all

    git clone --depth 1 https://github.com/raspberrypi/tools.git rpi_tools
    export PATH=$PATH:$(pwd)/rpi_tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
    
  • Get & Build WebRTC for Raspberry Pi

    Code: Select all

    git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
    export PATH=$PATH:$(pwd)/depot_tools
    mkdir webrtc
    pushd webrtc
    GYP_DEFINES="target_arch=arm" fetch --no-history webrtc
    pushd src
    gn gen out/Release --args='is_debug=false rtc_use_h264=true ffmpeg_branding="Chrome" rtc_include_tests=false rtc_enable_protobuf=false is_clang=false target_cpu="arm" treat_warnings_as_errors=false' 
    ninja -C out/Release
    popd
    popd
    
  • Get & Build & pkg WebRTC Streamer

    Code: Select all

    git clone https://github.com/mpromonet/webrtc-streamer
    cd webrtc-streamer
    make CROSS=arm-linux-gnueabihf- SYSROOT=$(pwd)/../webrtc/src/build/linux/debian_jessie_arm-sysroot tgz
    
Raspberry Pi tgz cross compiled with this procedure is available from github latest

After copy and extract the tgz to a Raspberry Pi, you can simply run :

Code: Select all

./webrtc-streamer
Then you should be able to access WebRTC streams captured from the V4L2 capture device using the url http://<raspberry>:8000.

This works with V4L2 capture devices that supports standard YUV format for capture, like raspicam, but also with USB webcam.

Best Regards,

Michel.
Last edited by mpromonet on Wed Nov 01, 2017 10:39 am, edited 3 times in total.

marty-sullivan
Posts: 3
Joined: Sat Jun 17, 2017 4:25 pm
Location: New York
Contact: Website

Re: WebRTC streaming of raspicam

Sat Jun 17, 2017 4:28 pm

Very cool, and works right out of the box! Is there a built-in way to configure the settings for the stream or do I need to fiddle with the source?

RpiName
Posts: 694
Joined: Sat Jul 06, 2013 3:14 am

Re: WebRTC streaming of raspicam

Sat Jun 17, 2017 5:16 pm

mpromonet wrote: [*]the unofficial v4l2 driver uv4l that provides an webrtc-extension

The janus-gateway solution is very-nice using h264 stream compressed by the GPU, but using raspivid piped to gstreamer is awkward and inefficient.
The uv4l is nice but closed source.
Just to be precise with regard to UV4L, the WebRTC module is an extension of the UV4L Streaming Server not of the "unofficial v4l2 driver". In facts, WebRTC works with any input drivers supported by the UV4L (rpi cameras, UVC-based webcams, raspidisp, etc...)

The UV4L Server also provides a Restful API over HTTP or HTTPS to simplify the interaction with Janus:
https://www.linux-projects.org/documentation/rest-api/

mpromonet
Posts: 13
Joined: Sun Sep 02, 2012 9:04 am

Re: WebRTC streaming of raspicam

Sun Jun 18, 2017 3:57 pm

The UV4L Server also provides a Restful API over HTTP or HTTPS to simplify the interaction with Janus:
https://www.linux-projects.org/documentation/rest-api/
If you are interested connected a WebRTC stream to Janus Gateway, there is a demo page janusvideoroom.html to publish WebRTC stream to Janus. I made this try using javascript page, but this could be implemented in any language sending HTTP requests.

I saw also connection between UV4L and Jitsi that is an interesting feature.

A thing that could be interesting with the project WebRTC-streamer is that it could publish an RTSP source, this is probably doable with UV4L developping an RTSP consumer to feed WebRTC.

UV4L is really interesting, but it seems closed source, maybe I am wrong ?

slingkid
Posts: 1
Joined: Fri Jul 28, 2017 3:12 am

Re: WebRTC streaming of raspicam

Fri Jul 28, 2017 3:38 am

I like the rasp-pi to stream video via Peer to Peer to a mobile device. I don't want to open any ports in my home network. How do I achieve this? Will webrtc-streamer be able to achieve what I want? If yes, can you provide more directions?

lekozak
Posts: 1
Joined: Sat Aug 26, 2017 4:41 pm

Re: WebRTC streaming of raspicam

Sat Aug 26, 2017 4:45 pm

Hi,
I'm not very used to building code, so this error stops me...

Makefile:94 : la recette pour la cible « src/PeerConnectionManager.o » a échouée
make: *** [src/PeerConnectionManager.o] Erreur 1

can you help me, please ?

mpromonet
Posts: 13
Joined: Sun Sep 02, 2012 9:04 am

Re: WebRTC streaming of raspicam

Mon Aug 28, 2017 6:53 am

@lekozak

In order to help you, you need to give a mre detailled information (for instance what makes the target fails). Did you build WebRTC library ?

If you are not interested building software, you get download the lates release from https://github.com/mpromonet/webrtc-streamer/releases or use the docker image https://hub.docker.com/r/mpromonet/webrtc-streamer.

Best Regards,

Michel.

encore-lab
Posts: 1
Joined: Wed Sep 20, 2017 1:40 pm

Re: WebRTC streaming of raspicam

Wed Sep 20, 2017 1:50 pm

@mpromonet

Thank you very much for your contribution. It is really awesome.

In a PC it works like a charm but I am experiencing performance issues in Android devices. I believe that these devices cannot decode the video on time because it is too heavy for them so it plays laggy. Can you tell me how can I change video resolution, framerate and bitrate please?

Thanks in advance!

mpromonet
Posts: 13
Joined: Sun Sep 02, 2012 9:04 am

Re: WebRTC streaming of raspicam

Wed Sep 20, 2017 10:07 pm

@encore-lab

There is an option that I didnot test really to set bitrate of the PeerConnection.
When calling connect of WebRtcStreamer, you can set option bitrate=<target bps>, or using options in url like

Code: Select all

 https://webrtc-streamer.herokuapp.com/?options=bitrate%3d100000
Best Regards,
Michel.
Last edited by mpromonet on Wed Nov 01, 2017 10:31 am, edited 1 time in total.

codeforge
Posts: 9
Joined: Fri May 01, 2015 10:09 pm

Re: WebRTC streaming of raspicam

Wed Oct 25, 2017 8:39 pm

Hi,
i follow the info for making webrtc for arm (raspberry pi 3) and when i run this command:

Code: Select all

make CROSS=arm-linux-gnueabihf- WEBRTCROOT=/home/osboxes/webrtc WEBRTCBUILD=Release SYSROOT=/home/osboxes/webrtc/src/build/linux/debian_jessie_arm-sysroot
i get this:

Code: Select all

...
src/rtspvideocapturer.o:(.rodata+0x340): undefined reference to `non-virtual thunk to cricket::VideoCapturer::AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>*, rtc::VideoSinkWants const&)'
src/rtspvideocapturer.o:(.rodata+0x344): undefined reference to `non-virtual thunk to cricket::VideoCapturer::RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>*)'
src/rtspvideocapturer.o:(.rodata+0x380): undefined reference to `rtc::MessageQueue::Quit()'
src/rtspvideocapturer.o:(.rodata+0x384): undefined reference to `rtc::MessageQueue::IsQuitting()'
src/rtspvideocapturer.o:(.rodata+0x388): undefined reference to `rtc::MessageQueue::Restart()'
src/rtspvideocapturer.o:(.rodata+0x38c): undefined reference to `rtc::MessageQueue::IsProcessingMessages()'
src/rtspvideocapturer.o:(.rodata+0x390): undefined reference to `rtc::MessageQueue::Get(rtc::Message*, int, bool)'
src/rtspvideocapturer.o:(.rodata+0x394): undefined reference to `rtc::MessageQueue::Peek(rtc::Message*, int)'
src/rtspvideocapturer.o:(.rodata+0x398): undefined reference to `rtc::MessageQueue::Post(rtc::Location const&, rtc::MessageHandler*, unsigned int, rtc::MessageData*, bool)'
src/rtspvideocapturer.o:(.rodata+0x39c): undefined reference to `rtc::MessageQueue::PostDelayed(rtc::Location const&, int, rtc::MessageHandler*, unsigned int, rtc::MessageData*)'
src/rtspvideocapturer.o:(.rodata+0x3a0): undefined reference to `rtc::MessageQueue::PostAt(rtc::Location const&, long long, rtc::MessageHandler*, unsigned int, rtc::MessageData*)'
src/rtspvideocapturer.o:(.rodata+0x3a4): undefined reference to `rtc::MessageQueue::PostAt(rtc::Location const&, unsigned int, rtc::MessageHandler*, unsigned int, rtc::MessageData*)'
src/rtspvideocapturer.o:(.rodata+0x3a8): undefined reference to `rtc::Thread::Clear(rtc::MessageHandler*, unsigned int, std::list<rtc::Message, std::allocator<rtc::Message> >*)'
src/rtspvideocapturer.o:(.rodata+0x3ac): undefined reference to `rtc::MessageQueue::Dispatch(rtc::Message*)'
src/rtspvideocapturer.o:(.rodata+0x3b0): undefined reference to `rtc::Thread::ReceiveSends()'
src/rtspvideocapturer.o:(.rodata+0x3b4): undefined reference to `rtc::MessageQueue::GetDelay()'
src/rtspvideocapturer.o:(.rodata+0x3c0): undefined reference to `rtc::Thread::Send(rtc::Location const&, rtc::MessageHandler*, unsigned int, rtc::MessageData*)'
src/rtspvideocapturer.o: In function `cricket::VideoCapturer::~VideoCapturer()':
/home/osboxes/webrtc/src/media/base/videocapturer.h:80: undefined reference to `rtc::TimestampAligner::~TimestampAligner()'
/home/osboxes/webrtc/src/media/base/videocapturer.h:80: undefined reference to `rtc::CriticalSection::~CriticalSection()'
/home/osboxes/webrtc/src/media/base/videocapturer.h:80: undefined reference to `cricket::VideoAdapter::~VideoAdapter()'
/home/osboxes/webrtc/src/media/base/videocapturer.h:80: undefined reference to `vtable for cricket::VideoCapturer'
/home/osboxes/webrtc/src/media/base/videocapturer.h:80: undefined reference to `vtable for cricket::VideoCapturer'
src/rtspvideocapturer.o: In function `rtc::VideoSourceBase::~VideoSourceBase()':
/home/osboxes/webrtc/src/media/base/videosourcebase.h:23: undefined reference to `vtable for rtc::VideoSourceBase'
src/rtspvideocapturer.o: In function `rtc::VideoBroadcaster::~VideoBroadcaster()':
/home/osboxes/webrtc/src/media/base/videobroadcaster.h:32: undefined reference to `rtc::VideoSinkWants::~VideoSinkWants()'
/home/osboxes/webrtc/src/media/base/videobroadcaster.h:32: undefined reference to `rtc::CriticalSection::~CriticalSection()'
/home/osboxes/webrtc/src/media/base/videobroadcaster.h:32: undefined reference to `vtable for rtc::VideoBroadcaster'
/home/osboxes/webrtc/src/media/base/videobroadcaster.h:32: undefined reference to `vtable for rtc::VideoBroadcaster'
src/rtspvideocapturer.o: In function `rtc::VideoSourceBase::SinkPair::~SinkPair()':
/home/osboxes/webrtc/src/media/base/videosourcebase.h:31: undefined reference to `rtc::VideoSinkWants::~VideoSinkWants()'
collect2: error: ld returned 1 exit status
make: *** [webrtc-streamer] Error 1
Anyone can help me? I'm using ubuntu trusty in vmware workstation.

Thanks

mpromonet
Posts: 13
Joined: Sun Sep 02, 2012 9:04 am

Re: WebRTC streaming of raspicam

Wed Nov 01, 2017 10:30 am

@codeforge

It should work on trusty, the automatic build on travis succeeded https://travis-ci.org/mpromonet/webrtc- ... /294472842

Did you build webrtc using gn & ninja ?

Best Regards,

Michel.

RaspiBeginner
Posts: 2
Joined: Sun Jan 21, 2018 7:53 pm

Re: WebRTC streaming of raspicam

Sun Feb 04, 2018 10:17 pm

This is honestly great!! However, I have one question. Is there a way to use this streamer to connect to an appRTC room (which can be accessed on a computer)? Please let me know how!!

Thanks

mpromonet
Posts: 13
Joined: Sun Sep 02, 2012 9:04 am

Re: WebRTC streaming of raspicam

Sun Feb 11, 2018 8:17 pm

Hi RaspiBeginner,
This should be possible like connecting to webrtc-streamer to janus-gateway.
I made some tries https://github.com/mpromonet/webrtc-str ... pprtc.html.
It is able to join the apprtc room, but there is a problems establishing ICE connection.
Best Regards,
Michel.

slipjig
Posts: 1
Joined: Thu Apr 18, 2013 10:59 pm

Re: WebRTC streaming of raspicam

Sun Jul 29, 2018 3:26 am

Hi,
First off, thank you for creating this project!

I am running a Raspberry Pi 3, which runs 64-bit ARM v8, and I'm having trouble running the released binaries as well as the Docker image. Do you have any plans to provide a version for RPi 3? If not I may try building it as you did on Ubuntu trusty, but I'm not especially familiar with gcc/make so it will probably be painful :)

Thanks,
Mike

Return to “Camera board”