Last active
January 22, 2022 20:40
-
-
Save jhamfler/cb21414d70696ba4a8957db80f186374 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ENCODE | |
# AUDIO | |
# upmix stereo to 5.1 | |
ffmpeg -i sound.opus -filter_complex "[0:a]pan=5.1(side)|FL=FL|FR=FR|LFE<FL+FR|FC<0.5*FR+0.5*FL|SL=FL|SR=FR[a]" -map 0 -map -0:a -map "[a]" -c copy -c:a flac output.flac | |
# convert any audio in current dir to mp3 in parallel | |
ls -1 --file-type | parallel --max-args 1 ffmpeg -i "{}" -vn -ar 44100 -ac 2 -b:a 192k "/path/{.}.mp3" | |
# VIDEO | |
# 4k h264/5, practical, small, ok | |
handbrakecli -d veryslow -e x264 -q 28 -i sourcevid -o outputvid.mp4 | |
handbrakecli -d veryslow -e x265 -q 28 -i sourcevid -o outputvid.mp4 | |
# 4k h264, fast, small, bad | |
handbrakecli -d ultrafast -e x264 -q 38 --width 1280 --height 720 -i inputvid -o outputvid.mp4 | |
# 4k archiv, unpractical, large, lossless | |
x265 --preset veryslow --lossless --input-res 3840x2178 --fps 30000/1001 --output x265vid.mp4 inputvid | |
# 4k to 1080p, h264, fast, bad quality | |
ffmpeg -i inputvid -c:v h264 -preset veryslow -crf 28 -vf scale=1920:-1 -max_muxing_queue_size 1024 -c:a copy -c:s copy output.mkv | |
#4k to 1080p, h264, slow, good quality, all audio and sub tracks | |
ffmpeg -threads $[$(nproc)-1] -thread_queue_size 512 -i inputvid $(echo '-map 0:'{0..99}'?') -c:v h264 -vf scale=1920:-1 -preset veryslow -tune film -crf 22 -max_muxing_queue_size 4096 -c:a copy -c:s copy output.mkv | |
# CUTTING | |
# cut away beginning and end | |
ffmpeg -ss 00:00:02 -i longer.mkv -codec copy -t 00:22:20 shorter.mkv | |
# cut from ss to end | |
ffmpeg -i longer.mkv -ss 00:00:02 -c copy -t 99:99:99 shorter.mkv | |
# replace video in mkv (BASH only) | |
# map from second video (stream 0, the video) (1:0) | |
# map all other streams from first video exept the first stream (¬0:0 but 0:1..99) if they exist ('?') | |
eval "$(echo ffmpeg -i videotoreplace.mkv -i newvideo.av1 -map 1:0 '-map '0:{1..99}'?' -c copy outputwithnewvideo.mkv)" | |
# concatenate ts video files including all streams - might not copy subs | |
ffmpeg -i "concat:00000.m2ts|00001.m2ts|00002.m2ts" -c copy -map 0 output.ts | |
# concatenate MKV | |
echo "file '/path/part1.mkv'" > list.txt | |
echo "file '/path/part2.mkv'" >> list.txt | |
# safe for absolute paths | |
# concat for concatenation | |
# list.txt has list of files | |
# c:a copy all audio files | |
# c:s copy all subs | |
# vcodec copy video | |
# map 0 as std option to copy everything | |
ffmpeg -safe 0 -f concat -i list.txt -c:a copy -c:s copy -vcodec copy -map 0 output.mkv | |
# gource h265 encode | |
gource -a 1 -i 0 -s 1 -c 1.5 -r 60 --title TITLE --key --date-format "%Y-%m-%d %H:%M" --highlight-users -1920x1080 -o - |\ | |
ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx265 -preset slow -pix_fmt yuv420p -crf 22 -bf 0 gource.mp4 | |
# HANDBRAKE | |
# 90° right math handbrake | |
--rotate=angle=0:hflip=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment