I have some video files which were transferred from black-and-white film to 29.97 fps interlaced. The film was transferred too darkly (meaning that it requires some brightening), and it also has some dull off-color artifacts. I was able to adjust the brightness levels, set the saturation to zero, and deinterlace using ffmpeg:
ffmpeg -y -hwaccel cuda -hwaccel_output_format cuda -i in.mkv -vf curves=psfile="curves.acv",hue=s=0,hwupload,yadif_cuda=1 -c:v h264_nvenc -preset:v p7 -tune:v hq -rc:v vbr -cq:v 10 -b:v 0 -maxrate 240M -bufsize 480M -c:a copy out.mkv
Using the output file -- now deinterlaced to 59.94fps -- I stepped frame-by-frame in VLC, where I counted a recurring pattern of duplicate frames: 3, 2, 3, 2, 3, 2, 3, ... which, I deduced, is coming from a 24 fps --> 60 fps conversion. The "duplicate" frames are not really identical -- each has some different amounts of noise, which one could attribute to the way the film was recorded, and the de-interlacing job that I'm performing now.
I know that it is possible to throw out these duplicate frames using ffmpeg, but because the video was encoded with low light levels, the dynamic range was compromised, and the dark areas in each frame have poor resolution. Rather than simply toss out the duplicate frames, I am wondering how I could average them, to obtain a bit better clarity in the noisy areas.
I also need to ensure that the frames which are deleted correspond to the actual duplicates: i.e., ffmpeg should throw out the two duplicate frames that correspond to the "3"s above, rather than the "2"s, for which only one frame should be deleted.
I have tried checking the ffmpeg documentation of the fps filter:
https://ffmpeg.org/ffmpeg-filters.html#fps
But there does not seem to be any averaging procedure, nor any clear algorithm for choosing which frames are deleted. Will it start by assuming a "3" repeat, or a "2"?
In principle I would like to add something to my video filters in the command above so that the video file is only re-encoded once.
Thanks for any help or advice!