Streaming Using NGINX with RTMP | Quality of Video Issues

Howdy folks!

Austiego here...

So I have this issue... and try as I might, I cant seem to get it figured out.

I am a light Linux user, so not a ton of experience, but a decent willingness to learn :-)

---The background---

So buddy and I like to do casual streams to Twitch/Youtube on the weekends for fun. After seeing Wendell and Grizzle's video on setting up an RTMP server using NGINX I decided to set up an Ubuntu machine in my home using NGINX so my buddy and I can stream to it. I then use another dedicated encoding machine in my home to grab both streams from the RTMP server, combine them in one stream and encode/rebroadcast to twitch/youtube.

---The problem---

The problem that I am having is when I retrieve the stream on my encoding machine from my RTMP server, the quality of the stream has been reduced dramatically. By quality, I mean the video quality. It looks fuzzy. The framerate and audio appear to be good, the video quality just does not look that great.

I've tried both OBS and XSplit, and they both show the same fuzzyness when receiving the RTMP streams.

When I do a local stream using XSplit to stream directly on my LAN to my encoding machine, the quality is as I would expect it. I've also tried different resolutions.

Streaming Setup...

Both HQ streams to RTMP server... 1080p 60fps @ 8000 kbits/sec

---Things I've tried/considered---

In an effort to troubleshoot my problem... I have tried/considered the following things...

  1. I'm blessed with a decent internet connection in my neighborhood. I ran the gambit of speed and throughput tests. Everything looks to be plenty fast enough with a good amount of reserve overhead.

  2. At first I was running a raspberry pi 3 with Raspbian Jessie Lite for my RTMP server, but I suspected the 10/100 port on the pi might bottleneck my incoming connections since in total they are around 16 Mbits. I loaded Ubuntu Gnome on a laptop with a gigabit Ethernet port and set everything up again.

  3. I've tried goofing around with the settings in XSplit and OBS, but other than cropping and resizing the individual streams, there is not much else I can do with them once I receive them from the RTMP server.

---What I suspect the problem might be---

To be honest, what it looks like is happening, is the RTMP server is downscaling the stream from 1080p to something smaller. When I then add the streams to my encoding PC, it looks similar to stretching a lower resolution video to a larger resolution stage... if that makes sense.

I have been looking at the NGINX website trying to determine if I would be able to add a few lines in the NGINX config file to make sure my video being received and retransmitted is not getting scaled or anything like that. Unfortunatly, I have not been able to figure it out.

Everything I read tells me that the quality of the retransmitted stream from my RTMP server should be at the same resolution and quality as the stream coming into the server.

Put simply this does not appear to be the case...

Has anybody else had this problem? Does anybody know of anything I could try?

My preferred software is XSplit, althought I love OBS... just my preference.

What do you guys/gals think?


Rtmp on nginx?

Run top while streaming. No high cpu usage? Guaranteed it's not downscaling. How would it? Lack of computation happening?

The only other option is that the packets you are sending just aren't making it. That would be my guess.


Thanks, Wendell!

I did not expect to get a response from Wendell himself!!

Thank you for your time, Sir! You are truly an inspiration to my nerdy curiosities and continuous need to tinker with things!

So I spent some time on this problem last night armed with the ammo you provided, Wendell...

You're right, nginx does not have the capability by itself to re scale the video. This was something I was pretty sure of, but in light of the issues I was having... I felt the need to question everything...

So! Here is what I found!

I decided to use VLC to view the stream coming directly from my RTMP server. This was surprisingly easy! A good tool to have in your tool belt... With VLC viewing the RTMP stream, I was able to verify both the video quality and the resolution and frame rate. It was my expected resolution and frame rate. Nginx rocks!!

Okay... quality is good up to the exit of the RTMP server... Now on to the encoding box...

When importing the stream from my RTMP server to my encoding machine with OBS, I noticed that the quality of the video was actually correct. My mention that the issue was common with both Xsplit and OBS above was not true. I guess when I came to that conclusion, I must have had a case of bit-brain with sleepy eyes.

And then came my epiphany... The problem was with my encoding PC's Xsplit setup. Xsplit uses a plugin called "RTMP plugin" to add a RTMP stream as an input. The plugin was developed by the developers at Xsplit, so I would expect it to be well integrated and set up.

Here is where it gets a little strange with a possible bug that I found...

I noticed that Xsplit was resizing the video from 1080p to 720p. This was what was causing my drop in quality. When adding the RTMP stream as an input, you do not get an opportunity to select the resolution of the input. With other inputs you can select what resolution you want to run the input at, or you can select the input to use the default (global) stage resolution... which in configurable. I ended up traversing to the plugin folder on my hard drive and opened up the config file with notepad++. The code in the file didn't quite make sense... I was expecting to see a command to set the resolution to something... 720p... or default... or something like that. I was unable to find anything of this sort. There were some variables that were being set in the config file with names that did not describe their purpose well. It must be that this config file is merely a subroutine of the larger code... perhaps in which global variables are declared...

In any event, I thought to myself when I created this input, if the global stage resolution was set to 720p, this might have forced my RTMP stream to be downscale to 720p.

I deleted my RTMP stream and recreated it with my global stage resolution at 1080p... and BAM! RTMP stream now running at 1080p!! When transitioning your global stage resolution, RTMP stream resolutions are not retroactive... Kind of a bug really...

All this tinkering... and that is what it ended up being.

I still see an oddity in which the RTMP stream is running at 50 fps instead of 60... but I can live with that. Perhaps an email to Xsplits support team for them to investigate.

I share this information for the community that has helped me so much in the past. Sorry I am such a long winded nerd...

If anybody needs any help getting a similar setup going, I am happy to share my experiences!

I was going to say use gstreamer but it seems you gotnit good now lol.