Created
November 23, 2021 21:06
-
-
Save jovandeginste/93d353f9b4718458e27d5b5ca0e5d9f9 to your computer and use it in GitHub Desktop.
Convert a rotated video recording (recorded in portrait mode, but plays in landscape mode) to landscape video with the same video blurred as backdrop
This file contains 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
#!/bin/bash -eu | |
INPUT="input.mp4" | |
OUTPUT="output.mp4" | |
W=1920 | |
H=1080 | |
OVERLAY_W=1080 # Increase this to remove the bottom part of the portrait recording | |
OVERLAY_X=$( | |
echo "(${W} - (${H} * ${OVERLAY_W} / ${W})) / 2" | bc | |
) | |
ffmpeg -i "${INPUT}" \ | |
-filter_complex " | |
[0:v]rotate='-PI/2:${H}:${W}'[rot]; | |
[rot]split[rotbg][rotfg]; | |
[rotbg]scale=${W}*2:-1, crop=${W}:${H}, boxblur=luma_radius=20:chroma_radius=20:luma_power=10[blurredbg]; | |
[rotfg]scale=-1:${OVERLAY_W}[zoomedfg]; | |
[blurredbg][zoomedfg]overlay=${OVERLAY_X}:0[combine]; | |
[combine]fade=in:0:75[out]; | |
[0:a]afade=in:st=0:d=5[audio] | |
" \ | |
-map "[out]" -map "[audio]" "${OUTPUT}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment