mirror of
https://github.com/yattee/yattee.git
synced 2026-08-05 23:01:28 +00:00
Label local-file video quality from mpv track info instead of Unknown
Streams built for local folder files carry no resolution/codec/fps metadata (unknowable before demux), so the quality selector labeled them "Unknown". Use the video track mpv reports (demux-w/h/fps, codec) to fill those fields into a display-only copy of the stream — the Video row and summary now show e.g. "720p · 30fps" with a codec badge. Selection and tap handling keep using the original stream.
This commit is contained in:
@@ -184,7 +184,7 @@ extension QualitySelectorView {
|
||||
if format == .hls || format == .dash {
|
||||
return format == .hls ? "HLS" : "DASH"
|
||||
}
|
||||
return stream.qualityLabel
|
||||
return displayStream(for: stream).qualityLabel
|
||||
}
|
||||
|
||||
private var currentAudioDisplayValue: String {
|
||||
@@ -695,6 +695,35 @@ extension QualitySelectorView {
|
||||
}
|
||||
}
|
||||
|
||||
/// A local file's Stream carries no resolution/codec/fps metadata
|
||||
/// (`MediaFile.toStream` cannot know them before demux), which would label
|
||||
/// the row "Unknown". Once mpv reports the file's video track, fill those
|
||||
/// fields for display. The enriched copy is display-only — selection and
|
||||
/// tap handling keep using the original stream (compared by URL).
|
||||
func displayStream(for stream: Stream) -> Stream {
|
||||
guard stream.url.isFileURL,
|
||||
stream.resolution == nil,
|
||||
!stream.isAudioOnly,
|
||||
let track = embeddedVideoTrack,
|
||||
let width = track.width,
|
||||
let height = track.height else {
|
||||
return stream
|
||||
}
|
||||
return Stream(
|
||||
url: stream.url,
|
||||
resolution: StreamResolution(width: width, height: height),
|
||||
format: stream.format,
|
||||
videoCodec: track.codec ?? stream.videoCodec,
|
||||
audioCodec: stream.audioCodec,
|
||||
bitrate: stream.bitrate,
|
||||
fileSize: stream.fileSize,
|
||||
isLive: stream.isLive,
|
||||
mimeType: stream.mimeType,
|
||||
httpHeaders: stream.httpHeaders,
|
||||
fps: track.fps.map { Int($0.rounded()) }
|
||||
)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func videoStreamRow(_ stream: Stream) -> some View {
|
||||
let isDownloadedStream: Bool = stream.url.isFileURL
|
||||
@@ -704,7 +733,7 @@ extension QualitySelectorView {
|
||||
let isPreferredQuality: Bool = stream.resolution == preferredQuality.maxResolution
|
||||
|
||||
VideoStreamRowView(
|
||||
stream: stream,
|
||||
stream: displayStream(for: stream),
|
||||
isSelected: isSelected,
|
||||
isPreferredQuality: isPreferredQuality,
|
||||
isDownloaded: isDownloadedStream,
|
||||
|
||||
Reference in New Issue
Block a user