[*] 码率配置

This commit is contained in:
acgist
2023-08-26 10:12:00 +08:00
parent 54d8c04b8b
commit 7e4230c214
6 changed files with 29 additions and 22 deletions

View File

@@ -28,7 +28,7 @@ public class MediaVideoProperties {
*/ */
private Format format; private Format format;
/** /**
* 码率:600|1200|1500|1800 * 码率:400|800|1200|1600
* 码率影响画质 * 码率影响画质
*/ */
private Integer bitrate; private Integer bitrate;

View File

@@ -73,21 +73,32 @@ module.exports = {
// Router配置https://mediasoup.org/documentation/v3/mediasoup/api/#RouterOptions // Router配置https://mediasoup.org/documentation/v3/mediasoup/api/#RouterOptions
routerOptions: { routerOptions: {
mediaCodecs: [ mediaCodecs: [
// OPUS PCMA PCMU G722
{ {
kind : "audio", kind : "audio",
mimeType : "audio/opus", mimeType : "audio/opus",
clockRate: 48000, clockRate: 48000,
channels : 2, channels : 2,
}, },
{
kind : "audio",
mimeType : "audio/pcmu",
clockRate: 8000,
channels : 1,
},
{
kind : "audio",
mimeType : "audio/pcma",
clockRate: 8000,
channels : 1,
},
{ {
kind : "video", kind : "video",
mimeType : "video/VP8", mimeType : "video/VP8",
clockRate : 90000, clockRate : 90000,
parameters: { parameters: {
"x-google-start-bitrate": 1000, "x-google-start-bitrate": 400,
// "x-google-min-bitrate": 800, // "x-google-min-bitrate": 800,
// "x-google-max-bitrate": 1800, // "x-google-max-bitrate": 1600,
}, },
}, },
{ {
@@ -96,9 +107,9 @@ module.exports = {
clockRate : 90000, clockRate : 90000,
parameters: { parameters: {
"profile-id" : 2, "profile-id" : 2,
"x-google-start-bitrate": 1000, "x-google-start-bitrate": 400,
// "x-google-min-bitrate": 800, // "x-google-min-bitrate": 800,
// "x-google-max-bitrate": 1800, // "x-google-max-bitrate": 1600,
}, },
}, },
{ {
@@ -109,9 +120,9 @@ module.exports = {
"packetization-mode" : 1, "packetization-mode" : 1,
"profile-level-id" : "4d0032", "profile-level-id" : "4d0032",
"level-asymmetry-allowed": 1, "level-asymmetry-allowed": 1,
"x-google-start-bitrate" : 1000, "x-google-start-bitrate" : 400,
// "x-google-min-bitrate": 800, // "x-google-min-bitrate": 800,
// "x-google-max-bitrate": 1800, // "x-google-max-bitrate": 1600,
}, },
}, },
{ {
@@ -122,9 +133,9 @@ module.exports = {
"packetization-mode" : 1, "packetization-mode" : 1,
"profile-level-id" : "42e01f", "profile-level-id" : "42e01f",
"level-asymmetry-allowed": 1, "level-asymmetry-allowed": 1,
"x-google-start-bitrate" : 1000, "x-google-start-bitrate" : 400,
// "x-google-min-bitrate": 800, // "x-google-min-bitrate": 800,
// "x-google-max-bitrate": 1800, // "x-google-max-bitrate": 1600,
}, },
}, },
], ],
@@ -154,10 +165,10 @@ module.exports = {
announcedIp: process.env.MEDIASOUP_ANNOUNCED_IP || "127.0.0.1", announcedIp: process.env.MEDIASOUP_ANNOUNCED_IP || "127.0.0.1",
}, },
], ],
initialAvailableOutgoingBitrate: 1000000, initialAvailableOutgoingBitrate: 400000,
minimumAvailableOutgoingBitrate: 800000, minimumAvailableOutgoingBitrate: 800000,
maxSctpMessageSize : 262144, maxSctpMessageSize : 262144,
maxIncomingBitrate : 1800000, maxIncomingBitrate : 1600000,
}, },
// PlainTransport配置https://mediasoup.org/documentation/v3/mediasoup/api/#PlainTransportOptions // PlainTransport配置https://mediasoup.org/documentation/v3/mediasoup/api/#PlainTransportOptions
plainTransportOptions: { plainTransportOptions: {

View File

@@ -1758,13 +1758,9 @@ class Taoyao {
}; };
me.push(message); me.push(message);
const { const {
minOutgoingBitrate,
maxOutgoingBitrate, maxOutgoingBitrate,
maxIncomingBitrate, maxIncomingBitrate,
} = config.mediasoup.webRtcTransportOptions; } = config.mediasoup.webRtcTransportOptions;
if(minOutgoingBitrate) {
await transport.setMinOutgoingBitrate(minOutgoingBitrate);
}
if(maxOutgoingBitrate) { if(maxOutgoingBitrate) {
await transport.setMaxOutgoingBitrate(maxOutgoingBitrate); await transport.setMaxOutgoingBitrate(maxOutgoingBitrate);
} }

View File

@@ -2793,9 +2793,9 @@ class Taoyao extends RemoteClient {
} }
const track = videoTrack || await me.getVideoTrack(); const track = videoTrack || await me.getVideoTrack();
const codecOptions = { const codecOptions = {
videoGoogleStartBitrate: 400,
videoGoogleMinBitrate : 800, videoGoogleMinBitrate : 800,
videoGoogleMaxBitrate : 1800, videoGoogleMaxBitrate : 1600,
videoGoogleStartBitrate: 1000,
}; };
let codec; let codec;
if(me.forceVP8) { if(me.forceVP8) {

View File

@@ -41,7 +41,7 @@ public class MediaVideoProperties {
@Schema(title = "格式", description = "格式", example = "VP8|VP9|H264|H265") @Schema(title = "格式", description = "格式", example = "VP8|VP9|H264|H265")
private Format format; private Format format;
@Schema(title = "码率", description = "码率影响画质", example = "600|1200|1500|1800") @Schema(title = "码率", description = "码率影响画质", example = "400|800|1200|1600")
private Integer bitrate; private Integer bitrate;
@Schema(title = "帧率", description = "帧率影响流畅", example = "15|18|20|24|30|45") @Schema(title = "帧率", description = "帧率影响流畅", example = "15|18|20|24|30|45")
private Integer frameRate; private Integer frameRate;

View File

@@ -121,7 +121,7 @@ taoyao:
# 4KUD=UHD=4K # 4KUD=UHD=4K
ud-video: ud-video:
format: H264 format: H264
bitrate: 1800 bitrate: 2000
frame-rate: 45 frame-rate: 45
resolution: 4096*2160 resolution: 4096*2160
# 2KQD=QHD=2K # 2KQD=QHD=2K
@@ -139,13 +139,13 @@ taoyao:
# 高清视频HD=720P # 高清视频HD=720P
hd-video: hd-video:
format: H264 format: H264
bitrate: 1000 bitrate: 800
frame-rate: 18 frame-rate: 18
resolution: 1280*720 resolution: 1280*720
# 标清视频SD=480P # 标清视频SD=480P
sd-video: sd-video:
format: H264 format: H264
bitrate: 800 bitrate: 400
frame-rate: 15 frame-rate: 15
resolution: 720*480 resolution: 720*480
# FFmpeg配置 # FFmpeg配置