Discussion:
Problem when multi client connect to server using OndemandServerMediaSubsession
Nguyen Van Long
2014-09-03 10:32:42 UTC
Permalink
Dear Live555 team,

I recently develop an application that uses live555 library and operates
simple tasks such as: get video data from camera, decode video data, draw
something on video frame, encode video frame and streaming. My application
is a client (to camera) and also a server when streaming video data.

To get video data from camera, I modified the testRTSPClient in testProgs.
Data received then decoded using ffmpeg and drawn some text, shape using Qt.
After that, I use ffmpeg again to encode video frame (codec is MJPEG-4) and
put the output into a queue which will be streamed later.

To stream video from a queue, I write a class based on DeviceSource, the
function doGetNextFrame always read mpeg-4 package from queue and calls
FrameSource::afterGetting(this) when data available. I also write a class
called Mpeg4LiveServerMediaSubsession which subbed class from
OnDemandServerMediaSubsession and re-implement three virtual functions
(getAuxSDPLine, createNewFrameSource, createNewRTPSink). The
createNewFrameSource actually return the
MPEG4VideoStreamDiscreteFramer::createNew() with input source parameter is
my class based on DeviceSource described above.

I use VLC as client to connect to my server and play video stream.
Everything seems ok and my application works quite fine when there are less
than 4 clients connect to server. When the 4th client connect to server, the
video of all clients is getting slower, image is very bad, I cannot see
video content clearly .

I don't think the problem is with my network because I use LAN with a good
capable and even my server and client (VLC) in the same computer, this
problem still happens.

I have some more information here:

My processor : corei3 3.36 MHz, Memory (RAM): 4GB, When 4 client connect to
server, program uses 30% of memory, 49% of CPU

When 1 client (VLC) connect to server, from VLC tool I see that the content
birate is about 6000 - 7000 kb/s. It reduce to 4000 - 5000 kb/s when 2
clients connect to server, 2000 - 2500 kb/s when 3 clients connect to server
and 600 - 1500 kb/s when 4 clients connect to server.

Do you have any ideals with my problem and any suggestions to improve video
quality when there are many clients connect to server?



Thanks!



Regards,



Nguyen Van Long (Mr)

ESoft - Software Development

----------------------------------------------------------------------------
-

ELCOM CORP

Add: Elcom Building, Duy Tan Street, Cau Giay District, Ha Noi

Mobile: (+84) 936 369 326 | Skype: Pfiev.long | Web:
<applewebdata://60404A86-7623-48A0-9326-200D87BEDAD4/Bi%E1%BB%83u%20m%E1%BA%
ABu/www.elcom.com.vn> www.elcom.com.vn
Ross Finlayson
2014-09-03 11:25:27 UTC
Permalink
I also write a class called Mpeg4LiveServerMediaSubsession which subbed class from OnDemandServerMediaSubsession
When your class "Mpeg4LiveServerMediaSubsession"s constructor calls the "OnDemandServerMediaSubsession" constructor, is the "reuseFirstSource" parameter "True"? (This ensures that only one input source object is created at a time, regardless of how many RTSP clients connect to your server.
I use VLC as client to connect to my server and play video stream. Everything seems ok and my application works quite fine when there are less than 4 clients connect to server. When the 4th client connect to server, the video of all clients is getting slower, image is very bad, I cannot see video content clearly …
Are these 4 clients (running VLC) on 4 *separate* computers? The reason I ask this is that - a few months ago - someone else reported similar symptoms to what you're reporting. In that case, though, the problem was that they were running more than one copy of VLC on the same client computer, and it turned out that the problem was the client computer's CPU overhead (from running more than one copy of VLC), not the server computer (running your LIVE555-based code).

Assuming that the 4 clients (running VLC) are on 4 separate computers, then does anything change when you run "openRTSP" rather than VLC as your client (again, all on separate client computers)?

Also, are the clients requesting RTP-over-UDP streaming from your server, or RTP-over-TCP streaming? If any of them are requesting RTP-over-TCP streaming, then does anything change if they request RTP-over-UDP streaming instead?

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
Ross Finlayson
2014-09-04 13:04:25 UTC
Permalink
I had seen the answer at http://lists.live555.com/pipermail/live-devel/2014-September/thread.html although I didn’t received email from mailing list (may be our mail server’s down or something cause to lost email …)
You're on the mailing list, so you should be receiving mailing list messages. Perhaps your company's spam filter is incorrectly rejecting this mailing list's messages??
As your suggestions, I use VLC as client running in 4 separated computer (I think hardware in each computer is ok to run just one vlc), The “reuseFirstSource” is of course set to true but nothing changed, video again getting slower with bad image when the 4th or 5th client connect to server (All clients use RTP-over-UDP to request to server)
I also use “openRTSP” to get data from my server and write into files. The same thing happens when the 4th or 5th client connect to server (when the connection less than 4, everything is ok).
I suspect that you are approaching the capacity of your network (or at least the capacity of your server's OS to transmit packets on your network). The big problem here is your choice of codec: JPEG. This is a very inefficient codec for streaming. If you haven't already done so, see
http://www.live555.com/liveMedia/faq.html#jpeg-streaming

I suggest using H.264 instead of MJPEG.

Also, if your clients are all on the same LAN, you should stream via IP multicast rather than IP unicast. (Then, your server's network traffic will be independent of the number of clients.) To do this, you would use a "PassiveServerMediaSubsession" rather than an "OnDemandServerMediaSubsession" (and note the various "test*Streamer" demo applications, which stream via multicast, using a "PassiveServerMediaSubsession".

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
Nguyen Van Long
2014-09-05 01:30:36 UTC
Permalink
Dear Ross,

I would like to give many thanks for your suggestions. It seems you are
right in my case. I will try to use another codec (H.264) as well as change
from streaming unicast to multicast.

Thank again for your help.



From: Nguyen Van Long [mailto:***@elcom.com.vn]
Sent: Thursday, September 04, 2014 4:47 PM
To: live-***@lists.live555.com
Cc: ***@elcom.com.vn
Subject: RE: Problem when multi client connect to server using
OndemandServerMediaSubsession



Dear Ross,

I had seen the answer at
http://lists.live555.com/pipermail/live-devel/2014-September/thread.html
although I didn't received email from mailing list (may be our mail server's
down or something cause to lost email .) and I would like to thank you for
your quick answer.

As your suggestions, I use VLC as client running in 4 separated computer (I
think hardware in each computer is ok to run just one vlc), The
"reuseFirstSource" is of course set to true but nothing changed, video again
getting slower with bad image when the 4th or 5th client connect to server
(All clients use RTP-over-UDP to request to server)
I also use "openRTSP" to get data from my server and write into files. The
same thing happens when the 4th or 5th client connect to server (when the
connection less than 4, everything is ok).
It's glad if you could give me some more suggestions about this problem.

Thanks!


From: Nguyen Van Long [mailto:***@elcom.com.vn]
Sent: Wednesday, September 03, 2014 5:33 PM
To: live-***@lists.live555.com
Cc: ***@elcom.com.vn
Subject: Problem when multi client connect to server using
OndemandServerMediaSubsession



Dear Live555 team,

I recently develop an application that uses live555 library and operates
simple tasks such as: get video data from camera, decode video data, draw
something on video frame, encode video frame and streaming. My application
is a client (to camera) and also a server when streaming video data.

To get video data from camera, I modified the testRTSPClient in testProgs.
Data received then decoded using ffmpeg and drawn some text, shape using Qt.
After that, I use ffmpeg again to encode video frame (codec is MJPEG-4) and
put the output into a queue which will be streamed later.

To stream video from a queue, I write a class based on DeviceSource, the
function doGetNextFrame always read mpeg-4 package from queue and calls
FrameSource::afterGetting(this) when data available. I also write a class
called Mpeg4LiveServerMediaSubsession which subbed class from
OnDemandServerMediaSubsession and re-implement three virtual functions
(getAuxSDPLine, createNewFrameSource, createNewRTPSink). The
createNewFrameSource actually return the
MPEG4VideoStreamDiscreteFramer::createNew() with input source parameter is
my class based on DeviceSource described above.

I use VLC as client to connect to my server and play video stream.
Everything seems ok and my application works quite fine when there are less
than 4 clients connect to server. When the 4th client connect to server, the
video of all clients is getting slower, image is very bad, I cannot see
video content clearly .

I don't think the problem is with my network because I use LAN with a good
capable and even my server and client (VLC) in the same computer, this
problem still happens.

I have some more information here:

My processor : corei3 3.36 MHz, Memory (RAM): 4GB, When 4 client connect to
server, program uses 30% of memory, 49% of CPU

When 1 client (VLC) connect to server, from VLC tool I see that the content
birate is about 6000 - 7000 kb/s. It reduce to 4000 - 5000 kb/s when 2
clients connect to server, 2000 - 2500 kb/s when 3 clients connect to server
and 600 - 1500 kb/s when 4 clients connect to server.

Do you have any ideals with my problem and any suggestions to improve video
quality when there are many clients connect to server?



Thanks!



Regards,



Nguyen Van Long (Mr)

ESoft - Software Development

----------------------------------------------------------------------------
-

ELCOM CORP

Add: Elcom Building, Duy Tan Street, Cau Giay District, Ha Noi

Mobile: (+84) 936 369 326 | Skype: Pfiev.long | Web:
<applewebdata://60404A86-7623-48A0-9326-200D87BEDAD4/Bi%E1%BB%83u%20m%E1%BA%
ABu/www.elcom.com.vn> www.elcom.com.vn
David Cassany Viladomat
2014-09-12 13:03:18 UTC
Permalink
Dear Nguyen and Ross,

I am writing as an answer to this email loop because our similar issue
might be useful to you. Some days ago we just noticed a similar behaviour
of what Nguyen exposed lately. We have an RTSP server that uses live555
library and we were facing a similar issue of experimenting packet loss
when having multiple clients connected to the server. Finally today we had
time to make further tests to isolate the issue in order to exclude any
performance limitation and we concluded:

1-> one of our old cheap switches was introducing about 3% of packet loss
(keeping network equipment updated and fully functional is a must if you
don't want to become mad ;-) )

2-> our server has two interfaces one with a public IP and another behind
the NAT in our company. So it seams that only when the server is using both
interfaces simultaneously we have packet losses. Having clients only in the
public interface we could stream up to six clients (with HD h264 streams)
without any loses, the same happened if checking only clients from our
private LAN. But the interesting point is that having just a single client
in the private LAN simultaneously with a single client out of our LAN we
faced up to 5% of packet loss.

Our work around is to have the server with a single network interface (not
to be tempted to use both at the same time) which works like charm right
now. Hopefully this might be useful to you.

Best regards,
David Cassany
Post by Nguyen Van Long
Dear Ross,
I would like to give many thanks for your suggestions. It seems you are
right in my case. I will try to use another codec (H.264) as well as change
from streaming unicast to multicast.
Thank again for your help.
*Sent:* Thursday, September 04, 2014 4:47 PM
*Subject:* RE: Problem when multi client connect to server using
OndemandServerMediaSubsession
Dear Ross,
I had seen the answer at
http://lists.live555.com/pipermail/live-devel/2014-September/thread.html
although I didn’t received email from mailing list (may be our mail
server’s down or something cause to lost email 
) and I would like to thank
you for your quick answer.
As your suggestions, I use VLC as client running in 4 separated computer (I think hardware in each computer is ok to run just one vlc), The “reuseFirstSource” is of course set to true but nothing changed, video again getting slower with bad image when the 4th or 5th client connect to server (All clients use RTP-over-UDP to request to server)
I also use “openRTSP” to get data from my server and write into files. The same thing happens when the 4th or 5th client connect to server (when the connection less than 4, everything is ok).
It’s glad if you could give me some more suggestions about this problem.
Thanks!
*Sent:* Wednesday, September 03, 2014 5:33 PM
*Subject:* Problem when multi client connect to server using
OndemandServerMediaSubsession
Dear Live555 team,
I recently develop an application that uses live555 library and operates
simple tasks such as: get video data from camera, decode video data, draw
something on video frame, encode video frame and streaming. My application
is a client (to camera) and also a server when streaming video data.
To get video data from camera, I modified the testRTSPClient in testProgs.
Data received then decoded using ffmpeg and drawn some text, shape using
Qt. After that, I use ffmpeg again to encode video frame (codec is MJPEG-4)
and put the output into a queue which will be streamed later.
To stream video from a queue, I write a class based on DeviceSource, the
function doGetNextFrame always read mpeg-4 package from queue and calls
FrameSource::afterGetting(this) when data available. I also write a class
called Mpeg4LiveServerMediaSubsession which subbed class from
OnDemandServerMediaSubsession and re-implement three virtual functions
(getAuxSDPLine, createNewFrameSource, createNewRTPSink). The
createNewFrameSource actually return the
MPEG4VideoStreamDiscreteFramer::createNew() with input source parameter is
my class based on DeviceSource described above.
I use VLC as client to connect to my server and play video stream.
Everything seems ok and my application works quite fine when there are less
than 4 clients connect to server. When the 4th client connect to server,
the video of all clients is getting slower, image is very bad, I cannot see
video content clearly 

I don’t think the problem is with my network because I use LAN with a good
capable and even my server and client (VLC) in the same computer, this
problem still happens.
My processor : corei3 3.36 MHz, Memory (RAM): 4GB, When 4 client connect
to server, program uses 30% of memory, 49% of CPU
When 1 client (VLC) connect to server, from VLC tool I see that the
content birate is about 6000 – 7000 kb/s. It reduce to 4000 – 5000 kb/s
when 2 clients connect to server, 2000 – 2500 kb/s when 3 clients connect
to server and 600 – 1500 kb/s when 4 clients connect to server.
Do you have any ideals with my problem and any suggestions to improve
video quality when there are many clients connect to server?
Thanks!
*Regards,*
*Nguyen Van Long (Mr)*
ESoft - Software Development
-----------------------------------------------------------------------------
*ELCOM CORP *
Add: Elcom Building, Duy Tan Street, Cau Giay District, Ha Noi
Mobile: (+84) 936 369 326 | Skype: Pfiev.long | Web: www.elcom.com.vn
_______________________________________________
live-devel mailing list
http://lists.live555.com/mailman/listinfo/live-devel
Loading...