Automating finding optimal parameters for re-encoding random video files with ffmpeg / avcov
1
vote
0
answers
62
views
I've done a bit of re-encoding of video with ffmpeg, mainly aimed at recompressing videos from assorted sources (youtube, twitch, tiktok, etc) to reduce file size with acceptable (subjective) amounts of loss in quality. Given that I know little about the quality setting of the original files (and these vary over time anyway), the process for any one file is very time consuming. Every time, the process is something like this:
1. Compress a chunk of video
2. Compare the compressed chunk against the original
3. Bump the crf up or down based on how bad the re-encode looks.
4. Repeat until the ideal crf value for a given file is found, or I get tired and give up.
This is essentially the "trial and error" approach that comes up as the only answer every time somebody asks how to find optimal settings. Trial and error works, of course, but it requires interaction after every loop. Given that ffmpeg can also calculate the loss for a given encode (PSNR or VMAF), are there any frontends or wrapper scripts implementing an automated process?
A different approach would be a script or frontend that generates a 'contact sheet' of re-encodes, basically re-encoding a small chunk of the original file repeatedly over a range of CRF values. Does such a thing exist already? Research how to generate previews of videos has yielded a lot of approaches to creating youtube-like preview snippets, not quality test snippets.
Asked by GDorn
(111 rep)
Dec 15, 2020, 10:27 PM