Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Some options and filters I used in FFmpeg.
- EDIT: Hah that's a nice and memorable URL, "Software development kit, java edition, (version) 8.8.9"
- I downloaded a pre-compiled binary from www.gyan.dev (thanks!) because I didn't know how to compile it manually back then...
- Version:
- ffmpeg version 6.0-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
- built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
- Sources:
- ffmpeg.org/ffmpeg-filters.html
- trac.ffmpeg.org
- video.stackexchange.com
- superuser.com
- (Possibly other StackExchange sites)
- ==General==
- %i% is path to your input file
- %i1%, %i2%, ... are used when multiple input files are needed
- %o% is path to your output file
- -r sets framerate/tbr, usually same with fps
- -framerate sets framerate/fps, usually same with tbr.
- Nevertheless, one must set both manually, otherwise the result asrom-izu.
- -f [format]
- -t [duration]s
- -to [stop time]s
- -ss [start time]s (with -seek_timestamp)
- -timestamp ["now"|time]
- -r:v [rate]Hz
- -fpsmax [rate]Hz
- -s size [width]x[height]
- ==Recording==
- Procedure:
- 1. Turn off power save mode
- 2. Toggle resolution to 1024x768
- 3. Record
- 4. Crop with -vf crop=w=1024:h=768:x=0:y=0 for further processing
- Uses Screen Capturer Recorder, open source project from GitHub.
- chdir C:\Program Files (x86)\Screen Capturer Recorder\configuration_setup_utility\vendor\ffmpeg\bin
- ffmpeg -f dshow -i video="screen-capture-recorder" -r 30 -filter:v crop=800:600:0:0 -y D:/_o.mp4
- -f dshow -i audio="virtual-audio-capturer" D:/_o.wav
- -f dshow -i audio="Mic (Conexant SmartAudio HD)" D:/_o.wav
- -f dshow -i video="screen-capture-recorder" -r 30 -framerate 30 -maxrate 30 -bufsize 1000000 -vcodec libx264 -preset:v ultrafast D:/_putout.mp4
- ffmpeg -hide_banner -f dshow -i audio="Mic (Conexant SmartAudio HD)" -y D:/_output.wav
- ffmpeg -hide_banner -f dshow -i audio="virtual-audio-capturer" -y D:/_output.wav
- ==Basic==
- '''Aas'''
- ffmpeg -i lbla.src lbla.ass
- ffmpeg -i video.mp4 -vf ass=filename=lbla.ass video-with-subtitles.mp4
- '''Combine images'''
- -framerate 25 -i pic%3d.png -c copy -y D:/vid0.mp4
- NOTE: pic%3d.png expands to pic001.png, pic002.png, etc
- '''Combine video and audio'''
- -i D:/video.mp4 -i D:/audio.mp3 -c:v copy -map 0:v -map 1:a -y D:/video-with-sound.mp4
- '''Concat'''
- 1. Generate concat.txt
- Windows: (for %i in (*.wav) do @echo file '%i') > concat.txt
- Batch file: (for %%i in (*.wav) do @echo file '%%i') > concat.txt
- 2. -f concat -i D:/input.txt -codec copy %o%
- '''Cut without reencoding'''
- -ss 1:02 -to 1:50 -i %i% -map 0 -c copy %o%
- '''Crop'''
- -i %i% -vf crop=w=1280:h=720:x=0:y=0 %o%
- '''Edgedetect'''
- -i d:/motion-2.mp4 -vf edgedetect=low=0.2:high=0.3 d:/motion-3.mp4
- NOTE: (high - low): closer means more details, farther means less
- '''Fade'''
- -i %i% -vf fade=type=in:st=4:d=0.5 -af afade=in:st=0:d=5 %o%
- '''Fade into another video'''
- -i %i1% -i %i2% -lavfi xfade=transition=fade:duration=1:offset=5.5 %o%
- NOTE: duration is length of effect, offset is (length_of_video1 - duration/2), use n=300*15, which is frames
- '''First frame as png'''
- -i %i% -c:v copy -frames:v 1 first-frame.png
- -f image2 -start_number 100 -i img%d.jpg video-from-jpgs.mp4
- '''Framerate'''
- -vf fps=25 %o1%
- '''Last frame'''
- ffmpeg -sseof -2 -i %o2% -update 1 -q:v 1 last-frame.png
- NOTE: read last 2 seconds, and take 1 frame
- '''Looping'''
- -loop 1 -t 5 -i %i% %o%
- -i %i% -f lavfi -i anullsrc -vcodec copy -af apad -t 10 %o%
- -stream_loop 10 -i %i% -c copy D:/%o%
- '''Pitch'''
- -i %i% -af asetrate=44100*8/9,atempo=9/8 %temp%
- -i %temp% -ar 44100 %o%
- NOTE: This changes the sample rate so we must reset it...
- '''Resize'''
- -s 1280x720
- -i %i%.png -update -frames:v 1 -s 1366x706 %o%
- '''Rotate without reencoding'''
- -i %i% -metadata:s:v rotate=90 -map 0 -c copy %o%
- '''Rotate'''
- -vf rotate=PI/6+2*PI*t/10
- '''Scaling'''
- -i %o% -vf scale=w=500:h=500:flags=neighbor %o%
- '''Speed up/Slow down'''
- -vf "setpts=2*PTS" %o%
- NOTE: may cause strange desync problems
- '''Subtitles'''
- -i %i% -vf ass=filename=subtitles.ass %o%
- NOTE: This will not work unless in %usr% directory!!!
- '''Zoom'''
- -i %i% -vf zoompan=z='min(zoom+0.005,2.0)':x=600:y=10:d=125 -t 5.0s %o%
- ==Video advanced==
- Valid constants and expressions in expr:
- random(1) min(x, y) sin(x) floor(expr)
- lt(x, y) lte(x, y) hypot(x, y) gauss(x)
- squish(x) 1/(1 + exp(4*x))
- if(x, y, z) return y if x isn't 0, else return z
- if(x, y) return y if x isn't 0, else return 0
- while(x, expr) loop and take expr if x isn't 0, and return expr when end
- print(x)
- T time X pixel at x Y pixel at y W video width H video height
- PI 3.14159...
- '''Blend'''
- -filter_complex blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)' D:/%o%
- '''FFT filter'''
- -vf fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)' D:/details-high-pass.mp4
- '''Brightness, contrast, and the like'''
- -vf "curves=all='0/0 0.5/1 1/1'" D:/_brighten.mp4
- -vf eq=contrast=10:gamma_r=0.2:gamma_b=0.2 D:/_green.mp4
- -vf eq=brightness=0.06:saturation=2 D:/_brighten.mp4
- (other choices include colorize and hue)
- '''geq, rapidly morphing spectacle'''
- -vf geq=lum='...':cb='...':cr='...' %o%
- (cb=cr=127: black&white)
- -vf geq=a='...':r='...':g='...':b='...' %o%
- (either YUV or RGB)
- -f lavfi color,geq='st(3,pow(X-(W/2),2)+pow(Y-(H/2),2));if(lte(ld(3),80*80),255,0)':128:128
- -i %i% -vf geq=lum='125':cb='100*sin(X/50)-100*tan(X/50)' -t 1 %o%
- -lavfi nullsrc=s=256x256,geq=random(1)/hypot(X-cos(N*0.07)*W/2-W/2\,Y-sin(N*0.09)*H/2-H/2)^2*1000000*sin(N*0.02):128:128
- -i %i% -vf geq=lum='gauss(400)':cb='100+100*sin(PI/10*T*X)':cr='0' -t 5 %o%
- -i %i% -vf geq=lum='random(1)*20*T':cb='min(T*50,X)' -t 5 %o%
- -f lavfi -t 5 -i allyuv -vf crop=w=1280:h=720 %p%
- -i %i% -vf geq=lum=127:cb='127':cr='127' -t 2 -y %o%
- -i %i% -vf geq=lum='127+T/2*mod(1/2/T*sqrt(pow(X-640,2)+pow(Y-360,2)),255)' %o%
- -i %i% -vf geq=lum='128+T*32*sin(squish(T)*X)+(64-32*T)*random(1)' %o%
- '''Generate video'''
- -f lavfi -t 10 -i color=black:s=1280x720 %o%
- '''Motion Interpolation'''
- -vf minterpolate=fps=30:me=esa (exhaustive search)
- NOTE: Also with scene change detection method and 20 modes of interpolate. Very processing-intensive
- -vf tmix=frames=8:weights="1 1 1 1 1 1 1 1"
- -vf tmix=frames=3:weights="-1 3 -1" - with temporal convolution (weird color-inverse-flash)
- '''Play video side by side'''
- ffplay -v warning -f rawvideo -s 800x400 -i /dev/zero -vf 'movie=video1.mkv,scale=400x400 [mv2] ; movie=video2.mkv,scale=400x400 [mv1]; [in][mv1] overlay=0:0 [tmp]; [tmp][mv2] overlay=400:0'
- ffmpeg -v warning -i video1.mkv -i video2.mkv -filter_complex '[0:v]scale=400:400,pad=800:400 [0:q]; [1:v]scale=400:400[1:q]; [0:q][1:q]overlay=400:0' -f nut -c:v rawvideo -c:a copy - | mplayer -noconsolecontrols -cache-min 1 -cache 1024000 -
- ffplay -f lavfi "movie=org[a];movie=enc[b];[a][b]blend=all_mode=difference"
- ==Audio==
- '''aevalsrc'''
- ffmpeg -i d:/anb.wav -lavfi aevalsrc="sin(440*2*PI*t):s=44100:d=1s" d:/sine-440.wav
- NOTE: Remember to specify d, or it will generate forever!
- '''Compress or expand dynamic range: Noise-gate, 1:2 compression'''
- -lavfi compand=(louding time):(quieting time):(line x)/(line y)
- -lavfi "compand=attacks=0.3:decays=0.8:points=-36/-900|-35/-35|0/0|20/20" D:/0.wav
- -lavfi compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
- -lavfi compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1 D:/high_noise_gate.wav
- '''Bass'''
- -af bass=(freq):(gain):(width or steepness):(mix):(normalize)
- -af bass=frequency=100:gain=-50 %o%
- '''Bandreject'''
- -af bandreject=f=200:width_type=h:width=200 %o%
- '''Dynaudnorm'''
- dynaudnorm=f=500:g=5:p=0.5
- f - frame length
- g - gaussian size (number of frames taken into consideration each step)
- p - peak loudness
- m - maximum gain
- '''Equalizer'''
- -af equalizer=f=1000:t=q:w=1:g=2,equalizer=f=100:t=q:w=2:g=-5 %o%
- -af equalizer=f=1000:width_type=h:width=600:g=-30 %o%
- '''Flanger'''
- -af flanger=delay=29:depth=5:regen=60 %o%
- '''Fade'''
- -i %i% -af afade=t=in:d=2s %o%
- -i %i%.wav -af afade=t=out:st=40:d=2s %o%
- NOTE: st (start time) must be specified for fade out otherwise it will fade out at the beginning and most of the track will be silence
- '''Magic'''
- -af "asplit[a],aphasemeter=video=0,ametadata=select:key=lavfi.aphasemeter.phase:value=-0.005:function=less,pan=1c|c0=c0,aresample=async=1:first_pts=0,[a]amix"
- '''Mix'''
- -i %i1% -i %i2% -filter_complex amix=inputs=2:normalize=0 %o%
- '''Sample rate'''
- -i %i% -af aresample=44100 %o%
- '''Spectrogram'''
- -i D:/vowel.wav -lavfi showspectrumpic D:/vowel.png
- '''Split to mono'''
- -lavfi "[0:a]channelsplit=channel_layout=stereo:channels=FR[right]" -map "[right]" front-right.wav
- '''Silence remove'''
- -af silenceremove=start_periods=1:start_threshold=-35dB %o%
- -af silenceremove=start_periods=1:start_duration=5:start_threshold=0.02 %o%
- '''Sound generation'''
- -f lavfi -i "sine=duration=3:f=220"
- aevalsrc="sine(220*2*PI*t):sample_rate=44100":duration=1
- anoisesrc=sample_rate=44100:amplitude=0.5:duration=4:color=brown
- '''Normalization'''
- -af speechnorm=compression=5:raise=0.0001:l=1 %o%
- -af dynaudionorm=f=500:g=31:maxgain=10.0 %o%
- '''Chorus'''
- -af "chorus=0.5:0.9:50|60|40:0.4|0.32|0.3:0.25|0.4|0.3:2|2.3|1.3" %o%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement