Skip to content

Commit

Permalink
优化rtsp
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Oct 16, 2023
1 parent d7fe33c commit d9d1462
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions Demo/SwiftUI/Shared/MovieModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class MEOptions: KSOptions {
override func process(assetTrack: some MediaPlayerTrack) {
if assetTrack.mediaType == .video {
if [FFmpegFieldOrder.bb, .bt, .tt, .tb].contains(assetTrack.fieldOrder) {
videoFilters.append("yadif=mode=0:parity=-1:deint=1")
hardwareDecode = false
videoFilters.append("yadif_videotoolbox=mode=0:parity=-1:deint=1")
asynchronousDecompression = false
}
#if os(tvOS) || os(xrOS)
runInMainqueue { [weak self] in
Expand Down Expand Up @@ -345,9 +345,11 @@ extension KSVideoPlayerView {
}
// There is total different meaning for 'listen_timeout' option in rtmp
// set 'listen_timeout' = -1 for rtmp、rtsp
if url.absoluteString.starts(with: "rtmp") || url.absoluteString.starts(with: "rtsp") {
if url.scheme == "rtmp" || url.scheme == "rtsp" {
options.formatContextOptions["listen_timeout"] = -1
options.formatContextOptions["fflags"] = ["nobuffer", "autobsf"]
options.formatContextOptions["fflags"] = ["nobuffer"]
options.preferredForwardBufferDuration = 2
options.hardwareDecode = false
} else {
options.formatContextOptions["listen_timeout"] = 3
}
Expand Down
4 changes: 2 additions & 2 deletions Demo/demo-iOS/demo-iOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class MEOptions: KSOptions {
override func process(assetTrack: some MediaPlayerTrack) {
if assetTrack.mediaType == .video {
if [FFmpegFieldOrder.bb, .bt, .tt, .tb].contains(assetTrack.fieldOrder) {
videoFilters.append("yadif=mode=0:parity=-1:deint=1")
hardwareDecode = false
videoFilters.append("yadif_videotoolbox=mode=0:parity=-1:deint=1")
asynchronousDecompression = false
}
#if os(tvOS) || os(xrOS)
runInMainqueue { [weak self] in
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSPlayer/AVPlayer/KSOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ open class KSOptions {
return true
}
// 处理视频轨道一致没有值的问题(纯音频)
if capacity.mediaType == .video && capacity.frameCount == 0 && capacity.packetCount == 0 {
if capacitys.count > 1, capacity.mediaType == .video && capacity.frameCount == 0 && capacity.packetCount == 0 {
return true
}
guard capacity.frameCount >= capacity.frameMaxCount >> 2 else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSPlayer/MEPlayer/MEPlayerItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ final class MEPlayerItem {
}
}

private lazy var timer: Timer = .scheduledTimer(withTimeInterval: 0.02, repeats: true) { [weak self] _ in
private lazy var timer: Timer = .scheduledTimer(withTimeInterval: 0.05, repeats: true) { [weak self] _ in
self?.codecDidChangeCapacity()
}

Expand Down

0 comments on commit d9d1462

Please sign in to comment.