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:
Arkadiusz Fal
2026-07-29 22:50:50 +02:00
parent 67ed8c322b
commit 9e546e29ee
10 changed files with 69 additions and 3 deletions

View File

@@ -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,