Skip to content

Commit

Permalink
fix: properly apply next state from decoder in qsv pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbenincasa committed Jan 12, 2025
1 parent adc267e commit 3a8a8e7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
3 changes: 3 additions & 0 deletions server/src/ffmpeg/FfmpegStreamFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TranscodeConfig } from '@/db/schema/TranscodeConfig.ts';
import { HttpStreamSource } from '@/stream/types.ts';
import { Maybe, Nullable } from '@/types/util.ts';
import { isDefined, isLinux, isNonEmptyString } from '@/util/index.ts';
import { LoggerFactory } from '@/util/logging/LoggerFactory.ts';
import { makeLocalUrl } from '@/util/serverUtil.ts';
import { ChannelStreamModes, FfmpegSettings } from '@tunarr/types';
import dayjs from 'dayjs';
Expand Down Expand Up @@ -48,6 +49,7 @@ import { HlsWrapperOptions, IFFMPEG } from './ffmpegBase.ts';
import { FfmpegInfo } from './ffmpegInfo.ts';

export class FfmpegStreamFactory extends IFFMPEG {
private logger = LoggerFactory.child({ className: FfmpegStreamFactory.name });
private ffmpegInfo: FfmpegInfo;
private pipelineBuilderFactory: PipelineBuilderFactory;

Expand Down Expand Up @@ -325,6 +327,7 @@ export class FfmpegStreamFactory extends IFFMPEG {
frameRate: videoStreamDetails.framerate?.toString(),
});

this.logger.debug('Video stream input: %O', videoStream);
const videoInput = new VideoInputSource(streamSource, [videoStream]);

const audioState = AudioState.create({
Expand Down
4 changes: 1 addition & 3 deletions server/src/ffmpeg/builder/pipeline/BasePipelineBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ export type PipelineBuilderContext = {
desiredAudioState?: AudioState;
pipelineSteps: PipelineStep[];
filterChain: FilterChain;
decoder: Nullable<Decoder>;

hasWatermark: boolean;
hasSubtitleOverlay: boolean;
Expand Down Expand Up @@ -281,7 +280,6 @@ export abstract class BasePipelineBuilder implements PipelineBuilder {
desiredAudioState: this.audioInputSource?.desiredState,
pipelineSteps: [],
filterChain: new FilterChain(),
decoder: this.decoder,
hasWatermark: !!this.watermarkInputSource,
hasSubtitleOverlay: false, // TODO:
is10BitOutput: (desiredState.pixelFormat?.bitDepth ?? 8) === 10,
Expand Down Expand Up @@ -604,7 +602,7 @@ export abstract class BasePipelineBuilder implements PipelineBuilder {
decoder = DecoderFactory.getSoftwareDecoder(this.context.videoStream);
this.videoInputSource.addOption(decoder);
}
this.context.decoder = decoder;
this.decoder = decoder;
return decoder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class NvidiaPipelineBuilder extends SoftwarePipelineBuilder {
decoder = super.setupDecoder();
}
}
this.context.decoder = decoder;
this.decoder = decoder;
return decoder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export class QsvPipelineBuilder extends SoftwarePipelineBuilder {
const {
desiredState,
videoStream,
decoder,
ffmpegState,
pipelineSteps,
filterChain,
Expand All @@ -135,8 +134,8 @@ export class QsvPipelineBuilder extends SoftwarePipelineBuilder {
paddedSize: videoStream.frameSize,
});

if (decoder) {
currentState = decoder.nextState(currentState);
if (this.decoder) {
currentState = this.decoder.nextState(currentState);
}

currentState = this.setDeinterlace(currentState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class VaapiPipelineBuilder extends SoftwarePipelineBuilder {
})
.otherwise(() => super.setupDecoder());

this.context.decoder = decoder;
this.decoder = decoder;

return decoder;
}
Expand All @@ -138,7 +138,7 @@ export class VaapiPipelineBuilder extends SoftwarePipelineBuilder {
return;
}

const { desiredState, videoStream, ffmpegState, pipelineSteps, decoder } =
const { desiredState, videoStream, ffmpegState, pipelineSteps } =
this.context;

let currentState = desiredState.update({
Expand All @@ -148,7 +148,7 @@ export class VaapiPipelineBuilder extends SoftwarePipelineBuilder {
pixelFormat: videoStream.pixelFormat,
});

currentState = decoder?.nextState(currentState) ?? currentState;
currentState = this.decoder?.nextState(currentState) ?? currentState;

currentState = this.setDeinterlace(currentState);
currentState = this.setScale(currentState);
Expand Down
4 changes: 2 additions & 2 deletions server/src/stream/hls/HlsSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ export class HlsSession extends BaseHlsSession<HlsSessionOptions> {

const transcodeResult = await lineupItemResult.mapAsync(async (result) => {
this.logger.debug(
'About to play item: %s',
JSON.stringify(result, undefined, 4),
'About to play lineup item: %s',
JSON.stringify(result.lineupItem, undefined, 4),
);
const context = new PlayerContext(
result.lineupItem,
Expand Down

0 comments on commit 3a8a8e7

Please sign in to comment.