Live streaming from Odroid to Android Phone

Moderators: odroid, mdrjr

Live streaming from Odroid to Android Phone

Unread postby mdali92 » Sat Jul 02, 2016 2:56 am

Hi,

I'm very new to Odroid and trying to do a little project here.

My project is :
Use a camera with Odroid and do live streaming via Wifi hotspot. This live feed can be viewed by an Android Smartphone.

So, basically I need to interface the odroid with a camera which will provide video feed. Then I need to use a wifi module which will open a hotspot to which clients can connect. The Android smartphone should be able to connect to this hotspot and view the live feed stream.

The below pic represents the system graphically to give a clear picture :
Image

Now, since I'm new to Odroid, I want someone to just give me rough brief guideline on how do I go about doing this and which modules (camera, wifi) I can use etc.. I don't want an entire step-by-step tutorial, just brief guidlines would be highly appreciated..

Thank you very much
mdali92
 
Posts: 5
Joined: Sat Jul 02, 2016 2:46 am
languages_spoken: english

Re: Live streaming from Odroid to Android Phone

Unread postby mad_ady » Sat Jul 02, 2016 4:00 am

There's an easy way and a hard way. The easy way is to use Android on odroid and the myriad of webcam apps such as Alfred. The harder way is to use linux and ffmpeg and create a RTSP stream (viewable with RTSP Player)
User avatar
mad_ady
 
Posts: 4921
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Live streaming from Odroid to Android Phone

Unread postby mdali92 » Sat Jul 02, 2016 6:55 am

I'm afraid I'll have to opt for the hard way : Linux.

Because this project is actually a sub-part of a bigger project which requires Linux to be run on Odroid for some other functionality.

So yeah, is there any tutorial for what you mentioned?

Also, what about the Wifi hotspotting?
mdali92
 
Posts: 5
Joined: Sat Jul 02, 2016 2:46 am
languages_spoken: english

Re: Live streaming from Odroid to Android Phone

Unread postby mad_ady » Sat Jul 02, 2016 12:48 pm

I am using Linux + C2 + 720p webcam + ffmpeg to produce RTSP streams. I wanted to do a how-to but lacked the time to polish it. I'll try to post some commands to get you started this tuesday... Ping me if I forget :)
For the wifi AP Hardkernel has a wiki page (I don't have the link but search for hostapd)
User avatar
mad_ady
 
Posts: 4921
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Live streaming from Odroid to Android Phone

Unread postby mdali92 » Sat Jul 02, 2016 2:27 pm

^ Thanks a lot mate!

Meanwhile if you are free, can you breeze through the link below. If I try to implement this, will it work in my case?

http://www.area536.com/projects/streaming-video/

Cheerz ;)
mdali92
 
Posts: 5
Joined: Sat Jul 02, 2016 2:46 am
languages_spoken: english

Re: Live streaming from Odroid to Android Phone

Unread postby mad_ady » Sun Jul 03, 2016 2:01 am

Well, you're on the right track. My solution also uses ffmpeg + ffserver with some tweaks for C2. I'll try to post something when I get to work on tuesday
User avatar
mad_ady
 
Posts: 4921
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Live streaming from Odroid to Android Phone

Unread postby mdali92 » Tue Jul 05, 2016 11:40 am

Hi friend, waiting for your instructions :D

Regards and have a nice day
mdali92
 
Posts: 5
Joined: Sat Jul 02, 2016 2:46 am
languages_spoken: english

Re: Live streaming from Odroid to Android Phone

Unread postby mad_ady » Tue Jul 05, 2016 2:54 pm

Ok, here's what I'm doing:

1. Set up mjpg_streamer (https://github.com/jacksonliam/mjpg-streamer). This will allow you to create a web server that can stream mjpeg from your camera or get screenshots. I use it to filter out bad frames from the camera (which sometimes cause the image to flicker violently). Start mjpeg-streamer with something like this:

Code: Select all
/usr/local/bin/mjpg_streamer  -i 'input_uvc.so -r 1280x720 -m 50000 -n -f 15 -q 95 -d /dev/video0' -o 'output_http.so -p 8090 -w /usr/local/share/mjpg-streamer/www/ -c yourusername:yourpassword'


Check mjpg_streamer's help output for details, but -m drops frames lower than 50k assuming they are incomplete. This means your cam will not work correctly in low light conditions (or when jpeg compression reduces the frame under 50Kb. Regular 720p frames from my cam are around 120kb.

2. Set up ffserver with this config (/etc/ffserver.conf)
Code: Select all
HTTPPort 8099
HTTPBindAddress 0.0.0.0
RTSPPort 554
RTSPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 1000
CustomLog -
<Feed mjpg-streamer.ffm>
File /tmp/mjpg-streamer.ffm
FileMaxSize 200K
ACL allow 127.0.0.1
</Feed>
<Stream live.h264.sdp>
Format rtp
Feed mjpg-streamer.ffm
 # Streaming settings
</Stream>
<Stream stat.html>
Format status
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255
</Stream>
<Redirect index.html>
URL http://www.ffmpeg.org/
</Redirect>


You can start ffserver with this command:
/usr/bin/ffserver

At this point ffserver will act as a RTSP gateway and listen for commands, but it will not start the stream. It needs ffmpeg to transcode the mjpg data from mjpg_streamer as h264.

3. Use ffmpeg to create a h264 stream:
Code: Select all
/usr/bin/ffmpeg  -framerate 5 -f mjpeg -i http://yourusername:yourpassword@127.0.0.1:8090/?action=stream -f alsa -i plughw:CARD=Camera,DEV=0 -acodec libmp3lame -c:v libx264 -preset ultrafast -r 5 -pix_fmt yuv420p -b:v 1500k -x264-params keyint=30:no-scenecut=1 -vf "drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf: text='My Webcam %{localtime\\:%F %T}': fontcolor=white@0.8: x=7: y=5" -override_ffserver http://localhost:8099/mjpg-streamer.ffm


FFMpeg will read from mjpg_streamer via its webserver interface, add sound from the webcam's MIC, transcode it to 1500k CBR H264 video, add a text overlay with "My Webcam" and the local time and pass the contents to ffserver.

Note that with this setup ffmpeg will continuously transcode even if there are no clients connected in ffserver. It should make moderate use of your CPU, but it will raise the temperature by 10 degrees (in my tests).

For my use (where consumers connect occasionally) I have a trigger that starts ffmpeg streaming and I only stream when users are connected to reduce load.
But it's a work in progress - needs more polishing.

To view the stream from android I use this app: https://play.google.com/store/apps/deta ... .app&hl=en with this URL: rtsp://odroid-ip:554/live.h264.sdp
User avatar
mad_ady
 
Posts: 4921
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Live streaming from Odroid to Android Phone

Unread postby mdali92 » Tue Jul 05, 2016 3:39 pm

Thanks a lot mate! That was really helpful. I'll let you know how it goes :D


Cheers :)
mdali92
 
Posts: 5
Joined: Sat Jul 02, 2016 2:46 am
languages_spoken: english

Re: Live streaming from Odroid to Android Phone

Unread postby ps10 » Thu Aug 18, 2016 3:05 am

mdali92 wrote:I'm afraid I'll have to opt for the hard way : Linux.

Because this project is actually a sub-part of a bigger project which requires Linux to be run on Odroid for some other functionality.

So yeah, is there any tutorial for what you mentioned?

Also, what about the Wifi hotspotting?


Hi, did you got wifi module to work as a hotspot. I read comments and found this http://odroid.com/dokuwiki/doku.php?id=en:xu4_wlan_ap link. One can create using this. If you got this to work , I am facing a problem. I followed all the steps of the Wifi module 3 and in my Wifi it shows OdroidAP as AccessPoint but its not connecting to it when I enter passphrase.

I am using NetGear, Inc. WNA1000M 802.11bgn [Realtek RTL8188CUS] Adapter. Any suggestions where I may be wrong.?

Thanks
ps10
 
Posts: 16
Joined: Wed Aug 03, 2016 6:31 am
languages_spoken: English
ODROIDs: XU4

Re: Live streaming from Odroid to Android Phone

Unread postby mikemoy » Sun Apr 22, 2018 3:30 pm

mad_ady wrote:Ok, here's what I'm doing:


Thanks for explaing all this. I have been going mad trying to do somthing I thought would be simple. Plug my USB webcam in and stream it to my PC browser. My problem starts with I need audio and this is the first hope I have seen for that.
I am curious though. I see that you have yours set for 5fps. Can the C0 handle more? I need at least 10 fps.
mikemoy
 
Posts: 187
Joined: Sat Sep 20, 2014 10:31 pm
Location: Chicago, IL
languages_spoken: english
ODROIDs: ODROID-U3, ODROID-C1

Re: Live streaming from Odroid to Android Phone

Unread postby mad_ady » Sun Apr 22, 2018 7:49 pm

Since I wrote that, I managed to perfect it further: viewtopic.php?f=52&t=23503

So, in short I couldn't get more than 7 fps real-time encoding on the C2, but I could get 25/30fps when doing hardware encoding with c2cap/c2enc. I know @crashoverride has also custom branches for C1 which should work on the C0 as well, but I don't know how well they work.

Here are the problems that remain:
1. c2cap/c2enc introduce a 5-6s delay from when data is fed into it until frames come out. This is a problem for sound (sound is 5-6s ahead of the video), or if you want real-time feedback. Sound can be fixed, but I haven't managed to work it out - feedback welcome).
2. If using ffsrver trigger, the client might time-out a few times before starting because of #1.

Good luck!
User avatar
mad_ady
 
Posts: 4921
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Live streaming from Odroid to Android Phone

Unread postby mikemoy » Sun Apr 22, 2018 10:44 pm

Thanks! I never would have thought these days something that looks so simple is turning out to be quite complex.
mikemoy
 
Posts: 187
Joined: Sat Sep 20, 2014 10:31 pm
Location: Chicago, IL
languages_spoken: english
ODROIDs: ODROID-U3, ODROID-C1


Return to General Chat

Who is online

Users browsing this forum: No registered users and 1 guest