mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
MPV: speed up playback start
We initialize MPV with more options so it does not have to guess. This dramatically speeds up playback start.
This commit is contained in:
parent
90777d91f6
commit
e44c7f84c8
@ -60,15 +60,41 @@ final class MPVClient: ObservableObject {
|
|||||||
checkError(mpv_set_option_string(mpv, "input-media-keys", "yes"))
|
checkError(mpv_set_option_string(mpv, "input-media-keys", "yes"))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// CACHING //
|
||||||
|
|
||||||
checkError(mpv_set_option_string(mpv, "cache-pause-initial", Defaults[.mpvCachePauseInital] ? "yes" : "no"))
|
checkError(mpv_set_option_string(mpv, "cache-pause-initial", Defaults[.mpvCachePauseInital] ? "yes" : "no"))
|
||||||
checkError(mpv_set_option_string(mpv, "cache-secs", Defaults[.mpvCacheSecs]))
|
checkError(mpv_set_option_string(mpv, "cache-secs", Defaults[.mpvCacheSecs]))
|
||||||
checkError(mpv_set_option_string(mpv, "cache-pause-wait", Defaults[.mpvCachePauseWait]))
|
checkError(mpv_set_option_string(mpv, "cache-pause-wait", Defaults[.mpvCachePauseWait]))
|
||||||
|
|
||||||
|
// PLAYBACK //
|
||||||
checkError(mpv_set_option_string(mpv, "keep-open", "yes"))
|
checkError(mpv_set_option_string(mpv, "keep-open", "yes"))
|
||||||
checkError(mpv_set_option_string(mpv, "hwdec", machine == "x86_64" ? "no" : "auto-safe"))
|
|
||||||
checkError(mpv_set_option_string(mpv, "vo", "libmpv"))
|
|
||||||
checkError(mpv_set_option_string(mpv, "demuxer-lavf-analyzeduration", "1"))
|
|
||||||
checkError(mpv_set_option_string(mpv, "deinterlace", Defaults[.mpvDeinterlace] ? "yes" : "no"))
|
checkError(mpv_set_option_string(mpv, "deinterlace", Defaults[.mpvDeinterlace] ? "yes" : "no"))
|
||||||
|
|
||||||
|
// GPU //
|
||||||
|
|
||||||
|
checkError(mpv_set_option_string(mpv, "hwdec", Defaults[.mpvHWdec]))
|
||||||
|
checkError(mpv_set_option_string(mpv, "vo", "libmpv"))
|
||||||
|
|
||||||
|
// We set set everything to OpenGL so MPV doesn't have to probe for other APIs.
|
||||||
|
checkError(mpv_set_option_string(mpv, "gpu-api", "opengl"))
|
||||||
|
checkError(mpv_set_option_string(mpv, "opengl-swapinterval", "0"))
|
||||||
|
|
||||||
|
#if !os(macOS)
|
||||||
|
checkError(mpv_set_option_string(mpv, "opengl-es", "yes"))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// We set this to ordered since we use OpenGL and Apple's implementation is ancient.
|
||||||
|
checkError(mpv_set_option_string(mpv, "dither", "ordered"))
|
||||||
|
|
||||||
|
// DEMUXER //
|
||||||
|
|
||||||
|
// We request to test for lavf first and skip probing other demuxer.
|
||||||
|
checkError(mpv_set_option_string(mpv, "demuxer", "lavf"))
|
||||||
|
checkError(mpv_set_option_string(mpv, "audio-demuxer", "lavf"))
|
||||||
|
checkError(mpv_set_option_string(mpv, "sub-demuxer", "lavf"))
|
||||||
|
checkError(mpv_set_option_string(mpv, "demuxer-lavf-analyzeduration", "1"))
|
||||||
|
checkError(mpv_set_option_string(mpv, "demuxer-lavf-probe-info", Defaults[.mpvDemuxerLavfProbeInfo]))
|
||||||
|
|
||||||
checkError(mpv_initialize(mpv))
|
checkError(mpv_initialize(mpv))
|
||||||
|
|
||||||
let api = UnsafeMutableRawPointer(mutating: (MPV_RENDER_API_TYPE_OPENGL as NSString).utf8String)
|
let api = UnsafeMutableRawPointer(mutating: (MPV_RENDER_API_TYPE_OPENGL as NSString).utf8String)
|
||||||
|
@ -266,8 +266,10 @@ extension Defaults.Keys {
|
|||||||
static let mpvEnableLogging = Key<Bool>("mpvEnableLogging", default: false)
|
static let mpvEnableLogging = Key<Bool>("mpvEnableLogging", default: false)
|
||||||
static let mpvCacheSecs = Key<String>("mpvCacheSecs", default: "120")
|
static let mpvCacheSecs = Key<String>("mpvCacheSecs", default: "120")
|
||||||
static let mpvCachePauseWait = Key<String>("mpvCachePauseWait", default: "3")
|
static let mpvCachePauseWait = Key<String>("mpvCachePauseWait", default: "3")
|
||||||
static let mpvCachePauseInital = Key<Bool>("cache-pause-initial", default: true)
|
static let mpvCachePauseInital = Key<Bool>("mpvCachePauseInitial", default: false)
|
||||||
static let mpvDeinterlace = Key<Bool>("mpvDeinterlace", default: false)
|
static let mpvDeinterlace = Key<Bool>("mpvDeinterlace", default: false)
|
||||||
|
static let mpvHWdec = Key<String>("hwdec", default: "auto-safe")
|
||||||
|
static let mpvDemuxerLavfProbeInfo = Key<String>("mpvDemuxerLavfProbeInfo", default: "no")
|
||||||
|
|
||||||
static let showCacheStatus = Key<Bool>("showCacheStatus", default: false)
|
static let showCacheStatus = Key<Bool>("showCacheStatus", default: false)
|
||||||
static let feedCacheSize = Key<String>("feedCacheSize", default: "50")
|
static let feedCacheSize = Key<String>("feedCacheSize", default: "50")
|
||||||
|
@ -8,6 +8,8 @@ struct AdvancedSettings: View {
|
|||||||
@Default(.mpvCachePauseInital) private var mpvCachePauseInital
|
@Default(.mpvCachePauseInital) private var mpvCachePauseInital
|
||||||
@Default(.mpvDeinterlace) private var mpvDeinterlace
|
@Default(.mpvDeinterlace) private var mpvDeinterlace
|
||||||
@Default(.mpvEnableLogging) private var mpvEnableLogging
|
@Default(.mpvEnableLogging) private var mpvEnableLogging
|
||||||
|
@Default(.mpvHWdec) private var mpvHWdec
|
||||||
|
@Default(.mpvDemuxerLavfProbeInfo) private var mpvDemuxerLavfProbeInfo
|
||||||
@Default(.showCacheStatus) private var showCacheStatus
|
@Default(.showCacheStatus) private var showCacheStatus
|
||||||
@Default(.feedCacheSize) private var feedCacheSize
|
@Default(.feedCacheSize) private var feedCacheSize
|
||||||
@Default(.showPlayNowInBackendContextMenu) private var showPlayNowInBackendContextMenu
|
@Default(.showPlayNowInBackendContextMenu) private var showPlayNowInBackendContextMenu
|
||||||
@ -73,12 +75,14 @@ struct AdvancedSettings: View {
|
|||||||
HStack {
|
HStack {
|
||||||
Text("cache-pause-initial")
|
Text("cache-pause-initial")
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
Link(destination: URL(string: "https://mpv.io/manual/stable/#options-cache-pause-initial")!) {
|
Image(systemName: "link")
|
||||||
Image(systemName: "link")
|
.accessibilityAddTraits([.isButton, .isLink])
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
}
|
.onTapGesture {
|
||||||
|
UIApplication.shared.open(URL(string: "https://mpv.io/manual/stable/#options-cache-pause-initial")!)
|
||||||
|
}
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
.onHover(perform: onHover(_:))
|
.onHover(perform: onHover(_:))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -87,13 +91,16 @@ struct AdvancedSettings: View {
|
|||||||
HStack {
|
HStack {
|
||||||
Text("cache-secs")
|
Text("cache-secs")
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
Link(destination: URL(string: "https://mpv.io/manual/stable/#options-cache-secs")!) {
|
Image(systemName: "link")
|
||||||
Image(systemName: "link")
|
.accessibilityAddTraits([.isButton, .isLink])
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
#if os(macOS)
|
.onTapGesture {
|
||||||
.onHover(perform: onHover(_:))
|
UIApplication.shared.open(URL(string: "https://mpv.io/manual/stable/#options-cache-secs")!)
|
||||||
#endif
|
}
|
||||||
}
|
#if os(macOS)
|
||||||
|
.onHover(perform: onHover(_:))
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
TextField("cache-secs", text: $mpvCacheSecs)
|
TextField("cache-secs", text: $mpvCacheSecs)
|
||||||
#if !os(macOS)
|
#if !os(macOS)
|
||||||
@ -106,10 +113,12 @@ struct AdvancedSettings: View {
|
|||||||
Group {
|
Group {
|
||||||
Text("cache-pause-wait")
|
Text("cache-pause-wait")
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
Link(destination: URL(string: "https://mpv.io/manual/stable/#options-cache-pause-wait")!) {
|
Image(systemName: "link")
|
||||||
Image(systemName: "link")
|
.accessibilityAddTraits([.isButton, .isLink])
|
||||||
}
|
.font(.footnote)
|
||||||
.font(.footnote)
|
.onTapGesture {
|
||||||
|
UIApplication.shared.open(URL(string: "https://mpv.io/manual/stable/#options-cache-pause-wait")!)
|
||||||
|
}
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
.onHover(perform: onHover(_:))
|
.onHover(perform: onHover(_:))
|
||||||
#endif
|
#endif
|
||||||
@ -127,17 +136,69 @@ struct AdvancedSettings: View {
|
|||||||
HStack {
|
HStack {
|
||||||
Text("deinterlace")
|
Text("deinterlace")
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
Link(destination: URL(string: "https://mpv.io/manual/stable/#options-deinterlace")!) {
|
Image(systemName: "link")
|
||||||
Image(systemName: "link")
|
.accessibilityAddTraits([.isButton, .isLink])
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
}
|
.onTapGesture {
|
||||||
|
UIApplication.shared.open(URL(string: "https://mpv.io/manual/stable/#options-deinterlace")!)
|
||||||
|
}
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
.onHover(perform: onHover(_:))
|
.onHover(perform: onHover(_:))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
Text("hwdec")
|
||||||
|
|
||||||
|
#if !os(tvOS)
|
||||||
|
Image(systemName: "link")
|
||||||
|
.accessibilityAddTraits([.isButton, .isLink])
|
||||||
|
.font(.footnote)
|
||||||
|
.onTapGesture {
|
||||||
|
UIApplication.shared.open(URL(string: "https://mpv.io/manual/stable/#options-hwdec")!)
|
||||||
|
}
|
||||||
|
#if os(macOS)
|
||||||
|
.onHover( /* perform: onHover(_:) */ )
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Picker("", selection: $mpvHWdec) {
|
||||||
|
ForEach(["auto", "auto-safe", "auto-copy"], id: \.self) {
|
||||||
|
Text($0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.pickerStyle(MenuPickerStyle())
|
||||||
|
}
|
||||||
|
|
||||||
|
if mpvEnableLogging {
|
||||||
|
logButton
|
||||||
|
}
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
Text("demuxer-lavf-probe-info")
|
||||||
|
|
||||||
|
#if !os(tvOS)
|
||||||
|
Image(systemName: "link")
|
||||||
|
.accessibilityAddTraits([.isButton, .isLink])
|
||||||
|
.font(.footnote)
|
||||||
|
.onTapGesture {
|
||||||
|
UIApplication.shared.open(URL(string: "https://mpv.io/manual/stable/#options-demuxer-lavf-probe-info")!)
|
||||||
|
}
|
||||||
|
#if os(macOS)
|
||||||
|
.onHover( /* perform: onHover(_:) */ )
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Picker("", selection: $mpvDemuxerLavfProbeInfo) {
|
||||||
|
ForEach(["yes", "no", "auto", "nostreams"], id: \.self) {
|
||||||
|
Text($0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.pickerStyle(MenuPickerStyle())
|
||||||
|
}
|
||||||
|
|
||||||
if mpvEnableLogging {
|
if mpvEnableLogging {
|
||||||
logButton
|
logButton
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user