Skip to content

Commit

Permalink
refactor: use static=true on Jellyfin video stream URL to access file…
Browse files Browse the repository at this point in the history
… directly (chrisbenincasa#731)
  • Loading branch information
chrisbenincasa authored Aug 29, 2024
1 parent 78cef1e commit 60bf786
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
11 changes: 3 additions & 8 deletions server/src/stream/jellyfin/JellyfinPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,17 @@ export class JellyfinPlayer extends Player {
stream.streamDetails.duration = lineupItem.streamDuration;
}

const streamUrl = new URL(stream.streamUrl);
streamUrl.searchParams.append(
'startTimeTicks',
Math.round((lineupItem.start ?? 0) * 10000).toString(),
);

const emitter = new EventEmitter() as TypedEventEmitter<FfmpegEvents>;
let ffmpegOutStream = this.ffmpeg.spawnStream(
streamUrl.toString(),
stream.streamUrl,
stream.streamDetails,
// Don't use FFMPEG's -ss parameter for Jellyfin since we need to request
// the seek against their API instead
0,
(lineupItem.start ?? 0) / 1000,
streamDuration?.toString(),
watermark,
{
// TODO: Use the real authorization string
'X-Emby-Token': server.accessToken,
},
); // Spawn the ffmpeg process
Expand Down
6 changes: 3 additions & 3 deletions server/src/stream/jellyfin/JellyfinStreamDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class JellyfinStreamDetails {

if (expectedItemType !== jellyfinItemTypeToProgramType(itemMetadata)) {
this.logger.warn(
'Got unexpected item type %s from Plex (ID = %s) when starting stream. Expected item type %s',
'Got unexpected item type %s from Jellyfin (ID = %s) when starting stream. Expected item type %s',
itemMetadata.Type,
item.externalKey,
expectedItemType,
Expand All @@ -116,7 +116,7 @@ export class JellyfinStreamDetails {
.catch((err) => {
this.logger.error(
err,
'Error while updating Plex file path for program %s',
'Error while updating Jellyfin file path for program %s',
item.programId,
);
});
Expand All @@ -139,7 +139,7 @@ export class JellyfinStreamDetails {
streamUrl = `${trimEnd(this.server.uri, '/')}/Videos/${trimStart(
path,
'/',
)}/stream`;
)}/stream?static=true`;
} else {
throw new Error('Could not resolve stream URL');
}
Expand Down

0 comments on commit 60bf786

Please sign in to comment.