mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 15:48:05 +00:00
fix(mpv): handle audio track selection for transcoded streams on iOS
This commit is contained in:
@@ -531,7 +531,11 @@ export default function page() {
|
|||||||
subtitleIndex,
|
subtitleIndex,
|
||||||
isTranscoding,
|
isTranscoding,
|
||||||
);
|
);
|
||||||
const initialAudioId = getMpvAudioId(mediaSource, audioIndex);
|
const initialAudioId = getMpvAudioId(
|
||||||
|
mediaSource,
|
||||||
|
audioIndex,
|
||||||
|
isTranscoding,
|
||||||
|
);
|
||||||
|
|
||||||
// Calculate start position directly here to avoid timing issues
|
// Calculate start position directly here to avoid timing issues
|
||||||
const startTicks = playbackPositionFromUrl
|
const startTicks = playbackPositionFromUrl
|
||||||
|
|||||||
@@ -91,21 +91,32 @@ export const getMpvSubtitleId = (
|
|||||||
/**
|
/**
|
||||||
* Calculate the MPV track ID for a given Jellyfin audio index.
|
* Calculate the MPV track ID for a given Jellyfin audio index.
|
||||||
*
|
*
|
||||||
* Audio tracks are simpler - they're always in MPV (no burn-in like image subs).
|
* For direct play: Audio tracks map to their position in the file (1-based).
|
||||||
|
* For transcoding: Only ONE audio track exists in the HLS stream (the selected one),
|
||||||
|
* so we should return 1 or undefined to use the default track.
|
||||||
|
*
|
||||||
* MPV track IDs are 1-based.
|
* MPV track IDs are 1-based.
|
||||||
*
|
*
|
||||||
* @param mediaSource - The media source containing audio streams
|
* @param mediaSource - The media source containing audio streams
|
||||||
* @param jellyfinAudioIndex - The Jellyfin server-side audio index
|
* @param jellyfinAudioIndex - The Jellyfin server-side audio index
|
||||||
|
* @param isTranscoding - Whether the stream is being transcoded
|
||||||
* @returns MPV track ID (1-based), or undefined if not found
|
* @returns MPV track ID (1-based), or undefined if not found
|
||||||
*/
|
*/
|
||||||
export const getMpvAudioId = (
|
export const getMpvAudioId = (
|
||||||
mediaSource: MediaSourceInfo | null | undefined,
|
mediaSource: MediaSourceInfo | null | undefined,
|
||||||
jellyfinAudioIndex: number | undefined,
|
jellyfinAudioIndex: number | undefined,
|
||||||
|
isTranscoding: boolean,
|
||||||
): number | undefined => {
|
): number | undefined => {
|
||||||
if (jellyfinAudioIndex === undefined) {
|
if (jellyfinAudioIndex === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When transcoding, Jellyfin only includes the selected audio track in the HLS stream.
|
||||||
|
// So there's only 1 audio track - no need to specify an ID.
|
||||||
|
if (isTranscoding) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const allAudio =
|
const allAudio =
|
||||||
mediaSource?.MediaStreams?.filter((s) => s.Type === "Audio") || [];
|
mediaSource?.MediaStreams?.filter((s) => s.Type === "Audio") || [];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user