User Tools

Site Tools



nVidia -hwaccel cuvid -c:v h264_cuvid
Start from frame -ss 5
HQ framerate 30fps -r ntsc
Use photoshop levels -vf curves=psfile=input.acv
Deblocking, Autolevels ,pp=ha/va/al
Convert colors -vf colormatrix=bt709:bt601

Show codec parameters

ffmpeg -h encoder=h264_omx

Quality based encoder NVENC

ffmpeg -i "%1" -codec:v h264_nvenc -rc:v vbr_hq -qmin:v 12 -qmax:v 18 -maxrate:v 60M -profile:v high -preset slow -bf 3 -rc-lookahead 16 -g 220 -sws_dither none -sws_flags lanczos -s 1920x1080 -codec:a libopus -ab 192k "%1_1080p.mp4"

Create GIF

@set /p CLUT=How Many Colors (4..256): 
@echo Number of colors: %CLUT%
@set /p BS=Bayer_Strength (0..5 lower is stronger): 
@echo Bayer Strength: %BS%
@ffmpeg.exe -y -stats -hide_banner -i "%1" -an -sn -dn -sws_dither ed -filter_complex "crop=1920:784:0:148,scale=640:-2:sws_flags=spline+accurate_rnd+full_chroma_int+full_chroma_inp:in_range='mpeg/tv':out_range='jpeg/full/pc',hqdn3d=5,smartblur=lr=1.75:ls=-0.50:lt=-5.5:cr=0.5:cs=1.0:ct=0.5,minterpolate=fps=25/2:mi_mode=mci:me_mode=bidir:me=epzs:vsbmc=1,scale=320:-2:sws_flags=spline+accurate_rnd+full_chroma_int+full_chroma_inp,xbr=2,scale=iw/2:-2:sws_flags=spline+accurate_rnd+full_chroma_int+full_chroma_inp,format=pix_fmts=rgb444le,split=2[vid][clut];[clut]palettegen=max_colors=%CLUT%:reserve_transparent=0:stats_mode=diff[out2]" -map [vid] -c:v ffv1 "%~n1_ll.mkv" -map [out2] "%~n1_CLUT%CLUT%_D.png"
@ffmpeg.exe -y -stats -hide_banner -i "%~n1_ll.mkv" -i "%~n1_CLUT%CLUT%_D.png" -lavfi "paletteuse=dither=bayer:bayer_scale=%BS%" -loop 0 -vsync 0 "%~n1_CLUT%CLUT%_D_BS%BS%.gif"
@rem  Optimizing GIF...
@gifsicle.exe -V -O3 "%~n1_CLUT%CLUT%_D_BS%BS%.gif" -o "%~n1_CLUT%CLUT%_D_BS%BS%_o.gif"


ffmpeg -i "$1" \ -filter_complex 'extractplanes=y+u+v[y][u][v]; [u] scale=w=3840:h=2160:flags=print_info+neighbor+bitexact [us]; [v] scale=w=3840:h=2160:flags=print_info+neighbor+bitexact [vs]; [y][us][vs]mergeplanes=0x001020:yuv444p,format=pix_fmts=yuv444p10le,hqdn3d=3:3:5:5,frei0r=lenscorrection:0.5:0.5:0.16:0.6,scale=w=1920:h=1080:flags=print_info+bicubic+full_chroma_inp+full_chroma_int' \ -sws_dither none \ -q 0 -quant_mat hq \ -c:v prores_ks \ -profile:v 4 \ -c:a copy \ -c:s copy \ -c:d copy \ -map 0 \ "$2/$1"

23fps to 60fps

23,976 / 60 = 0.3996 (39.96%)
Speed up 239.76%

Rotate 90degree

ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output.mp4

Real rotate

-vf "transpose=2"

Create slideshow from pictures

c:\programs\stream\ffmpeg -f concat -i list.txt -codec:v libx265 -b:v 1000k -x265-params "pass=1" -pix_fmt yuv420p10le -preset fast -filter:v "crop=in_w:in_h-480" -maxrate 20000k -sws_flags spline -s 3840x2160 -aspect 16:9 -f mp4 nul
c:\programs\stream\ffmpeg -f concat -i list.txt -codec:v libx265 -b:v 1000k -x265-params "pass=2" -pix_fmt yuv420p10le -preset fast -filter:v "crop=in_w:in_h-480" -maxrate 20000k -sws_flags spline -s 3840x2160 -aspect 16:9 -f mp4 output.mp4
file '0.jpg'
duration 10
file '0_02.jpg'
duration 10

2-pass x264

c:\programs\stream\ffmpeg -y -i -vf curves=psfile=input.acv -preset veryslow -pix_fmt yuvj420p -c:v libx264 -b:v 30000k -pass 1 -an -f mp4 nul
c:\programs\stream\ffmpeg -i -vf curves=psfile=input.acv -preset veryslow -pix_fmt yuvj420p -c:v libx264 -b:v 30000k -pass 2 -c:a aac -b:a 320k output.mp4

Archiving in HEVC

c:\programs\stream\ffmpeg -i "uhqresize.avs" -codec:v libx265 -crf 12 -preset slow -c:a libopus -b:a 320k output.mkv

Rip to MP3

c:\programs\stream\ffmpeg -i video.mp4 -b:a 192K -vn music.mp3

Recode audio to AC3

ffmpeg -i FILE.mkv -map 0:v -map 0:a:0 -map 0:s -c copy -c:a ac3 -b:a 640k -cutoff 18000 FILE-AC3.mkv

Convert HDR to SDR

ffmpeg.exe -i input.mkv -vf zscale=t=linear:npl=100,format=gbrpf32le,
format=yuv420p -c:v libx265 -crf 18 -preset slower output.mkv

Encode HDR

ffmpeg -i source.webm -c:v libx265 -pix_fmt yuv420p10le -x265-params "level=5.2:colorprim=bt2020:colormatrix=bt2020nc:transfer=smpte2084" -crf 12 -preset medium -c:a copy output.mkv

Patch some old videos

c:\programs\stream\ffmpeg -fflags +genpts -r 30 -i "input.mkv" -codec copy -bsf:v mpeg4_unpack_bframes output.mkv

Encode Dolby Pro Logic

c:\programs\stream\ffmpeg -i input.mp4 -c:v copy -c:a:0 aac -ac 2 -b:a 320k -af "aresample=matrix_encoding=dplii" dolby-prologic.mp4

Double framerate by motion

ffmpeg -i input.hevc -filter “minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1'” output.hevc

Export video for Premiere almost lossless

c:\programs\stream\ffmpeg -i input.mp4 -c:v v210 -c:a copy output.avi

Insert HDR10 Metadata

c:\programs\hdr_metadata\mkvmerge -o output.mkv --colour-matrix 0:9 --colour-range 0:1 --colour-transfer-characteristics 0:16 --colour-primaries 0:9 --max-content-light 0:1000 --max-frame-light 0:128 --max-luminance 0:1000 --min-luminance 0:0.005 --chromaticity-coordinates 0:0.68,0.32,0.265,0.690,0.15,0.06 --white-colour-coordinates 0:0.3127,0.3290 input.mkv

Insert Stereo into 5.1 Layout

c:\programs\stream\ffmpeg -i input.mkv -filter_complex "[0:a]pan=5.1(side)|FL=FL|FR=FR|FC=FL+FR|LFE<FL+FR|SL=0.7*FL|SR=0.7*FR[a]" -map 0 -map -0:a -map "[a]" -c copy -c:a ac3 -b:a 640k output.mkv

Normalize audio

ffmpeg -i video.mkv -af "volumedetect" -vn -sn -dn -f null /dev/null
ffmpeg -i input.mkv -af "volume=5dB" output.mkv

Dynamic Normalization

ffmpeg -i input.mkv -af "dynaudnorm=m=4" output.mkv

Save frames from video

c:\programs\stream\ffmpeg -i input.mp4 -vf fps=10/60 -qscale:v 2 image-%%03d.jpg

Encode pictures to video

ffmpeg -framerate 25 -i %%06d.png -vf curves=psfile=enc.acv -pix_fmt yuv420p -codec:v libx265 -x265-params "crf=19:keyint=360" -preset veryslow output.mkv

Decode pictures from video

ffmpeg -i input.mkv -qscale:v 2 image-%%06d.jpg


ffmpeg -i input.mp4 -vcodec copy -acodec copy -encryption_scheme cenc-aes-ctr -encryption_key 100b6c20940f779a4589152b57d2dacb -encryption_kid eb676abbcb345e96bbcf616630f1a3da encrypted.mp4


You can optionally use -tune to change settings based upon the specifics of your input. Current tunings include:

film use for high quality movie content; lowers deblocking
animation good for cartoons; uses higher deblocking and more reference frames
grain preserves the grain structure in old, grainy film material
stillimage good for slideshow-like content

Encode with HDR10 Metadata

Color Primaries: bt2020
Mastering Display: Display P3
Luminance: min:0.001cm/m2 max: 1000cd/m2
1000 / 400 average

x265-params "crf=21:keyint=340:vbv-maxrate=60000:vbv-bufsize=65535:colorprim=bt2020:colormatrix=bt2020nc:transfer=smpte2084:hdr=1:info=1:repeat-headers=1:max-cll=1000,400:max-fall=400:master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1)"


video/encoding.txt · Last modified: 2021/01/26 14:23 by Jan Forman