diff --git a/pkg/ffmpeg/codec_hardware.go b/pkg/ffmpeg/codec_hardware.go index ec71627d39e..4c39cb3b91a 100644 --- a/pkg/ffmpeg/codec_hardware.go +++ b/pkg/ffmpeg/codec_hardware.go @@ -82,7 +82,11 @@ func (f *FFMpeg) InitHWSupport(ctx context.Context) { f.hwCodecSupport = hwCodecSupport } -func (f *FFMpeg) hwCanFullHWTranscode(ctx context.Context, vf *models.VideoFile, codec VideoCodec) bool { +func (f *FFMpeg) hwCanFullHWTranscode(ctx context.Context, codec VideoCodec, vf *models.VideoFile, reqHeight int) bool { + if codec == VideoCodecCopy { + return false + } + var args Args args = append(args, "-hide_banner") args = args.LogLevel(LogLevelWarning) @@ -91,7 +95,7 @@ func (f *FFMpeg) hwCanFullHWTranscode(ctx context.Context, vf *models.VideoFile, args = args.Input(vf.Path) args = args.Duration(0.1) - videoFilter := f.hwMaxResFilter(codec, vf.Width, vf.Height, minHeight, true) + videoFilter := f.hwMaxResFilter(codec, vf.Width, vf.Height, reqHeight, true) args = append(args, CodecInit(codec)...) args = args.VideoFilter(videoFilter) diff --git a/pkg/ffmpeg/stream_segmented.go b/pkg/ffmpeg/stream_segmented.go index 42f534e7806..1058fb8eb27 100644 --- a/pkg/ffmpeg/stream_segmented.go +++ b/pkg/ffmpeg/stream_segmented.go @@ -330,7 +330,7 @@ func (s *runningStream) makeStreamArgs(sm *StreamManager, segment int) Args { codec := HLSGetCodec(sm, s.streamType.Name) - fullhw := sm.config.GetTranscodeHardwareAcceleration() && sm.encoder.hwCanFullHWTranscode(sm.context, s.vf, codec) + fullhw := sm.config.GetTranscodeHardwareAcceleration() && sm.encoder.hwCanFullHWTranscode(sm.context, codec, s.vf, s.maxTranscodeSize) args = sm.encoder.hwDeviceInit(args, codec, fullhw) args = append(args, extraInputArgs...) diff --git a/pkg/ffmpeg/stream_transcode.go b/pkg/ffmpeg/stream_transcode.go index 27475a5f21f..ce56e07956c 100644 --- a/pkg/ffmpeg/stream_transcode.go +++ b/pkg/ffmpeg/stream_transcode.go @@ -186,7 +186,7 @@ func (o TranscodeOptions) makeStreamArgs(sm *StreamManager) Args { codec := o.FileGetCodec(sm, maxTranscodeSize) - fullhw := sm.config.GetTranscodeHardwareAcceleration() && sm.encoder.hwCanFullHWTranscode(sm.context, o.VideoFile, codec) + fullhw := sm.config.GetTranscodeHardwareAcceleration() && sm.encoder.hwCanFullHWTranscode(sm.context, codec, o.VideoFile, maxTranscodeSize) args = sm.encoder.hwDeviceInit(args, codec, fullhw) args = append(args, extraInputArgs...)