The FFmpeg PPA supplies older versions, which may not have the option. Generally, it's not recommended to install ffmpeg from distribution packages – rather compile it yourself or download a static build from their homepage.
You don't necessarily have to use the glob patterns – an input file like ffmpeg -i 'snapshot-%05d.jpg' output.mp4
should also work.
Note that for this, you should always use the latest ffmpeg version, and preferably compile it yourself. This gives you access to the most recent libx265 and libfdk-aac for audio encoding.
Also, the data rate savings will be quite drastic if you're going from a ~10 MBit/s DVD to around 1–2 MBit/s for H.264 video and 0.5–1 MBit/s for H.265 video. Changing the quality in the below steps may influence the bitrates, but still the data reduction should be significant.
H.264
For the quality / rate control, you want to use CRF mode in libx264 rather than a constant bitrate. Using CRF ensures that an average quality is preserved, independent of the original video resolution or its complexity. Constant bitrate is only really useful if you're constrained by the transmission medium (e.g. hard drive speed, Internet throughput).
Choosing the CRF value is the tricky part. It requires you to look at the output. The default for libx264 (23) offers a quite good tradeoff between size and quality. But given that your original source is already compressed (and not with a very good quality compared to Blu-rays), you may want to change the CRF to be a little lower, such as 20. This will increase needed bitrate by about a third.
Choose the preset according to how long you want to wait. slow
seems like a good value here.
ffmpeg -i input \
-c:v libx264 -crf 20 -pix_fmt yuv420p \
-x264-params keyint=240:min-keyint=20 \
-preset:v slow -profile:v baseline -level 3.0 \
-c:a libfdk_aac -vbr 4 \
output.mp4
The built-in ffmpeg AAC encoder can be used if libfdk-aac is not available. Use -c:a aac -strict experimental -b:a 128k
instead of -c:a libfdk_aac -vbr 4
.
H.265
Research suggests that using HEVC will lead to up to 74% bitrate saving compared to H.264. This is based on subjective viewing data of Ultra-HD sequences. Of course, it depends on the temporal complexity of the source content, and the amount of data saved will not be as high for hard to code sequences. Either way you can safely say that 50% data reduction is absolutely possible.
The default CRF for libx265 is 28. Using the same source content, it results in about half the bitrate compared to libx264 at CRF 23. This is irrespective of the actual bitrate, i.e., if the H.264 version takes 1.5 MBit/s, then H.265 will use around 750 kBit/s, but it's 750 kBit/s vs. 350 kBit/s for another sequence. I ran it on a couple of sequences at DVD-PAL resolution and was not able to tell the difference in terms of quality.
ffmpeg -i input \
-c:v libx265 -pix_fmt yuv420p \
-x265-params crf=28:keyint=240:min-keyint=20 \
-preset:v slow \
-c:a libfdk_aac -vbr 4 \
output.mp4
For more information, here are the relevant resources:
Best Answer
Instead of reading the Arch Wiki, rather check the ffmpeg documentation on the preset options. All should be explained there.
Note that there are three different kinds of presets:
.ffpreset
files: You defineoption=value
pairs in those files and for video settings you generally use them with-vpre
. Depending on the encoder you select, ffmpeg will then search for a matchingffpreset
file. For example, if you set-vcodec libvpx
(or-c:v libvpx
), and-vpre 1080p
, then ffmpeg will load thelibvpx-1080p.ffpreset
file.You can also, more generally, use
-pre
and specifyvcodec=libvpx
as an option/value pair in the.ffpreset
file. This allows you to set video and audio encoders at the same time. For example, you simply call-pre custom
, and ffmpeg will load thecustom.ffpreset
file..avpreset
files: work similar to-vpre
or-apre
presets — those are mostly for compatibility with Libav.x264 presets: x264 is an H.264 encoder (used in ffmpeg with
-c:v libx264
). It has several presets which basically control the speed of the encoder in inverse relation to the quality or efficiency of the encoding process. Those presets have nothing to do with ffmpeg's presets, and they're called with the-preset
option. They have names likeultrafast
,superfast
,veryfast
,faster
,fast
,medium
,slow
,slower
orveryslow
. Read the H.264 encoding guide for more about that, or callx264 --fullhelp
for the preset description.