【发布时间】:2021-04-01 06:46:35
【问题描述】:
当前默认示例 Android pjsip pjsua2 示例应用发送的视频质量非常差,我希望将其改进为至少高清质量。我尝试使用以下方法,但它一直显示非常低的视频质量。如何提高传出视频质量?此示例应用能够从其他 sip 视频通话中接收高达 355 * 288 的视频质量,但它发送的视频质量非常差。
目前,我试图通过在拨打电话之前更新 MediaFormatvideo 文件中的以下值来实现高清视频。而且它根本无助于改善传出视频。我是否在错误的地方更新了这些属性?
目前它发送低于 192 * 144 的视频质量,不接受高于 352 * 288 的视频质量。如何更新它以支持至少 1280*720 的视频质量?
MediaFormatVideo mf=new MediaFormatVideo();
mf.setFpsNum(30);
mf.setFpsDenum(1);
mf.setAvgBps(512000);
mf.setMaxBps(1024000);
mf.setHeight(720);
mf.setWidth(1280);
我正在更新这些设置如下:
MyCall call = new MyCall(account, -1);
CallOpParam prm = new CallOpParam(true);
AccountVideoConfig avc=new AccountVideoConfig();
MediaFormatVideo mf=new MediaFormatVideo();
Log.e("javan-video",String.valueOf(avc.getAutoShowIncoming()));
Log.e("javan-videofps",String.valueOf(mf.getFpsNum()));
mf.setFpsNum(30);
mf.setFpsDenum(1);
mf.setAvgBps(512000);
mf.setMaxBps(1024000);
mf.setHeight(720);
mf.setWidth(1280);
Log.e("javan-videofps",String.valueOf(mf.getFpsNum()));
try {
call.makeCall("sip:"+dialno+"@peoplefone.ch", prm);
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
am.setSpeakerphoneOn(true);
// startRinging();
} catch (Exception e) {
call.delete();
return;
}
currentCall = call;
showCallActivity();
}
我找到了文档,并以此为基础进行了实施,但我无法提高视频质量。
Framerate
Specify number of frames processed per second.
For encoding direction, configured via pjmedia_vid_codec_param.enc_fmt.det.vid.fps, e.g:
/* Sending @30fps */
param.enc_fmt.det.vid.fps.num = 30;
param.enc_fmt.det.vid.fps.denum = 1;
Note:
that there is a possibility that the value will be adjusted to follow remote capability. For example, if remote signals that maximum framerate supported is 10fps and locally the encoding direction framerate is set to 30fps, then 10fps will be used.
limitation: if preview is enabled before call is established, capture device will opened using default framerate of the device, and subsequent calls that use that device will use this framerate regardless of the configured encoding framerate that is set above. Currently the only solution is to disable preview before establishing media and re-enable it once the video media is established.
For decoding direction, two steps are needed:
pjmedia_vid_codec_param.dec_fmt.det.vid.fps should be set to the highest value expected for incoming video framerate.
signalling to remote, configured via codec specific SDP format parameter (fmtp): pjmedia_vid_codec_param.dec_fmtp.
H263-1998, maximum framerate is specified per size/resolution basis, check here for more info.
/* 3000/(1.001*2) fps for CIF */
param.dec_fmtp.param[m].name = pj_str("CIF");
param.dec_fmtp.param[m].val = pj_str("2");
/* 3000/(1.001*1) fps for QCIF */
param.dec_fmtp.param[n].name = pj_str("QCIF");
param.dec_fmtp.param[n].val = pj_str("1");
H264, similar to size/resolution, the framerate is implicitly specified in H264 level (check the standard specification or this) and the H264 level is signalled via H264 SDP fmtp profile-level-id, e.g:
/* Can receive up to 1280×720 @30fps */
param.dec_fmtp.param[n].name = pj_str("profile-level-id");
param.dec_fmtp.param[n].val = pj_str("xxxx1f");
Bitrate
Specify bandwidth requirement for video payloads stream delivery.
This is configurable via pjmedia_vid_codec_param.enc_fmt.det.vid.avg_bps and pjmedia_vid_codec_param.enc_fmt.det.vid.max_bps, e.g:
/* Bitrate range preferred: 512-1024kbps */
param.enc_fmt.det.vid.avg_bps = 512000;
param.enc_fmt.det.vid.max_bps = 1024000;
Notes:
This setting is applicable for encoding and decoding direction, currently there is no way to set asymmetric bitrate. By decoding direction, actually it just means that this setting will be queried when generating bandwidth info for local SDP (see next point).
The bitrate setting of all codecs will be enumerated and the highest value will be signalled in bandwidth info in local SDP (see ticket #1244).
There is a possibility that the encoding bitrate will be adjusted to follow remote bitrate setting, i.e: read from SDP bandwidth info (b=TIAS line) in remote SDP. For example, if remote signals that maximum bitrate is 128kbps and locally the bitrate is set to 512kbps, then 128kbps will be used.
If codec specific bitrate setting signalling (via SDP fmtp) is desired, e.g: MaxBR for H263, application should put the SDP fmtp manually, for example:
/* H263 specific maximum bitrate 512kbps */
param.dec_fmtp.param[n].name = pj_str("MaxBR");
param.dec_fmtp.param[n].val = pj_str("5120"); /* = max_bps / 100 */
文档链接:enter link description here
From: "0525512904" <sip:0525512904@95.128.80.93>;tag=1609930889511
I: To: <sip:90761330096@95.128.80.5>;tag=c6ce5331-3a35-44c8-bb80-23b6ec664085
I: CSeq: 1 INVITE
I: Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
I: Contact: <sip:90761330096@146.4.49.20:45483;transport=TLS;ob>
I: Supported: replaces, 100rel, timer, norefersub
I: Content-Type: application/sdp
I: Content-Length: 580
I: v=0
I: o=- 3818919690 3818919691 IN IP4 192.168.3.135
I: s=pjmedia
I: b=AS:352
I: t=0 0
I: a=X-nat:0
I: m=audio 4012 RTP/AVP 96 120
I: c=IN IP4 192.168.3.135
I: b=TIAS:64000
I: a=rtcp:4031 IN IP4 192.168.3.135
I: a=sendrecv
I: a=rtpmap:96 speex/16000
I: a=rtpmap:120 telephone-event/16000
I: a=fmtp:120 0-16
I: a=ssrc:1510027056 cname:365aaa4f448493db
I: m=video 4013 RTP/AVP 97
I: c=IN IP4 192.168.3.135
I: b=TIAS:256000
I: a=rtcp:4033 IN IP4 192.168.3.135
I: a=sendrecv
I: a=rtpmap:97 H264/90000
I: a=fmtp:97 profile-level-id=42e01e; packetization-mode=1
I: a=ssrc:1146236185 cname:365aaa4f448493db
I: a=rtcp-fb:* nack pli
I: --end msg--
E: ringing call
完整的日志链接sip call complete log
【问题讨论】:
-
欢迎堆栈溢出。请在此处提供足够的信息,以便其他人通过在此处提供足够的信息来重现问题来帮助您
-
我已经更新了我的问题。我可以在哪里以及如何更改 pjsip 中的视频分辨率 ...
-
@a_local_nobody 你能看看我更新的问题
-
没有足够的信息来确定问题(如果有)。请记住,您正在指定您可以接收(而不是发送)的最大视频限制。然后,这仅限于对方可以收到的内容。如果对方不能显示超过 640x480,那么你的一方将限制自己只发送到那个。这由在 SDP 提议/答案中发送的 H264 配置文件级别 ID 确定。我建议您将 pjsip 日志级别设置为 4(从内存中)并查看它以查看它的内容。也许您需要研究 SDP 如何处理视频,以便您了解它在说什么。
-
正如@ShanePowell 所说,查看 SDP 协商双方的 h264 配置文件级别。在这里查看更多信息:link