old years ffmpeg distribute only the source code and there are many people made webpages and spreading the binaries.
now days is only one site.
show video information
convert 4:3 video to 16:9
by default if nothing specified on cmd line, uses libx264 (h264) codec.
You can use -crf or -b:v with a maximum bit rate by specifying both -maxrate and -bufsize. (src)
convert to 480p - avoid "height not divisible by 2"
Make a batch file to drag & drop the video file
bufsize
crf
16:9 resolutions :
references :
ffmpeg - H.264 Video Encoding Guide
ffmpeg - Scale Filter
ffmpeg - Codecs
Doing 2 pass encoding with FFmpeg
@tigefa4u/personal quick ffmpeg cheat sheet
Limit output filesize - no other switches can be used, when the encoding reaches the excepted filesize stops, so the result can be the half movie
16:9 <> 4:3
libx265
ffmpeg -ss and -t for cutting for video / mp3
Avidemux Tutorial for fixing 4:3 to 16:9
Change CPU Priority
now days is only one site.
show video information
ffmpeg.exe -i "input.mp4"
convert 4:3 video to 16:9
by default if nothing specified on cmd line, uses libx264 (h264) codec.
- CBR (Constant Bit Rate) - Target specific filesize (aka bitrate)
ffmpeg.exe -i "input.mp4" -b:v 376k -maxrate 376k -bufsize 700k -vf "scale=854x480,setsar=1" -c:a aac -b:a 96k "output.mp4"
- Constrained encoding (VBV / maximum bit rate)
ffmpeg.exe -i "input.mp4" -crf 30 -maxrate 450k -bufsize 800k -vf "scale=854x480,setsar=1" -c:a aac -b:a 96k "output.mp4"
crf = where 0 is lossless, 23 is default, and 51 is worst possible. A lower value is a higher quality (src)
- Constrained encoding with libx265 (h265) codec
ffmpeg.exe -i "input.mp4" -crf 30 -vcodec libx265 -vf "scale=854x480,setsar=1" -c:a aac -b:a 96k "output.mp4"
You can use -crf or -b:v with a maximum bit rate by specifying both -maxrate and -bufsize. (src)
convert to 480p - avoid "height not divisible by 2"
//normal : ffmpeg.exe -i "input.mp4" -crf 27 -vf scale=-1:480 "output.mp4" -- "height not divisible by 2"
//fix - https://dtbaker.net/blog/ffmpeg-width-or-height-not-divisible-by-2/
ffmpeg.exe -i "input.mp4" -crf 27 -vf scale=-2:480 "output.mp4"
- Target specific filesize (aka bitrate) - how to calculate
//this will show the movie length in seconds
ffprobe.exe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "input.mp4"
//source - https://trac.ffmpeg.org/wiki/Encode/H.264#twopass
//you can achieve the same result at https://www.3ivx.com/support/calculator/
Assuming you have a video is 1h 40m and you would like to trim down to 350mb with audio 96kbits, the calculation is (8192 is constant) ;
targetSize * 8192 / ffprobe result
350 * 8192 / 6071,72 = 472kBit/s (total bitrate)
472 - 96 (desired audio bitrate) = 376kBit/s video bitrate
- Two-pass
It's recommended to use a two-pass encoding mode if you want to target specific filesize (aka bitrate).
On 2022, using 2 passes with libx265 not recommended, nothing changes. (src)
Nevertheless, the use is :
construct the needed cmd line, and add -pass 1, these will generate a log file, then use the same cmd line but now with -pass 2 to do the actual conversion.
Make a batch file to drag & drop the video file
JavaScript:
@echo off
if [%1]==[] goto usage
:: filepath of ffmpeg
set ffmpeg="c:\tools\ffmpeg.exe"
set ffprobe="c:\tools\ffprobe.exe"
set dd=%~1h265.mp4
%ffmpeg% -i "%~1" -crf 30 -vcodec libx265 -vf "scale=854x480,setsar=1" -c:a aac -b:a 96k "%dd%"
::%ffmpeg% -i "%~1" -crf 30 -maxrate 450k -bufsize 800k -vf "scale=854x480,setsar=1" -c:a aac -b:a 96k "%dd%"
::%ffmpeg% -i "%~1" -b:v 376k -maxrate 376k -bufsize 700k -vf "scale=854x480,setsar=1" -c:a aac -b:a 96k "%dd%"
::%ffmpeg% -i "%1"
::%ffprobe% -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "%~1"
pause
exit
:usage
@echo please drag and drop a file
pause
exit
bufsize
Based on the -bufsize option, ffmpeg will calculate and correct the average bit rate produced. If we didn't specify -bufsize, these intervals could be significantly longer than we would want. This would cause the current bit rate to frequently jump a lot over and below the specified average bit rate and would cause an unsteady output bit rate.
If we specify a smaller -bufsize, ffmpeg will more frequently check for the output bit rate and constrain it to the specified average bit rate from the command line. Hence, lowering -bufsize lowers the bitrate variation that the encoder can produce.
Specifying too small -bufsize would cause ffmpeg to degrade the output image quality, because it would have to (frequently) conform to the limitations and would not have enough of a free space to use some optimizations (for example, optimizations based on the frame repetitions and similar), because the buffer would not contain enough frames for the optimizations to be effective. (src)
crf
Use this rate control mode if you want to keep the best quality and care less about the file size. This is the recommended rate control mode for most uses.
This method allows the encoder to attempt to achieve a certain output quality for the whole file when output file size is of less importance. This provides maximum compression efficiency with a single pass. By adjusting the so-called quantizer for each frame, it gets the bitrate it needs to keep the requested quality level. The downside is that you can't tell it to get a specific filesize or not go over a specific size or bitrate, which means that this method is not recommended for encoding videos for streaming. (src)
16:9 resolutions :
- 640 x 360 (nHD)
- 854 x 480 (FWVGA)
- 960 x 540 (qHD)
- 1024 x 576 (WSVGA)
- 1280 x 720 (HD/WXGA)
- 1366 x 768 (FWXGA)
- 1600 x 900 (HD+)
- 1920 x 1080 (FHD)
- 2048 x 1152 (QWXGA)
- 2560 x 1440 (QHD)
- 3200 x 1800 (WQXGA+)
- 3840 x 2160 (UHD)
- 5120 x 2880 (UHD+)
- 7680 x 4320 (FUHD)
- 15360 x 8640 (QUHD)
- 30720 x 17280 (HHD)
- 61440 x 34560 (FHHD)
- 122880 x 69120 (QHHD)
references :
ffmpeg - H.264 Video Encoding Guide
ffmpeg - Scale Filter
ffmpeg - Codecs
Doing 2 pass encoding with FFmpeg
@tigefa4u/personal quick ffmpeg cheat sheet
Limit output filesize - no other switches can be used, when the encoding reaches the excepted filesize stops, so the result can be the half movie
16:9 <> 4:3
libx265
ffmpeg -ss and -t for cutting for video / mp3
Avidemux Tutorial for fixing 4:3 to 16:9
Change CPU Priority
Last edited: