simulcast - consumer is selecting invalid temporal layer

Hi there,

I’m creating a video producer using the following code:

producer.transport({
  track,
  encodings: [
    { maxBitrate: 450000, scaleResolutionDownBy: 2 },
    { maxBitrate: 2500000, scaleResolutionDownBy: 1 },
  ], {
    videoGoogleStartBitrate: 500000,
  })

And keep getting the temporalLayer 2 selected when a consumer starts. After debugging the worker code I found it was caused by SimulcastConsumer::UseAvailableBitrate.


e[38;5;98;1mmediasoup:worker[pid:58818] e[0mRTC::RtpParameters::ValidateEncodings() | RtpParameters.ValidateEncodings e[38;5;98m+0mse[0m
  e[38;5;98;1mmediasoup:worker[pid:58818] e[0mRTC::RtpParameters::ValidateEncodings() | RtpParameters.ValidateEncodings encoding [spatial:1 e[38;5;98m+0mse[0m
  e[38;5;98;1mmediasoup:worker[pid:58818] e[0mRTC::RtpParameters::ValidateEncodings() | RtpParameters.ValidateEncodings encoding [temporal:1 e[38;5;98m+0mse[0m
  
e[38;5;98;1mmediasoup:worker[pid:58818] e[0mRTC::SimulcastConsumer::UseAvailableBitrate() | UseAvailableBitrate params [bitrate:1000000] e[38;5;98m+0mse[0m
  e[38;5;98;1mmediasoup:worker[pid:58818] e[0mRTC::SimulcastConsumer::UseAvailableBitrate() | testing layers 0:0 [virtualBitrate:1080000, requiredBitrate:137216] e[38;5;98m+0mse[0m
  e[38;5;98;1mmediasoup:worker[pid:58818] e[0mRTC::SimulcastConsumer::UseAvailableBitrate() | testing layers 0:1 [virtualBitrate:1080000, requiredBitrate:234272] e[38;5;98m+0mse[0m
  e[38;5;98;1mmediasoup:worker[pid:58818] e[0mRTC::SimulcastConsumer::UseAvailableBitrate() | testing layers 0:2 [virtualBitrate:1080000, requiredBitrate:426248] e[38;5;98m+0mse[0m
  e[38;5;98;1mmediasoup:worker[pid:58818] e[0mRTC::SimulcastConsumer::UseAvailableBitrate() | choosing layers 0:2 [bitrate:1000000, virtualBitrate:1080000, usedBitrate:426248, consumerId:08db906d-f18b-4c58-b9b5-a9381fd408bc] e[38;5;98m+0mse[0m

Do you have any idea why this is happening and point me in the right direction as debugging the c++ layer is very time consuming for me.

Thanks.

You are settings 2 encodings, so in Chrome/Firefox with VP8, it means 2 spatial layers with 3 temporal layers each one, meaning that Chrome may send spatial layer 0 and 1 and temporal layer 0, 1 and 2.

So you are mixing the number of encodings (spatial layers) with temporal layers, which does not make sense.

Please rephrase your question. And also check your producer.getStats() (in server side) to see how many streams your browser is sending at a given time (the browser may stop sending spatial layer 1 due to CPU load, etc).

Thank you so much for the reply.

Right, so if I specify 3 encoding objects, like in the demo, it sends 3 spatial + 3 temporal layers right? Is there any reading material on this subject that you can recommend.

Great work by the way, thanks a million.

The documentation?