I thought of a solution very similar to one answer, deleted from a community boot, which is therefore not visible to all users.
I don't think ffmpeg
can do it all by itself. Better to use find
to find the files and then call ffmpeg
on them with the right parameters.
ffmpeg
You can use a codec that has better compression on its own, like libx265
, and then choose to reduce the definition and/or the number of frames per second. The parameters to choose for ffmpeg
is up to you, it will be something like this
ffmpeg -i input.mp4 -vf scale=1280:-2 -c:v libx265 -crf 30 output.mp4
Note on crf:
If you’re unsure about what CRF to use, begin with the default and change it according to your subjective impression of the output. Is the quality good enough? No? Then set a lower CRF. Is the file size too high? Choose a higher CRF. A change of ±6 should result in about half/double the file size, although your results might vary.
find
From the root directory which haves a lot of folder inside you can run find
with the ffmpeg
command line with your desired parameters.
find . -type f -name "*.mp4" -exec ffmpeg -i {} -vf scale=1280:-2 -c:v libx265 -crf 30 {}.newlycompressed.mp4 \;
Note:
you may want to run in advance another call to find
to store the filenames to delete after you check it was all ok...
find . -type f -name "*.mp4" -exec echo "rm " {} \; >> Files_to_be_deleted