Advertisement
Nyan-Cat

Some Bash scripts for turning a portrait video into landscape with blurred background

Feb 13th, 2021 (edited)
1,008
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.95 KB | None | 0 0
  1. toLandscape () { echo "Processing $1"; convert -respect-parentheses \
  2. \( $1 +write mpr:original \) \
  3. \( mpr:original -resize 690x1080! -blur 0x25 +write mpr:blurred \) \
  4. \( -size 1920x1080 xc:SkyBlue \
  5.    mpr:blurred -geometry 1920x1080 -gravity northwest -composite \
  6.    mpr:blurred -geometry 1920x1080 -gravity southeast -composite \
  7.    mpr:original -geometry 1920x1080 -gravity center -composite \
  8.    -size 1920x1080 -quality 100 +write $1 \) NULL:; }; export -f toLandscape
  9.  
  10. shave () { convert $1 -shave 8x0 $1; }; export -f shave
  11.  
  12. toFrames () { mkdir -p frames; ffmpeg -i $1 -vsync 0 -f image2 frames/frame-%05d.png; }; export -f toFrames
  13.  
  14. forEach () { seq -f "frame-%05g.png" 1 $1 | xargs -P 6 -I {} bash -c 'toLandscape "$@"' _ {}; }; export -f forEach
  15.  
  16. toVideo () { ffmpeg -thread_queue_size 65536 -r 30 -f image2 -s 1920x1080 -i frames/frame-%05d.png -i $1 -map 0:v:0 -map 1:a:0 -vcodec libx264 -crf 17 -pix_fmt yuv420p -shortest LANDSCAPE_$1; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement