fix(jellyfin): use the current audio track for media generation (#271)

This commit is contained in:
2026-09-24 21:14:34 -07:00
committed by GitHub
parent ba0155e429
commit 63eb228e4f
3 changed files with 32 additions and 1 deletions
+4
View File
@@ -0,0 +1,4 @@
type: fixed
area: jellyfin
- Timing review previews and mined card audio now use the audio track you are playing on Jellyfin direct-play streams, instead of the track Jellyfin marks as default.
+24
View File
@@ -213,6 +213,30 @@ test('resolveMediaGenerationInput reads file-local mpv request options', async (
}); });
}); });
test('resolveMediaGenerationInput keeps stream selection for a directly played remote container', async () => {
const resolver = (
mediaSource as typeof mediaSource & {
resolveMediaGenerationInput?: StructuredMediaResolver;
}
).resolveMediaGenerationInput;
assert.equal(typeof resolver, 'function');
// Jellyfin direct play: mpv opens the URL as-is, so it can hold several audio streams.
const jellyfinUrl = 'http://jellyfin.local:8096/Videos/abc/stream?static=true';
const result = await resolver!(
{
currentVideoPath: jellyfinUrl,
requestProperty: async (name: string) =>
name === 'stream-open-filename' ? jellyfinUrl : null,
},
'audio',
);
assert.equal(result?.path, jellyfinUrl);
assert.equal(result?.source, 'stream-open-filename');
assert.equal(result?.singleResolvedStream, false);
});
test('resolveMediaGenerationInput prefers a ready cached media file for YouTube extraction', async () => { test('resolveMediaGenerationInput prefers a ready cached media file for YouTube extraction', async () => {
const resolver = ( const resolver = (
mediaSource as typeof mediaSource & { mediaSource as typeof mediaSource & {
+4 -1
View File
@@ -400,12 +400,15 @@ export async function resolveMediaGenerationInput(
return result; return result;
} }
if (streamOpenFilename) { if (streamOpenFilename) {
// A URL that yt-dlp resolved (e.g. youtube.com -> googlevideo) is one picked stream.
// When mpv opens the path as-is (e.g. Jellyfin direct play), it is the full container,
// so mpv's audio stream index still applies.
const result = await toResolvedMediaGenerationInput( const result = await toResolvedMediaGenerationInput(
mpvClient, mpvClient,
streamOpenFilename, streamOpenFilename,
kind, kind,
'stream-open-filename', 'stream-open-filename',
isRemoteMediaPath(streamOpenFilename), isRemoteMediaPath(streamOpenFilename) && streamOpenFilename !== currentVideoPath,
); );
logResolvedMediaGenerationInput(options, currentVideoPath, result); logResolvedMediaGenerationInput(options, currentVideoPath, result);
return result; return result;