I want to encode a video, that has a length of 60 seconds, to a target or maximum size of 10 MB.
There are two approaches I know of. One is explained in the FFMPEG-Wiki, and the other one I found in the documentation. Unfortunately, I haven't found an explanation on when to use what method.
Is any of those methods recommended? If not, what are the upsides/downsides of each method?
1) Calculate and set Bitrate to match the length of the video as explained in the ffmpeg-wiki
(10 MB * 8192 [converts MB to kilobits]) / 60 seconds = ~1365 kbits/s total bitrate 1365k - 128k (desired audio bitrate) = 1237k video bitrate
ffmpeg -y -i input -c:v copy -preset medium -b:v 1237k -pass 1 -c:a copy -b:a 128k -f mp4 /dev/null && \
ffmpeg -i input -c:v libx264 -preset medium -b:v 1237k -pass 2 -c:a libfdk_aac -b:a 128k output.mp4
2) Use the -fs
parameter and let ffmpeg figure it out.
ffmpeg -i input -c:v copy -c:a copy -preset medium -crf 23 -fs 10485760 output.mp4
libx264
asc:v
. In thefs
example, you aren't transcoding the video, since-c:v copy
is used. So, thepreset
andcrf
also don't have any effect.