User Tools

Site Tools


video:encoding

FFMPEG and NVENC

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
h264.bat
ffmpeg -i "%1" -codec:v h264_nvenc -b:v 20000k -maxrate 25000k -preset slow -bf 3 -g 220 -sws_dither none -sws_flags lanczos -s 1920x1080 -codec:a aac -ab 192k "%1_1080p.mp4"

Create GIF

creategif.bat
@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"

Defish

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

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

Create slideshow from pictures

slideshow.bat
ffmpeg -f concat -i list.txt -codec:v libx264 -b:v 1000k -maxrate 20000k -filter:v "crop=in_w:in_h-360" -sws_flags lanczos -s 1920x1080 -aspect 16:9 -pix_fmt yuv420p -pass 1 -f mp4 NUL
ffmpeg -f concat -i list.txt -codec:v libx264 -b:v 1000k -maxrate 20000k -filter:v "crop=in_w:in_h-360" -sws_flags lanczos -s 1920x1080 -aspect 16:9 -pix_fmt yuv420p -pass 2 "slideshow.mp4"
list.txt
file '0.jpg'
duration 10
file '0_02.jpg'
duration 10

2-pass x264

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

Rip to MP3

ripmp3.bat
c:\programs\stream\ffmpeg -i video.mp4 -b:a 192K -vn music.mp3
video/encoding.txt · Last modified: 2018/08/12 13:46 by Jan Forman