SDK questions

All the issues related to streaming of recorded media.

SDK questions

Postby tasoss » Sun Jul 09, 2017 1:29 pm

Hello.
a)I'm using ffmpeg in order to stream to udp://foo:50001/live/channel1
In case the stream is over i want to be informed somehow(for example the stream may have been corrupted for some reason).

So i have tried to use ServerStats COM object, GetMediaUsageSummary and i get :

<MediaResources>
<Resource Name="ch001" UsersNumber="1" Throughput="0"/>
</MediaResources>

From GetActiveLiveServerConnections i get
<xml>
<LiveConnections>
<Connection IPAddress="mpts://foo:50001" BroadcastAlias="channel1" InitiatedBy="Media Server" Activity="Receiving stream over MPEG2-TS"/>
</LiveConnections>
</xml>

In unreal media server configuration GUI i get the same information in live encoder connections.
After a few seconds it disappers and i get no xml(from the sdk).
I suppose that while i stream i should always get some kind of info from the sdk(until it ends).
After a few seconds it appears again.
What am i doing wrong?

b)I'm trying to use GetCurrentStats but i get an exception
System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

Int32 users;
Int32 sec;
rl.GetCurrentStats(out users, out sec);

Thanks!
tasoss
 
Posts: 0
Joined: Wed Jul 05, 2017 3:41 pm

Re: SDK questions

Postby admin » Mon Jul 10, 2017 10:19 am

Hello,

In case of MPEG2-TS UDP streaming, you cannot really get a timely notification from Unreal Media Server when the stream is over or broke, but you certainly can get the notification from ffmpeg.

With Unreal Media Server, you can only get some kind of notification when you have active viewers of that stream.
When you don't have any viewers, Unreal Media Server does not receive the stream and has no idea if the stream is OK. You can only get that from the encoder - ffmpeg.
So, when you have active viewers, then yes, you can use ServerStats COM object and you will receive entries for your live broadcast using methods GetMediaUsageSummary and GetActiveLiveServerConnections, like you did. If the stream breaks, these entries will disappear from the XML (you will still receive and empty XML document). You can probably use that as an indication that the stream broke. Note that Unreal Media Server will discover that MPEG2-TS stream broke only after 15 seconds since it broke.

Regarding GetCurrentStats exception, it's not clear why you are getting it; you are not showing how you create the rl object. also, try to do ref instead of out on parameters.

If instead of MPEG2-TS you would use RTMP publish from ffmpeg, then you could get a much faster answer about a broken stream using GetActiveLiveServerConnections method, regardless if there are active viewers or not. If ffmpeg is publishing, there will be an entry in the XML for this broadcast; if publishing broke, there will be no entry in the XML.
admin
Site Admin
 
Posts: 1029
Joined: Fri Aug 21, 2009 10:13 am

Re: SDK questions

Postby tasoss » Mon Jul 10, 2017 11:51 am

Thanks for answering.
I have created an interop using tlbimp and then
private LiveCountersClass rl = new ServerStatsLib.LiveCountersClass();
rl.GetCurrentStats....
It has been created as out so i can't use ref.

About the first problem i would like to try using RTMP publish as you have mentioned.
Is it enough to pass to ffmpeg -f flv udp://xx:5119/live/channel1 ?
I know it's not related to media server but i would appreciate it if you could answer me.
Thanks again.
tasoss
 
Posts: 0
Joined: Wed Jul 05, 2017 3:41 pm

Re: SDK questions

Postby admin » Mon Jul 10, 2017 12:48 pm

How to do RTMP publish with ffmpeg: find it in
http://umediaserver.net/umediaserver/faq.html

Example: "ffmpeg -re -i file.mp4 -acodec copy -vcodec copy -f flv rtmp://192.168.1.8:5130/live/Camera8/livestream"
admin
Site Admin
 
Posts: 1029
Joined: Fri Aug 21, 2009 10:13 am

Re: SDK questions

Postby tasoss » Mon Jul 10, 2017 1:40 pm

thanks!
tasoss
 
Posts: 0
Joined: Wed Jul 05, 2017 3:41 pm


Return to Streaming Files

Who is online

Users browsing this forum: No registered users and 1 guest

cron