From ChatGPT,
ffmpeg -i filename_%05d.jpg -c:v hevc_qsv -preset veryslow -global_quality 0 output_lossless_qsv.mkv
For 4K (4096x4096) files, this was running at around 8 fps on my i5 laptop, as against 2 fps for non-accelerated libx264. The mistake I made earlier was to put the preset before the -c:v.
- -i must come before input options end.
- All encoder options (-c:v, -preset, -global_quality) must be placed after the input and before the output filename.
If you place -preset before -i filename_%05d.jpg, FFmpeg thinks it’s a decoder option, causing the error:
Codec AVOption preset ... is not a decoding option.
With audio, we would need something like
ffmpeg -r 30 -i KG-LS_%05d.jpg -i audio.wav \
-c:v hevc_qsv -preset veryslow -global_quality 0 \
-c:a aac -b:a 192k \
-shortest \
output_with_audio.mkv
# or on Windows,
ffmpeg -r 30 -i KG-LS_%05d.jpg -i audio.wav ^
-c:v hevc_qsv -preset veryslow -global_quality 0 ^
-c:a aac -b:a 192k ^
-shortest ^
output_with_audio.mkv
Edit - this produces a
low-bitrate video with colour issues on VLC (and perhaps on other players. The python front-end presets, like the command below, might be useful -
FFmpeg command to copy-paste:
ffmpeg -y -i in_%05d.jpg -i map_x_directp2.pgm -i map_y_directp2.pgm -i weight_alpha_mask.png -filter_complex '[0:v][1:v][2:v]remap[remapped];[3:v]format=gray,scale=4096:4096,colorchannelmixer=rr=1:gg=1:bb=1[mask_rgb];[remapped][mask_rgb]blend=all_mode=multiply[blended];[blended]scale=3840:2160,setsar=1,setdar=16/9,format=yuv420p[out]' -map '[out]' -map '0:a?' -c:v hevc_qsv -preset fast -crf 23 -pix_fmt yuv420p -c:a aac -b:a 128k D:/out-W4K.mp4
So, without warping, that would be -
ffmpeg -y -i in_%05d.jpg -i audio.wav -c:v hevc_qsv -preset veryslow -crf 1 -pix_fmt yuv420p -c:a aac -b:a 128k out.mp4
But unfortunately, even the warping command produces a low bitrate video with colour issues. Green tinted instead of purple tinted for the earlier videos. Even changing the codec to libx265 did not help. So, some incompatibility in the input frames is suspected. Maybe I'll just use avidemux instead instead of trying to troubleshoot.
From
ffmpeg -h
Getting help:
-h -- print basic options
-h long -- print more options
-h full -- print all options (including all format and codec specific options, very long)
-h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocol
ffmpeg -h encoder=hevc_qsv
....
-preset <int> E..V....... (from 1 to 7) (default medium)
veryfast 7 E..V.......
faster 6 E..V.......
fast 5 E..V.......
medium 4 E..V.......
slow 3 E..V.......
slower 2 E..V.......
veryslow 1 E..V.......
....
-profile <int> E..V....... (from 0 to INT_MAX) (default unknown)
unknown 0 E..V.......
main 1 E..V.......
main10 2 E..V.......
mainsp 3 E..V.......
rext 4 E..V.......
scc 9 E..V.......
Claude.ai pointed out that the colour tint issues are probably due to wrong pixel format, and the low bitrate is probably because "QSV's CRF implementation is unreliable". So, suggestion is to use nv12 pixel format and global_quality instead of CRF, where quality of 15-20 is near lossless. Or force a high bitrate if that doesn't work -
-b:v 20M -maxrate 25M
ffmpeg -y -r 30 -i in_%05d.jpg -i audio.wav -c:v hevc_qsv -preset veryslow -global_quality 18 -pix_fmt nv12 -c:a aac -b:a 128k out.mp4
And that solved the problem.
No colour tint, hevc_qsv encoder resulted in a 25 Mbps video, libx265 encoder with the same preset and quality settings but without the -pix_fmt nv12 resulted in a 7 Mbps video, both of good quality.