With XPMobileSDK
Transmit fps and bandwidth to view it in each streaming video at the time of playing it (I have different videos at different resolutions, bandwidths and origins.
It can be done with XPMobileSDK or something personalized should be done, if someone has done it, you can support me giving me an example of how they did it.
its for web player in javascript.
Thanks I am at your service.
Hi Isaias,
As you know the Mobile server transcodes video from original codec, resolution and frame-rate (for example H.264 1920x1080@30 fps) to a series of a JPEG images with client specified resolution and rate (for example JPEG 640x360@15 fps).
So if you want to display the original camera to the Mobile server FPS and bandwidth (how the stream originated into the camera and reached the RS) I’m afraid that is not possible.
If however you want to display frame-rate and bandwidth of the transcoded stream that is running between Mobile server and your web application/player, you could easily implement it by yourself.
You should hook into the “videoConnectionReceivedFrame” (or whatever your callback for getting video frames is called - I’m using the name used in the samples).
You should have something like this into your code:
/**
* Executed on received frame.
*/
function videoConnectionReceivedFrame(frame) {
if (!drawing && frame.dataSize > 0) {
// perform measure here on the FPS and avr bandwidth
}
}
You just have to implement some component for average calculation.
The easiest way is to accumulate data for some fixed period (for example 3 to 5 seconds) and after that divide this accumulated data to the period and you will receive the average value. Principle is the same for both fps and bandwidth. The difference will be only in what you accumulate (1 for every frame for the fps and frame.dataSize for the bandwidth).
Petar Vutov, i have found where i can take that info now with your example, Thanks a lot for that.
But now I am looking for the formulas to obtain fps and bandwidth with the data that I now have, but what I find has similar uses, but the solution does not apply with the data that I already have, they will only have one to call GetFrameRate () or GetStreamBandwidth ().
How is it done in the server, but in mobile for web version?
Why I couldn’t calculate fps and bandwidth in Javascript.
Please, I am at your service.
Hi Isaias,
I’m not completely sure I fully understand what you have exactly in mind.
Of course it is possible to measure FPS and the bandwidth in the client.
Here you can find example of simple FPS meter component:
export default class FpsMeter {
constructor() {
this.frames = [];
this.span = 5000;
this.Fps = 0;
}
dequeueOldFrames(dateNow) {
var utcNow = dateNow;
while ((this.frames.length > 0) &&
((utcNow - this.frames[0]) > this.span)) {
this.frames.shift();
}
this.Fps = Math.round(this.frames.length / this.span * 1000);
}
onFrame() {
var dateNow = Date.now();
this.frames.push(dateNow);
this.dequeueOldFrames(dateNow);
}
}
You should create a instance of it per every steam you consume and call “onFrame” on every received video frame. After that you could access .Fps property in order to get the value of the FPS.
This code sample implements classical “moving window average” algorithm.