Closed uguraltinsoy closed 4 months ago
你可以用我的swiftUI的demo试下。输入这个udp的url。看下行不行。
The code I broadcast and the code I test the broadcast are as follows, but the application stays like this
Brodcast WebCam :
ffmpeg -f avfoundation -video_size 1280x720 -framerate 30 -i "0" -pixel_format uyvy422 -c:v libx264 -preset medium -tune zerolatency -f mpegts "udp://127.0.0.1:6000?pkt_size=1316"
Test Live Video
ffplay -fflags nobuffer -flags low_delay -probesize 32 -analyzeduration 1 -strict experimental -framedrop -f mpegts -vf setpts=0 udp://127.0.0.1:6000
import SwiftUI
import KSPlayer
struct ContentView: View {
// udp://@127.0.0.1:6000
let options: KSOptions = {
var option = KSOptions()
option.isAutoPlay = true
option.cache = false
option.probesize = 32
return option
}()
var body: some View {
VStack {
KSVideoPlayerView(url: URL(string: "udp://127.0.0.1:6000")!, options: options)
}
}
}
我的demo里面的Player可以播放你的udp吗?
I'm not that good at Swift, your demo project seemed very confused to me, I tried to do as much as I could understand. I don't know how I can test with your demo project
你直接运行我的demo。然后在app的界面上会有一个地方可以输入url。你把你的url给输入进去就可以进行测试了。
The application in TestFlight is connecting, there is a lot of delay but it works
如果我的demo是可以的,那就是你写的代码,有些地方的配置有问题了。你可以先自己排查下,如果还是找不到的原因的话,那我可以提供需要收费的技术支持服务。详细价格可以参考这个项目的Sponsor tiers。
Paid support because I can't use the library you wrote? Could your library be giving an "unsupported URL" error?
warning KSPlayer: KSPlayerLayer.swift:423 finish(player:error:) | Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x600000cbe670 {Error Domain=NSOSStatusErrorDomain Code=-1002 "(null)"}}
How can I contact you privately? I got a Monthly Sponsorship and I only have 1 problem
Paid support because I can't use the library you wrote? Could your library be giving an "unsupported URL" error?
warning KSPlayer: KSPlayerLayer.swift:423 finish(player:error:) | Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x600000cbe670 {Error Domain=NSOSStatusErrorDomain Code=-1002 "(null)"}}
![]()
我看了你的日志。你需要加一行代码
KSOptions.secondPlayerType = KSMEPlayer.self
Yes it worked thanks. I solved the latency problem in FFPLay in this way, do you have any suggestions for this? there is a lot of latency now. I added similar ones to Options but it was not enough
let options: KSOptions = {
var option = KSOptions()
option.isAutoPlay = true
option.cache = false
option.probesize = 32
return option
}()
ffplay -fflags nobuffer -flags low_delay -probesize 32 -analyzeduration 1 -strict experimental -framedrop -f mpegts -vf setpts=0 udp://127.0.0.1:6000
OR
mpv udp://127.0.0.1:6000 --no-cache --untimed --no-demuxer-thread --vd-lavc-threads=1
option.codecLowDelay = true
options.probesize = 32
options.maxAnalyzeDuration = 1
Is it normal that there is so much difference? Isn't this much delay too much when running on localhost? FFPlay delay 10ms KSPlayer 17.75s
private let options: KSOptions = {
var options = KSOptions()
options.isAutoPlay = true
options.codecLowDelay = true
options.probesize = 32
options.maxAnalyzeDuration = 1
return options
}()
在加一下 options.formatContextOptions["fflags"] = ["nobuffer"]
Do you have any other ideas? 10 seconds doesn't seem normal in general.
options.preferredForwardBufferDuration = 0.02
option.codecLowDelay = true
options.probesize = 32
options.maxAnalyzeDuration = 1
options.formatContextOptions["fflags"] = ["nobuffer"]
Unfortunately it doesn't work, there is still a serious delay like 10s.
你试下不要用模拟器,直接用mac或是真实的iPhone运行下。
from phone hotspot to mac via wifi from real device to mac dropped to 3-4s. is it possible to reduce it even more?
I solved the smoothness problem by downgrading the ffmpeg stream packet, but this error still occurs
ffmpeg -f avfoundation -video_size 1280x720 -framerate 30 -i "2" -pixel_format uyvy422 -vf hflip -c:v libx264 -preset ultrafast -tune zerolatency -vf "hflip,crop=in_w/1. 33333:in_h, scale=960:720" -f mpegts "udp://192.168.0.1:6000?pkt_size=32"
I get this error and the stream freezes, do you have any advice for this? "error KSPlayer: MEPlayerItem.swift:131 MEPlayerItem | hardware accelerator failed to decode picture"
这个报错是说不能硬件解码,所以用的是软件解码。一般是流的编码格式有问题才会这样
Since I don't know how to use swiftui, I am writing in this way, but I couldn't run it, can I watch UDP live broadcast and how should I use swiftui?