This is a very good way to encode a top-quality WEBM file, this uses 2-pass encoding, I encoded a 30-second file and it was only 3205kB. Not bad at all. Encoding a 15-second silent WEBM file made a 1.6-megabyte file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #!/bin/bash FILE="$1" DURATION="$2" OUTFILE="$3" ffmpeg -hide_banner -y -i $FILE -t $DURATION -pix_fmt yuv420p10le -profile:v 2 -g 9999 -threads 8 \ -row-mt 1 -tile-columns 2 -tile-rows 2 -quality good -speed 2 -auto-alt-ref 1 -lag-in-frames 25 \ -arnr-maxframes 7 -arnr-strength 5 -enable-tpl 1 -c:v libvpx-vp9 -qmin 0 -qmax 63 -minrate 0 \ -b:v 873k -filter_complex "setparams=range=tv:colorspace=bt709:color_primaries=bt709:color_trc=bt709" \ -an -sn -map_metadata -1 -map_chapters -1 -bitexact -pass 1 -an -f webm /dev/null ffmpeg -hide_banner -y -i $FILE -t $DURATION -pix_fmt yuv420p10le -profile:v 2 -g 9999 -threads 8 \ -row-mt 1 -tile-columns 2 -tile-rows 2 -quality good -speed 2 -auto-alt-ref 1 -lag-in-frames 25 \ -arnr-maxframes 7 -arnr-strength 5 -enable-tpl 1 -c:v libvpx-vp9 -qmin 0 -qmax 63 -minrate 0 \ -b:v 873k -filter_complex "setparams=range=tv:colorspace=bt709:color_primaries=bt709:color_trc=bt709" \ -an -sn -map_metadata -1 -map_chapters -1 -bitexact -pass 2 $OUTFILE |
Use the script like this. ./2pass.sh 640x360_MP4_382577081780319467.mp4 15 charge.webm
. This will work just fine.
2-pass encoding is the only way to get the best quality out of an encode, this works very well. Use the -hide_banner option to hide the version information and other unneeded stuff. The -y parameter allows the script to overwrite a file when it is run again. This script should be very useful to any Linux user who wants to share very useful WebM files online.
Here is a lot of information about this WebM file I made.
(base) ┌─jason-Lenovo-H50-55@jason⬎ └─◉ 5.1-~/Videos-10:00-⚫ ◉--[$] ☕ ffprobe -hide_banner charge.webm Input #0, matroska,webm, from 'charge.webm': Metadata: encoder : Lavf Duration: 00:00:15.00, start: 0.000000, bitrate: 874 kb/s Stream #0:0: Video: vp9 (Profile 2), yuv420p10le(tv, bt709, progressive), 640x360, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 1k tbc (default) Metadata: ENCODER : Lavc libvpx-vp9 DURATION : 00:00:15.000000000 |
This would be quite useful for posting a video clip on 4chan, they allowed 4 Megabyte webm files recently.