Skip to content

Commit 2ebf444

Browse files
authored
Merge pull request #6 from StreamUI/070224-render-settings
Update Bitrate
2 parents 23ca2e3 + 3a992aa commit 2ebf444

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

Sources/StreamUI/Helpers/RenderSettings.swift

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,22 @@ public struct RenderSettings {
100100
func getDefaultBitrate() -> Int {
101101
let numOfPixels = width * height
102102
switch numOfPixels {
103-
case 0 ... 102_240: return 800_000 // for 4/3 and 16/9 240p
104-
case 102_241 ... 230_400: return 1_000_000 // for 16/9 360p
105-
case 230_401 ... 409_920: return 1_300_000 // for 4/3 and 16/9 480p
106-
case 409_921 ... 921_600: return 2_000_000 // for 4/3 600p, 4/3 768p and 16/9 720p
107-
default: return 3_000_000 // for 16/9 1080p
103+
case 0 ... 102_240: // for 4/3 and 16/9 240p
104+
return 4_000_000
105+
case 102_241 ... 230_400: // for 16/9 360p
106+
return 4_000_000
107+
case 230_401 ... 409_920: // for 4/3 and 16/9 480p
108+
return 4_000_000
109+
case 409_921 ... 921_600: // for 4/3 600p, 4/3 768p and 16/9 720p
110+
return fps == 60 ? 6_000_000 : 4_000_000
111+
case 921_601 ... 2_073_600: // for 16/9 1080p
112+
return fps == 60 ? 12_000_000 : 10_000_000
113+
case 2_073_601 ... 3_686_400: // for 1440p
114+
return fps == 60 ? 24_000_000 : 15_000_000
115+
case 3_686_401 ... 8_294_400: // for 4K / 2160p
116+
return fps == 60 ? 35_000_000 : 30_000_000
117+
default:
118+
return 30_000_000 // default for resolutions higher than 4K
108119
}
109120
}
110121

Sources/StreamUI/Streaming/RTMPStreaming.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public class RTMPStreaming: ObservableObject {
7575
maxKeyFrameIntervalDuration: 2
7676
)
7777

78+
rtmpStream.audioSettings.bitRate = 128_000
79+
7880
// rtmpStream.bitrateStrategy = VideoAdaptiveNetBitRateStrategy(mamimumVideoBitrate: VideoCodecSettings.default.bitRate)
7981
}
8082

0 commit comments

Comments
 (0)