first frames dropped because "Too large for target bitrate"

256 views
Skip to first unread message

Andriy Tylychko

unread,
Mar 28, 2018, 5:41:42 AM3/28/18
to discuss-webrtc
I have a custom `VideoTrackSourceInterface` impl which I try in the peerconnection sample. When it starts producing FullHD frames they are dropped in `VideoStreamEncoder::EncodeVideoFrame` with log message "Dropping frame. Too large for target bitrate.":

video_frame.size() > MaximumFrameSizeForBitrate(encoder_start_bitrate_bps_ / 1000)

and `encoder_start_bitrate_bps_` is default 300000.

How can I fix this?

I stream from a prerecorded h.264 encoded file (just a prototype for later h.264 hardware encoder), so dropping frames isn't the best idea. Also for production version it would be nice to stream high quality from the beginning.

Can I configure higher "start bitrate"? Can I do this by some configuration parameter instead of messing with SDP offer? If not, what's the proper way to do this with SDP offer?

I tried to add `b=AS:5000` to the offer and the answer (based on this discussion: https://groups.google.com/forum/#!topic/discuss-webrtc/XKdxQiEjUFs, also mentioned here: http://www.rtcbits.com/2016/11/controlling-bandwidth-usage-in-webrtc.html). but `encoder_start_bitrate_bps_` is still 300000 when the first frame is generated (and dropped):

void Conductor::OnSuccess(webrtc::SessionDescriptionInterface* desc) {

std::string sdp;
desc->ToString(&sdp);

std::regex pattern{ "m=video.*\\r\\n(?:c=.*\\r\\n)*(?:i=.*\\r\\n)*" };
sdp = std::regex_replace(sdp, pattern, "$&b=AS:5000\r\n");

std::unique_ptr<webrtc::SessionDescriptionInterface> desc_with_b = webrtc::CreateSessionDescription(desc->GetType(), sdp);

delete desc;
desc = desc_with_b.release();

  peer_connection_->SetLocalDescription(
      DummySetSessionDescriptionObserver::Create(), desc);

  Json::StyledWriter writer;
  Json::Value jmessage;
  jmessage[kSessionDescriptionTypeName] =
      webrtc::SdpTypeToString(desc->GetType());
  jmessage[kSessionDescriptionSdpName] = sdp;
  SendMessage(writer.write(jmessage));
}

this finds "m=video*" line in SDP, skips all "c=*" and "i=*" lines after it and adds "b=AS:5000" after them (based on https://webrtchacks.com/limit-webrtc-bandwidth-sdp/). Is this correct?

I also found about "x-google-start-bitrate" here: http://www.rtcbits.com/2016/11/controlling-bandwidth-usage-in-webrtc.html but haven't tried it yet, should I?

thank you

Reply all
Reply to author
Forward
0 new messages