New Setup - Digital Ocean Droplet

Forum home -> Tech Talk -> View topic

Post

Posted
Rating:
#312 (In Topic #64)
Avatar
Standard member

Video Streaming from Drone to Static IP

Hi Guys,

I watched your video recently about re-streaming from Digital Ocean and saw similarities to what I hope to accomplish with my current project.  I am building a heavy lift hexcopter and am using a Pixhawk flight controller attached to an Odroid XU4 companion computer running Linux, Ubuntu and Gstreamer.  I want to stream my video feed to the static IP that is associated with the Digital Ocean droplet that I just created.  The ultimate goal is to allow remote viewing of the video stream by authorized users.  the Gstreamer side is complete and I am ready to direct the video stream toward my static IP.

I'm sure ther are many ways to accomplish this, but I want to pose the question to you and get your input as to the best and simplest way to set up the droplet to allow for this functionality.  Nothing fancy, just reliable with low latency.  What do I need to do to my droplet (if anything) in order to accomplish this task?

Thank you for your help.


 
Online now: No Back to the top

Post

Posted
Rating:
#313
Avatar
Standard member
I went ahead and setup NGINX on my Digital Ocean droplet and am able to stream my UAV video with about an 8 second latency.   New topics…  should I configure a firewall and how can I optimize the NGINX config file so I can view the stream with VLC media player on my Android smart phone?

I deleted everything in my config file except for rtmp:

rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application live {
                        live on;
                        record off;
                }
        }
}
Online now: No Back to the top

Post

Posted
Rating:
#314
Avatar
NOTS Staff
Hi there!

Commenting on your usage of NGINX as a media server: I find it great for re-streaming to other platforms, but not suitable as a platform in itself, for my needs. Streaming services like Vimeo/Livestream, YouTube, etc. have content distribution networks that are able to transcode into better delivery formats and handle a lot of load; your one droplet, on the other hand, might have issues with too many people trying to read the raw stream from it at the same time. If it's only going to be a small number of users, though, then it might very well be fine.

It sounds like you already got that part figured out, which is great. If you can view the stream in VLC on your computer, you should be able to view it on VLC for Android; RTMP is supported on VLC for Android. There's not anything you can "optimize" in the NGINX config file with regards to that.

As far as firewalls go, that's an option since you're reading the stream directly, but it will only work if you have static IP addresses for the devices you're accessing the video from (assuming a simple setup). If the video is going over the internet, that means you'll need static public IPs. If you're just streaming over a local network, then the firewall would be easier to set up, but also less necessary. I think you already know that stuff. The RTMP port is TCP 1935 (which you can change in your config file), so that's what you can restrict by IP if you want to do so.

Are there currently any sticking points for you/concrete questions I can answer? If I'm wrong about being able to view the video from your server already, let me know and I can help with that. Otherwise, it sounds like you already have things set up. NGINX isn't a fully built-out streaming server, but it should be fulfilling your basic requirements already, unless I'm overlooking something.
Online now: No Back to the top

Post

Posted
Rating:
#315
Avatar
Standard member
Yep, the NGINX seems to be working well.  Now, please tell me if there is a better way of doing this…… as customers come online with Hawkeye, I had envisioned simply creating another droplet for them inside my Digital Ocean account that would be set up the same way mine is.  This way I can provide streaming services and support to them perpetually.  There will never be very many users viewing any active video stream at one time since it will be very restricted in nature.

Can I allow more than one video stream to be active on a droplet at one time in the case that they have multiple aircraft flying concurrently?  Could this be accomplished by streaming to another port, or would I need to create a new droplet for each aircraft?

For example, could a droplet for customer X with 2 aircraft needing to stream at the same time in their fleet be accommodated with the following configuration:

rtmp {
        server {
                listen 1935;                        (uav #1)
                chunk_size 4096;

                listen 1936;                        (uav #2)
                chunk_size 4096;


                application live {
                        live on;
                        record off;
                }
        }
}

And so on……  correct?
Online now: No Back to the top

Post

Posted
Rating:
#316
Avatar
NOTS Staff

Hawkeye said

Can I allow more than one video stream to be active on a droplet at one time in the case that they have multiple aircraft flying concurrently?  Could this be accomplished by streaming to another port, or would I need to create a new droplet for each aircraft?

I'm tempted to say that instead of specifying two ports like you're doing in your example, you actually want to specify two applications, which can be independently streamed to/read from by providing the corresponding URLs. You may still need to separate out the droplets if security is a concern, because the NGINX RTMP module doesn't support username/password authentication, like I mentioned in my video (at least, it didn't when I made the video– I see that the module has gained HLS support since then, but I still don't see authentication anywhere.)

If we think about it, NGINX is binding the port it's listening on, and if you have one NGINX instance handling multiple streams, it can do all of its communication on one port as long as it can tell the streams apart by URL/application name. If you were running several different instances of NGINX, then you could have it separated by port, as long as your streaming software on the drones lets you specify a custom port. I'd try multiple applications first, then move on to ports if that doesn't work.
Online now: No Back to the top

Post

Posted
Rating:
#317
Avatar
Standard member
Thank you for your insight.  I have a couple of questions for you.  I have been developing a Linux bash script to automate the startup of the streaming process.  In order to do some basic error handling, I was testing segments of the program by issuing ping commands to check connectivity.  After about 10 or 15 pings, the IP stopped responding.  No pings, ssh or stream commands will work.  Per our earlier discussion, I deliberately did not create a firewall for the droplet at Digital Ocean.

I have rebooted the droplet to no avail.  I have contacted their tech support but have not received a reply yet.

My questions are as follows,  it appears that some kind of threshold has been met and the IP is no longer accepting incoming connection requests.  Does Digital Ocean have their own firewall that is in place, or is this something that is built into NGINX?    How can I increase the threshold limit?

What are your thoughts?
Online now: No Back to the top

Post

Posted
Rating:
#318
Avatar
NOTS Staff

Hawkeye said

After about 10 or 15 pings, the IP stopped responding.  No pings, ssh or stream commands will work.  Per our earlier discussion, I deliberately did not create a firewall for the droplet at Digital Ocean.

I have rebooted the droplet to no avail.  I have contacted their tech support but have not received a reply yet.

My questions are as follows,  it appears that some kind of threshold has been met and the IP is no longer accepting incoming connection requests.  Does Digital Ocean have their own firewall that is in place, or is this something that is built into NGINX?    How can I increase the threshold limit?

DigitalOcean certainly does not have any sort of firewall that would block a ping.

I assume that you rebooted the droplet by power off & back on through the DigitalOcean web interface. Do you see any stats on their interface about system resource usage?

There is no "threshold limit" built into NGINX to my knowledge. Even if some sort of threshold for maximum connections had been met somewhere on your system, there should be no active connections after rebooting your droplet, so you should still be able to connect again.

Possible reasons for not being able to SSH into a droplet include the SSH daemon being stopped or the system's resources being tied up. Seeing as you can't ping either, I would assume it's a resource issue, unless there is a firewall in play somewhere (once again, that would be something you set up on your droplet, as DigitalOcean won't be blocking pings, certainly not by default.)

Hypothetically, if you had something in your NGINX configuration or your Bash script that completely tied up your system's resources, and NGINX and/or your Bash script were set to start up automatically with your system (e.g. with Systemd/your init), I could imagine your droplet booting up, the script/NGINX being started, and the system immediately (and automatically) being tied up, not allowing you to connect any more.

I usually use Linode these days, but I recall that DigitalOcean had a web-based console that you can access through your web browser. That web-based console would give you a "direct" connection into your droplet's TTY (they're able to provide this cheaply because the droplet is actually a VM). Are you able to access the web console? Watching the machine boot up/trying to connect through the web/"physical" console and trying to stop whatever process is crashing the system before it starts would be my next step if that's what is happening.
Online now: No Back to the top

Post

Posted
Rating:
#319
Avatar
Standard member
Making great progress.  Now it's time to automate the streaming process.  I've written a Linux executable script with error handling routines and have set it up to run when the companion computer boots up.  One problem remains…..

I want to send notification text messages to my android phone from different points in the body of the bash script upon failure of any part of the streaming process to assist in debugging while in the field.  Under normal conditions in the field, the monitor will not be attached to the Odroid.
 
I was trying to use the curl command, but always get the message:  " could not resolve host "
 
I’ve tested sending a message from my email to text to and from my android phone to email and it works flawlessly, so I know there is nothing wrong with the sms gateway.
 
Is there something missing in my Linux distro on the Odroid that is causing the command to fail, or do I simply have the command syntax incorrect.
 
curl 1234567890@txt.att.net  “This is a test message”
 
also tried this:
 
curl 1234567890@mms.att.net  “This is a test message”
 
Or is there simply a better way to send notifications other than the curl command……
Your advice would be greatly appreciated
 
Online now: No Back to the top

Post

Posted
Rating:
#320
Avatar
NOTS Staff

Hawkeye said

Making great progress.  Now it's time to automate the streaming process.

Whoa, whoa, whoa, whoa, whoa… what happened to the droplet connectivity issue? What was the problem? How did you solve it? Was the web console helpful?

Hawkeye said

I want to send notification text messages to my android phone from different points in the body of the bash script upon failure of any part of the streaming process to assist in debugging while in the field.  Under normal conditions in the field, the monitor will not be attached to the Odroid.
 
I was trying to use the curl command, but always get the message:  " could not resolve host "
 
I’ve tested sending a message from my email to text to and from my android phone to email and it works flawlessly, so I know there is nothing wrong with the sms gateway.
 
Is there something missing in my Linux distro on the Odroid that is causing the command to fail, or do I simply have the command syntax incorrect.
 
curl 1234567890@txt.att.net  “This is a test message”
 
also tried this:
 
curl 1234567890@mms.att.net  “This is a test message”
 
Or is there simply a better way to send notifications other than the curl command……

Yeah, that's not what cURL is for… there are ways to send email with cURL, but it's usually used for downloading, not sending mail. If you read up on the syntax, you'll see that what you're doing doesn't really make sense: https://www.computerhope.com/unix/curl.htm

If you want to go the email-to-SMS route, I'd personally be using Sendmail or Postfix. Depending on if you have your Droplet all configured to send mail correctly, you might have an easier time using SSMTP and configuring it up to send email from an email account you have elsewhere. Here are some links that should get you started:

https://unix.stackexchange.com/questions/363814/simplest-way-to-send-one-line-mail-out-via-command-line-using-gmail
https://www.computerhope.com/unix/usendmai.htm
http://www.postfix.org/sendmail.1.html

If you told us what SMS gateway you're using, I would see what kind of APIs they have available… but email is probably going to be simplest for you to get set up.
Online now: No Back to the top
1 guest and 0 members have just viewed this.