Resource icon

All Versions How to set up your own private RTMFP server using MonaServer

thomasJ

Member
thomasJ submitted a new resource:

How to set up your own private RTMFP server using MonaServer - tutorial RTMFP MonaServer broadcast

This article is inspired of the great guide of How to set up your own private RTMP server using nginx.

MonaServer is a tiny and scalable open source server which provide protocols RTMFP, RTMP, RTMPE, WebSocket and HTTP. Server applications are written in lua and clients just need to support one of these protocols.

The interest of MonaServer here is...

Read more about this resource...
 

thomasJ

Member
Hi,

I think it is possible in a scripting way, I don't know the protocol used to stream to Twitch, RTMP? In this case you should listen to onVideo an onAudio events in a lua application and resend the packets to Twitch via RTMP (using an RTMP library).

As it requires a bit of work I don't know if it is interesting for your needs. And I think streaming directly from OBS to Twitch will be easier and faster.

I think the best use of MonaServer with OBS is to set up your own channel, add other features (like remote control), and with some development you could set up a p2p channel at very low cost.

I hope it will help
 

LKNim

New Member
What to do if I got this on Windows?

Mona/Protocols.h[68] RTMFP server started on 0.0.0.0:1935 (UDP)
Mona/Protocols.h[68] RTMP server started on 0.0.0.0:1935 (TCP)
Mona/Protocols.h[60] HTTP server, Permission denied (address=0.0.0.0:80, reuseAddress=true, backlog=64)
 

FortuN

Member
What to do if I got this on Windows?

Mona/Protocols.h[68] RTMFP server started on 0.0.0.0:1935 (UDP)
Mona/Protocols.h[68] RTMP server started on 0.0.0.0:1935 (TCP)
Mona/Protocols.h[60] HTTP server, Permission denied (address=0.0.0.0:80, reuseAddress=true, backlog=64)


Also getting that error on Windows 8
 

thomasJ

Member
Hello LKNim and FortuN,

It's not an error, you have already a process listening on the port 80, maybe Skype or Apache? If you don't want to use the HTTP/WebSocket part of MonaServer you can continue without doing anything. Otherwise you can :
- kill the other process listening on the port 80 and restart MonaServer,
- or Configure the HTTP port of MonaServer in the file MonaServer.ini (create the file)
Here is a MonaServer.ini sample :
Code:
[HTTP]
port=8081

Thank you for your report, I will add it in the FAQ.
 

FortuN

Member
Thanks for help. However, now i can't get it to work in OBS.

After entering my FMS URL/Server ip in OBS to 0.0.0.0:1935
IqveXni.jpg





and press "Start Stream" i get an error saying


"Could not connect to server

RTMP_Connect0, Failed to connect to socket, the requested adress is not guilty in context"

And this is how mona looks after started


lpnUDVM.jpg




Edit* I got it to work using rtmp://127.0.0.1, however, i can only play it on VLC on this computer, when i try to play it up form my other computer in network it doesen't work. How could i achieve so i can play it up on my 2nd pc?
 
Last edited:

thomasJ

Member
Yes, you've done well to change the address ;)

It should work. Make sure that you can ping the pc where MonaServer is running (PC1) from your other computer (PC2) :
1. Open the command line tool on PC2
2. Run the following command : ping X.X.X.X (replace X.X.X.X with the address of PC1, not 127.0.0.1!)
3. If you have a response, it's ok, maybe your firewall is blocking incoming connections from PC2 to PC1.

To know if it comes from the firewall, try to disable it for a moment on PC1 and retry vlc connection.
 

FortuN

Member
So, after some testing i think i managed to get it working quite good.
I have yet to try it live to twitch but internal testing seem good using 2-pc setup.

However using Nvidia Nvenc at PC1 (Game comp) to PC2 (Stream comp) seems not to work nice since it gets stuttering and high fps drop. However i changed to Intel quick sync and it worked great! I don't know why it could be so since both work good otherwise, but streaming to the monaserver Nvidia seems to have some issues.

This is also by far the easiest thing to get working with 2-pc setup, just download and start the server on the stream computer and on gaming computer just enter the ip to the Monaserver computer and all set!

A tips is to use Video Source plugin to catch the RTMP, otherwise you could also use VLC to capture the rtmp and then have OBS to capture VLC, but Video source plugin seems to be the best way. Awesome!
 

iAmGreiG

New Member
Thanks for this. I have a slight issue with audio sync though.

From PC1 im encoding using quicksync.
PC2 im using the video source plugin to catch the rtmp stream.

After 5-10 mins of streaming the audio becomes out of sync on the stream / pc 2. I have tested pc 1 local recording and streaming to make sure its not being caused at source but its completely fine.

Somehow the audio/video is de-syncing on the second pc, has anyone else noticed this happening ? I will have to experiment with perhaps using vlc on the 2nd pc and see if perhaps its the plugin de-syncing .
 

thomasJ

Member
Hi guys,

Sadly I can't test it with quicksync and nvidia nvenc but I can confirm that it works well with x264+mp3 for me. You can try to decrease the audio/video quality, or check the "Automatic low latency mode" checkbox in the Advanced menu. What about the "Force desktop audio to use video timestamps..." checkbox?

Typically it is a problem of TCP (RTMP), if you can use a UDP client (RTMFP) like the sample in this tutorial you should no more encounter this kind of problem because if there is a congestion problem (like I think) UDP will drop frames to continue the "live" streaming.

Tell me if you have fixed your problem or if you want a sexier player :)
 

CvP

New Member
16/03 23:38:35.1 FATAL Server(20276) sources\Server.cpp[96] Server, bad allocation
16/03 23:38:35.1 WARN Server(20276) sources\Sessions.cpp[41] sessions are deleting
16/03 23:38:35.1 INFO Server(20276) sources\Publication.cpp[98] Publication test stopped
16/03 23:38:37.7 NOTE Server(20276) sources\Server.cpp[130] Server stopped​
What causes this error? The server just closes when this happens.
 

thomasJ

Member
16/03 23:38:35.1 FATAL Server(20276) sources\Server.cpp[96] Server, bad allocation
16/03 23:38:35.1 WARN Server(20276) sources\Sessions.cpp[41] sessions are deleting
16/03 23:38:35.1 INFO Server(20276) sources\Publication.cpp[98] Publication test stopped
16/03 23:38:37.7 NOTE Server(20276) sources\Server.cpp[130] Server stopped​
What causes this error? The server just closes when this happens.

Hi CvP,

With these informations I can't help you, you should send me more informations. Could you send me an email (jammetthomas AT gmail.com) with :
- the version of MonaServer that you use,
- the procedure to reproduce the issue,
- and all informations you think are relevant to help me to debug.

Thanks
 

CvP

New Member
Hi.

1. I'm not sure which version I have. I just downloaded it on 14th March.
2. No fixed repro steps. Just happens.
3. I didn't even create any ini file. Running with stock settings. Configured OBS as normal. After starting stream, it works just fine. However, after an hour or two (or three), MonaServer just quits. At first I didn't understand what was happening. After it happened a few times, I checked the log a while ago and found out these fatal errors.


The only thing I can tell is it happens after streaming for a long time.
 
Last edited:

thomasJ

Member
Hi.

1. I'm not sure which version I have. I just downloaded it on 14th March.
2. No fixed repro steps. Just happens.
3. I didn't even create any ini file. Running with stock settings. Configured OBS as normal. After starting stream, it works just fine. However, after an hour or two (or three), MonaServer just quits. At first I didn't understand what was happening. After it happened a few times, I checked the log a while ago and found out these fatal errors.


The only thing I can tell is it happens after streaming for a long time.

Ok, so I will do some tests of long sessions to see if I can reproduce your problem.
So your environment is Windows as I guess, which version of Windows?
How many users are connected to your instance of MonaServer in general?
For the moment you could try to install the last version I've released on sourceforge and run it with maximum log level :

MonaServer.exe /log=8
And when your issue happens please send me your log file (logs/log.0) by mail.

Thank you
 

thomasJ

Member
Hi petrichbg,

MonaServer can't publish to an external server as it doesn't implement the client part of the RTMP protocol.

- What kind of stream support twitch? RTMP and...?
- I don't know well Twitch but maybe you can restream from twitch to MonaServer.
 

DemonAura

New Member
Is there any way this could be set up to be read by a lua script in a Garry's Mod Cinema server? I can provide some of the source code to see if it's possible perhaps. Any idea?
 
Top