Free, open source software for transcoding

· Application software · #note/sink ·



filters in a chain are separated by commas ","
chains by a semicolon ";"
if an input or output is not specified it is assumed to come from the preceding or sent to the following item in the chain.



The FFmpeg rescaler provides a high-level interface to the libswscale library image conversion utilities. In particular it allows one to perform image rescaling and pixel format conversion.
https://trac.ffmpeg.org/wiki/Scaling https://ffmpeg.org/ffmpeg-scaler.html

iw is input width
-1 and -2 to preserve ratio

ffmpeg -i input -vf "scale=iw/2:-1" output



To list all possible internal presets and tunes:

"%ffdev%\ffmpeg" -hide_banner -f lavfi -i nullsrc "-c:v libx264" -preset help -f mp4 -y NUL

chaneru x264 doc

Rate control

There are two rate control modes that are usually suggested for general use:


The range of the CRF scale is 0–51, where 0 is lossless (for 8 bit only, for 10 bit use -qp 0), 23 is the default, and 51 is worst quality possible. A lower value generally leads to higher quality, and a subjectively sane range is 17–28. Consider 17 or 18 to be visually lossless or nearly so; it should look the same or nearly the same as the input but it isn't technically lossless.

The range is exponential, so increasing the CRF value +6 results in roughly half the bitrate / file size, while -6 leads to roughly twice the bitrate.

Will two-pass provide a better quality than CRF?
​No, though it does allow you to target a file size more accurately.

Two-pass ABR

For two-pass, you need to run ffmpeg twice, with almost the same settings, except for:

When using option -an, you may eventually get a segfault or a broken file. If so, remove option -an and replace by -vsync cfr to the first pass.


To see a list of current presets with -preset help
If you target a certain file size or constant bit rate, you will achieve better quality with a slower preset. Similarly, for constant quality encoding, you will simply save bitrate by choosing a slower preset.



x265 docs


FFmpeg wiki

REM h264_nvenc help
"%ffdev%\ffmpeg" -hide_banner -h encoder=h264_nvenc

Sequence to video

Many high-end video pipelines work with DPX, EXR or TIFF sequences. To transform these sequences into video files, the easiest way is to specify the first file in the sequence as the input and then use -framerate to set the input frame rate and -r to set the output frame rate:

ffmpeg -i input_0001.dpx -framerate 59.94 -c:v libx264 -b:v 30M -r 29.97 -an output.mp4


and Paletteuse, dithering options



Getting info and help

For filters, codecs, muxers, etc



rem Get encoder help
"%ffdev%\ffmpeg" -hide_banner -h encoder=exr
rem Get encoder help
"%ffdev%\ffmpeg" -hide_banner -h encoder=tiff
rem Get encoder help
"%ffdev%\ffmpeg" -hide_banner -h encoder=aac
rem Get pixel formats for encoder
"%ffdev%\ffmpeg" -hide_banner -h encoder=h264_nvenc
rem Get pixel formats for encoder
"%ffdev%\ffmpeg" -hide_banner -h encoder=hevc_nvenc
rem Get pixel formats for encoder
"%ffdev%\ffmpeg" -hide_banner -h encoder=libvpx-vp9
rem Get pixel formats for encoder
"%ffdev%\ffmpeg" -hide_banner -h encoder=mjpeg
rem Get pixel formats for encoder
"%ffdev%\ffmpeg" -hide_banner -h encoder=png
rem Get pixel formats for encoder
"%ffdev%\ffmpeg" -hide_banner -h encoder=libx264
rem Get pixel formats for encoder
"%ffdev%\ffmpeg" -hide_banner -h encoder=libx265


rem Get pixel formats for encoder
"%ffdev%\ffmpeg" -hide_banner -h encoder=aac
rem Get pixel formats for encoder
"%ffdev%\ffmpeg" -hide_banner -h encoder=ac3
rem Get pixel formats for encoder
"%ffdev%\ffmpeg" -hide_banner -h encoder=pcm_s16le

Pixel formats

rem Get all pixel formats
"%ffdev%\ffmpeg" -hide_banner -pix_fmts
rem Get pixel formats for encoder
"%ffdev%\ffmpeg" -hide_banner -h encoder=libx264 | findstr "pixel"


rem Get pixel muxer's private options
"%ffdev%\ffmpeg" -hide_banner -h muxer=apng
rem Get pixel muxer's private options
"%ffdev%\ffmpeg" -hide_banner -h muxer=mjpeg

Colorspace conversion



Count keyframes

set "file=D:\Keerah\Projects1\stf tests\thecolour05.mov"
"%ffdev%\ffprobe.exe" -hide_banner -of compact=p=0:nk=1 -select_streams "v:0" -count_frames -show_entries stream=nb_read_frames -skip_frame nokey -v 0 -i "%file%"

Show streams

set "file=D:\Keerah\Projects1\stf tests\Blossom1.04d.tif"
"%ffdev%\ffprobe.exe" -v error -hide_banner -show_streams -show_format -sexagesimal -i "%file%"
set "file=D:\Keerah\Projects1\stf tests\Senses_preview.webm"
"%ffdev%\ffprobe.exe" -v error -hide_banner -show_streams -show_format -sexagesimal -i "%file%"
set "file=F:\Keerah\Projects2\2012\Karaban - Goodavto\passat_updated.mp4"
"%ffdev%\ffprobe.exe" -v error -hide_banner -show_streams -show_format -sexagesimal -i "%file%"

Formatting output

set "file=D:\Keerah\Projects1\stf tests\thecolour05.mov"
"%ffdev%\ffprobe.exe" -v error -hide_banner -show_entries "format=format_name" -of "default=noprint_wrappers=1:nokey=1" -sexagesimal -i "%file%"

rem also:
-of flat
-of compact=p=0
-of json
-of xml

Get particular stream data

set "file=D:\Keerah\Projects1\stf tests\thecolour05.mov"
"%ffdev%\ffprobe.exe" -v error -hide_banner -show_entries "stream=width,height,duration,codec_name,pix_fmt,color_space,color_primaries,color_transfer,color_range,avg_frame_rate" -select_streams "v:0" -sexagesimal -i "%file%"



Simple version using stats parameters

ffmpeg -v warning -hide_banner -stats ${your_params}

Write to file

FFmpeg in a separate process

-progress %TEMP%\progr.txt


Port watcher

FFmpeg in a separate process


DURATION= $(ffprobe -select_streams v:0 -show_entries "stream=duration" \
    -of compact $INPUT_FILE | sed 's!.*=\(.*\)!\1!g')

nc -l $WATCHER_PORT | while read; do
    sed -n 's/out_time=\(.*\)/\1 of $DURATION/p')
done &

ffmpeg -y -i $INPUT_FILE -progress localhost:$WATCHER_PORT $OUTPUT_ARGS