Description :
The video processing worker crashes during the Phase_3_H265_SDR and Phase_4_H265_HDR encoding phases. The crash is caused by the FFmpeg command failing with an Invalid argument (-22) error.
Root Cause :
In src/infrastructure/ffmpeg/encoding/flags.ts, the -tune film flag is hardcoded for all video encodes in the videoEncoderFlags function. While the libx264 (AVC) encoder supports this tuning parameter, the libx265 (HEVC) encoder rejects it in our current FFmpeg build, causing an immediate fatal crash during initialization.
Steps to Reproduce :
- Upload a source video to trigger the worker pipeline.
- The worker successfully completes
Phase_1_Audio and Phase_2_H264_SDR.
- The worker attempts to start
Phase_3_H265_SDR.
- The pipeline throws a
TranscodeError and the job fails.
Error Logs :
[libx265 @ 0x562091282180] Error setting preset/tune slow/film.
[vost#0:0/libx265 @ 0x5620912f4180] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[fc#0 @ 0x562091273740] Task finished with error code: -22 (Invalid argument)
Proposed Fix :
Update the videoEncoderFlags function in src/infrastructure/ffmpeg/encoding/flags.ts to conditionally apply the -tune film parameter only when the codec is libx264.
Affected File : src/infrastructure/ffmpeg/encoding/flags.ts
Possible Code Change :
// Replace:
'-preset', variant.preset,
'-tune', 'film',
// With:
'-preset', variant.preset,
...(codec === 'libx264' ? ['-tune', 'film'] : []),
Acceptance Criteria :
Description :
The video processing worker crashes during the
Phase_3_H265_SDRandPhase_4_H265_HDRencoding phases. The crash is caused by the FFmpeg command failing with anInvalid argument (-22) error.Root Cause :
In
src/infrastructure/ffmpeg/encoding/flags.ts, the-tune filmflag is hardcoded for all video encodes in thevideoEncoderFlagsfunction. While thelibx264(AVC) encoder supports this tuning parameter, thelibx265(HEVC) encoder rejects it in our current FFmpeg build, causing an immediate fatal crash during initialization.Steps to Reproduce :
Phase_1_AudioandPhase_2_H264_SDR.Phase_3_H265_SDR.TranscodeErrorand the job fails.Error Logs :
[libx265 @ 0x562091282180] Error setting preset/tune slow/film. [vost#0:0/libx265 @ 0x5620912f4180] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height. [fc#0 @ 0x562091273740] Task finished with error code: -22 (Invalid argument)Proposed Fix :
Update the
videoEncoderFlagsfunction insrc/infrastructure/ffmpeg/encoding/flags.tsto conditionally apply the-tune filmparameter only when the codec islibx264.Affected File :
src/infrastructure/ffmpeg/encoding/flags.tsPossible Code Change :
Acceptance Criteria :
-22crasheslibx264variants correctly retain thefilmtuning parameter in their FFmpeg command string