Files
q-tools/av/ffmpeg-magic
2022-02-14 15:50:42 +02:00

53 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
if [[ "$1" = "-h" ]]; then
echo This script prints out various ffmpeg commands
exit
fi
cat <<'EOF' | md-color
# Basic Good Quality
a) -hide_banner -q:v 0 -q:a 0
b) -s hd720 -g 250 -c:v libx264 -crf 23 -c:a aac -movflags faststart -strict -2
YIFY) -c:v libx264 -crf 27 -x264-params cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:b-adapt=2:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all -c:a aac -ar 44100 -b:a 128k -map 0
# Smooth slow motion
-filter:v "minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=120'",setpts=1.5*PTS
# BCS + unsharp (works also on -filter_complex)
-vf unsharp,"eq=contrast=1.4:brightness=0.1:saturation=1.5:gamma=1.0"
# More filters to try
histeq=strength=0.1,normalize=blackpt=red:whitept=yellow:smoothing=150,hqdn3d=4:4:3:3"
# Trim
-vcodec copy -acodec copy -ss 00:01:30 -to 00:02:30
-vcodec copy -acodec copy -ss 50 -to 65
# Vertical2Horizontal
-filter_complex "[0:v]scale=ih*16/9:-1,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,crop=h=iw*9/16"
# Rotate 0=90CCW+flip,1=90CW,2=90CCW,3=90CW+flip. example 180 deg.
-vf "transpose=2,transpose=2"
# Antishake-Stabilize
in=videofile.mp4
ffmpeg -i "$in" -vf vidstabdetect=stepsize=32:shakiness=10:accuracy=10:result="$in".transforms.trf -f null -
ffmpeg -i "$in" -vf vidstabtransform=input="$in".transforms.trf:zoom=0:smoothing=10,unsharp=5:5:0.8:3:3:0.4 -q:v 0 "$in".stabilized.mp4
# To Stills
-vf fps=10 "$1".%06d.png
# From Stills
-r 1/5 -start_number 0 -i img%03d.png -r 30 -pix_fmt yuv420p
# Segment
-segment_time 00:15:00 -f segment -reset_timestamps 1 "$in.%03d.480p.mp4"
# Stacking
-i input0 -i input1 -filter_complex vstack=inputs=2 (OR/) hstack=inputs=2
# Chroma key
-f lavfi -i color=c=green:s=1920x1080 -i input.mp4 -filter_complex "[1:v]chromakey=0x297141:0.1:0.0[ckout];[0:v][ckout]overlay[o]" -map [o] -map 1:a
# View live
-pix_fmt yuv420p -f matroska - | ffplay -i -
# Concatenate
find . -type f -printf "file '%P'\n" | sort -V > filelist.txt
ffmpeg -f concat -safe 0 -i filelist.txt -c copy concatenated.mp4
# Audio encode
ffmpeg -i file.wav -codec:a libmp3lame -qscale:a 2 file.mp3
# Audio map
ffmpeg -i input.mp4 -i input.mp3 -c copy -map 0:0 -map 1:1 -shortest out.mp4
# Fade in/out
-vf "fade=t=in:st=0:d=1,fade=t=out:st=10:d=1" -af "afade=t=in:st=0:d=1,afade=t=out:st=10:d=1"
EOF