[Native][C++]How to set vp8 codec in 360p mode

1,063 views
Skip to first unread message

grgk...@gmail.com

unread,
Jan 24, 2014, 3:42:39 PM1/24/14
to discuss...@googlegroups.com
Hi all,

Is there a way to specify in the code that I'd like VP8 codec to start in 360p mode. Currently I see this in my logs:

SetSendCodecs() : selected video codec VP8/1280x720x30fps@2000kbps (min=50kbps, start=300kbps)

I appreciate your help.
George

Mike Anderson

unread,
Jan 24, 2014, 4:48:10 PM1/24/14
to discuss...@googlegroups.com
I believe the codec resolution should be dependent on the constraints on the video source.
when creating the video source here
PeerConnectionFactory::CreateVideoSource(cricket::VideoCapturer* capturer, const MediaConstraintsInterface* constraints)
supplying the following constraints should let you modify those three variables
mandatory:{
    "minHeight":"360",
    "maxHeight":"360",
    "maxFramerate":"30" }

If the camera does not support this resolution, the api will enumerate over the supported resolutions and pick the closest resolution that is below this resolution. If the camera does not support format enumeration in a way that the api understands, the default list is below.

(from talk/app/webrtc/videosource.cc)
static const cricket::VideoFormatPod kVideoFormats[] = {
{1920, 1080, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY},
{1280, 720, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY},
{960, 720, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY},
{640, 360, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY},
{640, 480, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY},
{320, 240, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY},
{320, 180, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY}
};

I hope this answer was close to what you were looking for
-Mike

grgk...@gmail.com

unread,
Jan 24, 2014, 6:02:58 PM1/24/14
to discuss...@googlegroups.com
Yes that worked perfectly.

From conductor.cc in peerconnection_client example:


void Conductor::AddStreams() {
........................
.....................
.........................

  FakeConstraints constraints;

  constraints.SetMandatoryMaxFrameRate(20);
  constraints.AddMandatory(MediaConstraintsInterface::kMinWidth, 426);
  constraints.AddMandatory(MediaConstraintsInterface::kMinHeight, 240);
  constraints.AddMandatory(MediaConstraintsInterface::kMaxAspectRatio, 426.0/240.0);

  talk_base::scoped_refptr<webrtc::VideoTrackInterface> video_track(
      peer_connection_factory_->CreateVideoTrack(
          kVideoLabel,
          peer_connection_factory_->CreateVideoSource(OpenVideoCaptureDevice(),
                                                      &constraints)));
 
..............
..............

Thanks a lot.
George

Francois Temasys

unread,
Feb 14, 2014, 2:29:13 AM2/14/14
to discuss...@googlegroups.com
Hi,

I was wondering almost the same question but for the codec. Is there a possible way to select the codec used for the video/audio?
I have been looking into the webrtc code and found that the list of audio codec is (if I'm not wrong):
cng/g711/g722/ilbc/isac/opus/pcm16b and the video codec:
i420/vp8

Can it be considered as a constrain?

Thank you
Francois

Alexandre GOUAILLARD

unread,
Feb 14, 2014, 3:51:27 AM2/14/14
to discuss...@googlegroups.com
today, in the browser, you do not have the capacity to choose the codec. Constraint is a very specific word in the JS/w3c realm, and media constraints deal mainly with resolution.

However, ….. you can modify the SDP generated by createOffer/Answer to alter the list of accepted codecs, either to change the priority (they are given in order of preference), or to completely remove one. Trying to add one that was not generated by the underlying code does not work. AppRTCDemo changes the audio codec preference to isac for example.

HTH.

alex.


--
 
---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Alex. Gouaillard, PhD, PhD, MBA
------------------------------------------------------------------------------------
CTO - Temasys Communications, S'pore / Mountain View
President - CoSMo Software, Cambridge, MA
------------------------------------------------------------------------------------

Mike Anderson

unread,
Feb 15, 2014, 4:57:13 PM2/15/14
to discuss...@googlegroups.com
Hi Francois, Alexandre,
I can confirm that currently the only way to set the codec is to parse and
edit the SDP. It's also important to note that Chrome and Firefox handle
interpret the SDP differently.

Chrome (and the native SDK) read the SDP and use the first codec in the
list that they can support, Firefox, on the other hand, picks the codec it
would rather support and only returns support for that codec in the answer
SDP (if it is the receiver of the offer).

So, if you want to be able to pick the codec for sure and support both
chrome and firefox, you must remove all the unwanted codecs from the offer
SDP from either the sender or receiver side.

-Mike

Francois Temasys

unread,
Feb 18, 2014, 1:47:02 AM2/18/14
to discuss...@googlegroups.com
Thank you for the help,

I did some experimentation and I would like to share to get your point of view.
NOT all of the codecs work for me.
Here is the actual list of codecs I found from the sdp:
  -audio: opus | ISAC | G722 | ILBC | PCMU | PCMA | CN | red | telephone-event
  -video: VP8 | red | ulpfec

On my web client it supports "only":
 -audio: opus | ISAC | PCMU | PCMA | telephone-event
 -video: VP8 | red | ulpfec

On my side I tested for the audio with:
 -audio: opus
 -video VP8
-->working
------------------------------
 -audio: ISAC
 -video VP8
-->working
-----------------------------
 -audio: PCMU
 -video VP8
--> NOT working
---------------------------------
 -audio: telephone-event
 -video VP8
--> NOT working

On the test with telephone-event, the web client is still trying to use the PCMU. The problem is by selecting the PCMU codec, I run into a segmentation fault error:
SRTP activated with negotiated parameters: send cipher_suite AES_CM_128_HMAC_SHA1_80 recv cipher_suite AES_CM_128_HMAC_SHA1_80
Enabling audio level header extension with ID 1
WebRtcVoiceMediaChanne::SetSendBandwidth.
WebRtcVoiceMediaChanne::SetSendBandwidthInternal.
Failed to set codec PCMU to bitrate 50000 bps, requires at least 64000 bps.
Setting voice channel options: AudioOptions {}
Set voice channel options.  Current options: AudioOptions {}
Warning(channel.cc:1755): Failed to set remote voice description
Error(channel.cc:875): Failure in SetRemoteContent with  action 2
Setting remote video description
NACK enabled for channel 0
Warning(webrtcvideoengine.cc:1416): webrtc: SetStorePacketsStatus already set, number: 600
NACK enabled for channel 0
Warning(webrtcvideoengine.cc:1416): webrtc: SetStorePacketsStatus already set, number: 600
SetSendCodecs() : selected video codec VP8/1280x720x30fps@2000kbps (min=50kbps, start=300kbps)
Video max quantization: 56
VP8 number of temporal layers: 1
VP8 options : picture loss indication = 0, feedback mode = 0, complexity = normal, resilience = off, denoising = 0, error concealment = 0, automatic resize = 0, frame dropping = 1, key frame interval = 3000
Recv stream 3066847284 reuse default channel #0
Add remote ssrc: 3066847284
Warning(webrtcvideoengine.cc:1416): webrtc: Start: Already running
SRTP activated with negotiated parameters: send cipher_suite AES_CM_128_HMAC_SHA1_80 recv cipher_suite AES_CM_128_HMAC_SHA1_80
WebRtcVideoMediaChanne::SetSendBandwidth
SetSendBandwidth() : selected video codec VP8/1280x720x30fps@256kbps (min=256kbps, start=256kbps)
Video max quantization: 56
VP8 number of temporal layers: 1
VP8 options : picture loss indication = 0, feedback mode = 0, complexity = normal, resilience = off, denoising = 0, error concealment = 0, automatic resize = 0, frame dropping = 1, key frame interval = 3000
Changing video state, recv=1 send=0
Error(webrtcsession.cc:252): SetRemoteDescription failed: Failed to update session state: ERROR_CONTENT
Session:5504169825929312883 Old state:STATE_RECEIVEDACCEPT New state:STATE_INPROGRESS Type:urn:xmpp:jingle:apps:rtp:1 Transport:http://www.google.com/transport/p2p
Dummy session description: OnFailure SetRemoteDescription failed: Failed to update session state: ERROR_CONTENT
Segmentation fault (core dumped)
And I don't have this error with other codecs.

Finally I tested for the video with:
 -audio: opus
 -video VP8
-->working
-----------------------------
 -audio: opus
 -video red
--> NOT working
---------------------------------
 -audio: opus
 -video ulpfec
--> NOT working

No segmentation fault here, but I can see on the web client console this message "CreateAnswer can't be called before SetRemoteDescription." and before in the log there is a setremotedescription. I guess the description is not correctly set.
Any help/comment is welcome.

I'll look into the webrtc issue if I can find any help.

Mike Anderson

unread,
Feb 18, 2014, 3:23:20 AM2/18/14
to discuss...@googlegroups.com
Hello Francois,
My understanding is that the only *real* codecs listed are opus, isac, ilbc and g722 and g711 for audio, and vp8 for video. The others can be thought of as capabilities.

PCMU and PCMA refer to two modes of operation of the G711 codec, PCMU is primarily used in North America, PCMA in Europe. I don't know why using PCMU is causing a segfault, this may be a bug in the implementation.

telephone-event refers to a set of codes that correspond to DTMF telephony tones (dial-pad tones). If both the sender and receiver support this, they can send DTMF tones with greater accuracy and efficiency than if the tones were compressed using the stream's audio codec.

RED signals that the client supports sending/receiving redundant frames (packets), I'm not sure why this is important. 

CN signals that the client supports comfort noise insertion frames (packets), these are frames that specify the current signal noise. I think the purpose is that the audio mixer can insert noise when no audio data is being transmitted, reducing choppyness in the sound of the audio

ULPFEC signals that the client supports error correction in frames

Again, 
I hope this helps

-Mike
iOS Dev @easyrtc

Francois Temasys

unread,
Feb 18, 2014, 3:45:07 AM2/18/14
to discuss...@googlegroups.com
Thanks that helped a lot my understanding of the codecs used in webrtc.
Reply all
Reply to author
Forward
0 new messages