Example below converts images to a VP9-codec video.
$ ffmpeg -framerate 25 -i img-%3d.png -c:v libvpx-vp9 -pix_fmt yuva420p outputfilename.webm
Notes:
-framerate = number of frames per second
-i = input filenames using wildcard of 3 digits in the name, e.g. img-001.png through img-999.png
-libvpx-vp9 = VP9, which has wide browser support
-pix_fmt = yuva420p which is a common web protocol, and can also support an alpha channel
Example below converts png images to a ProRes 4444-codec video:
$ ffmpeg -framerate 25 -i img-%3d.png -c:v prores_ks -pix_fmt yuva444p10le -alpha_bits 16 -profile:v 4444 -f mov -vframes 150 outputfilename.mov
Notes:
-framerate = number of frames per second
-i = input filenames using wildcard of 3 digits in the name, e.g. img-001.png through img-999.png
-c:v prores_ks = convert the video to ProRes codec
-pix_fmt yuva444p10le - create the video with the pixel format for the ProRes 4444 specified
-alpha_bits = 16 bits
-profile:v 4444 = video profile for the ProRes 4444 specified
Example to break a webm video w/transparency into its separate images again:
$ ffmpeg -vcodec libvpx-vp9 -i inputfilename.webm -pix_fmt rgba -r 25 out/img-%d.png
Notes:
-vcodec = libvpx (older library) or libvpx-vp9 (new more advanced library)
-pix_fmt = RGB with Alpha channel
-r 25 = 25 frames/second
out = output with incrementing digits for each video frame
Example of Movie conversion to AV1 format with alpha:
$ ffmpeg -y -i inputfilename.mov -filter_complex "[0:v]format=pix_fmts=yuva444p[main]; [main]split[main][alpha]; [alpha]alphaextract[alpha]; [main][alpha]vstack" -pix_fmt yuv420p -an -c:v libaom-av1 -cpu-used 3 -crf 45 -pass 1 -f null /dev/null && ffmpeg -y -i inputfilename.mov -filter_complex "[0:v]format=pix_fmts=yuva444p[main]; [main]split[main][alpha]; [alpha]alphaextract[alpha]; [main][alpha]vstack" -pix_fmt yuv420p -an -c:v libaom-av1 -cpu-used 3 -crf 45 -pass 2 -movflags +faststart outputfilename.mp4
Notes:
-crf - lower number is better quality, typically more time to convert, and larger file-size
[main]split[main][alpha] forks the input/output, and [alpha]alphaextract[alpha] sets the alpha data to a black&white luminosity of the transparency
[main][alpha]vstack places the alpha back on top of the main video components.
Example of Movie conversion to HEVC format with alpha:
INPUT="in.mov" OUTPUT="hevc.mp4" CRF=30 PRESET="veryslow" bash -c
$ ffmpeg -y -i inputfilename.mov -filter_complex "[0:v]format=pix_fmts=yuva444p[main]; [main]split[main][alpha]; [alpha]alphaextract[alpha]; [main][alpha]vstack" -pix_fmt yuv420p -an -c:v libx265 -preset veryslow -crf 30 -tag:v hvc1 -movflags +faststart outputhevc.mp4
previous page
|