Automatic resolution switch

djuka

Member
Hi, I have set video resolution like this:

Code:
video:
{
    width: {min:320,max:640},
    height: {min:240,max:480}
}
On mobile devices I get recordings always 640x480 even if the network is slow.
Is there a possibility to automatically switch from 640x480 to 320x240 if the network is slow?
 

Max

Administrator
Staff member
Good day.
Is there a possibility to automatically switch from 640x480 to 320x240 if the network is slow?
Yes, but you have to configure WCS and write some client side code:
1. Configure the server for publishing quality check
Code:
inbound_video_rate_stat_send_interval=1
then restart server
2. While publiushing a stream, handle CONNECTION_QUALITY.UPDATE event and republish the stream with lower resolution if channel quality becomes BAD
JavaScript:
var CONNECTION_QUALITY = Flashphoner.constants.CONNECTION_QUALITY;
...
// Function to publish a stream
function publish() {
    ...
    publishStream = session.createStream({
        name: streamName,
        display: localVideo,
        cacheLocalResources: true,
        constraints: constraints
        ...
    }).on(CONNECTION_QUALITY.UPDATE, function (quality, clientFiltered, serverFiltered) { 
       if (quality == CONNECTION_QUALITY.BAD) {
             // Stop the stream publishing
             publishStream.stop();
             // Update resolution
             constraints.video.width = 320;
             constraints.video.height = 240;
             // Publish stream again
             publish();
       }
    });
    publishStream.publish(); 
}
Please read the details here
 
Top