菜鸟教程小白 发表于 2022-12-11 18:09:13

ios - 如何在 webrtc ios 中压缩视频文件?


                                            <p><p>我正在使用 Webrtc 视频流。<br/></p>

<pre><code>- (RTCMediaConstraints *)defaultMediaStreamConstraints {
NSArray *mandatoryConstraints = @[
                                  [ initWithKey:@&#34;maxWidth&#34; value:@&#34;640&#34;],
                                  [ initWithKey:@&#34;maxHeight&#34; value:@&#34;480&#34;],
                                  [ initWithKey:@&#34;maxFrameRate&#34; value:@&#34;15&#34;],
                                 ];

NSArray *optionalConstraints = @[];
RTCMediaConstraints* constraints1 =
[
initWithMandatoryConstraints:mandatoryConstraints
optionalConstraints:nil];
return constraints1;
}
- (RTCMediaConstraints *)defaultPeerConnectionConstraints {
   NSArray *mandatoryConstraints = @[ [ initWithKey:@&#34;maxHeight&#34; value:],
                                 [ initWithKey:@&#34;maxWidth&#34; value:],
                                 [ initWithKey:@&#34;maxFrameRate&#34; value:]
                                 ];
   NSArray *optionalConstraints = @[];

   RTCMediaConstraints* constraints1 =
                  [
                  initWithMandatoryConstraints:mandatoryConstraints
                  optionalConstraints:optionalConstraints];
return constraints1;
}
</code></pre>

<p><br/>
但是,它不起作用。它设置了高质量的视频流。<br/>
如何压缩质量?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>在将其设置为本地 session 描述并将其发送给对等方之前,您应该直接在 SDP 内部设置视频带宽。</p>

<p>找到 <code>a=mid:video\r\n</code> 并将 <code>b=AS:128\r\n</code> 附加到它。</p>

<p>您可以通过查找 <code>a=mid:audio\r\n</code> 对音频流执行相同操作。</p>

<p>例如,给定以下 SDP:</p>

<pre><code>v=0
o=- 487255629242026503 2 IN IP4 127.0.0.1
s=-
t=0 0

a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:8a1/LJqQMzBmYtes
a=ice-pwd:sbfskHYHACygyHW1wVi8GZM+
a=ice-options:google-ice
a=fingerprint:sha-256 28:4C:19:10:97:56:FB:22:57:9E:5A:88:28:F3:04:
   DF:37:D0:7D:55:C3:D1:59:B0:B2:81 :FB:9D:DF:CB:15:A8
a=setup:actpass
a=mid:audio
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
</code></pre>

<p>您必须在 <code>a=mid:audio</code> 和 <code>a=extmap:1 urn:ietf:params:rtp- 之间附加 <code>b=AS:128</code> hdrext:ssrc-audio-level</code>.</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何在 webrtc ios 中压缩视频文件?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/40805983/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/40805983/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何在 webrtc ios 中压缩视频文件?