Created
March 20, 2019 20:50
-
-
Save PhoenixIllusion/24dd082fcda26012b7c7bd4658881e55 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
| function dist(){ | |
| RET=`echo "$1 $2 $3 $4" | \ | |
| awk ' | |
| function ceil(valor) | |
| { | |
| return (valor == int(valor)) ? valor : int(valor)+1 | |
| } | |
| function a(dx,dy) { | |
| return sqrt(dx*dx+dy*dy); | |
| } | |
| { | |
| print ceil(a($2-$4,$1-$3)); | |
| }'` | |
| } | |
| function rot() { | |
| DX=`expr $3 - $1` | |
| DY=`expr $4 - $2` | |
| DIST=$5 | |
| RET=`echo "$DX $DY $DIST" | \ | |
| awk ' | |
| function asin(x) { | |
| return atan2(x, sqrt(1-x*x)) | |
| } | |
| { | |
| print asin($2/$3); | |
| }'` | |
| } | |
| TL[0]=154 | |
| TL[1]=501 | |
| BL[0]=142 | |
| BL[1]=651 | |
| TR[0]=355 | |
| TR[1]=515 | |
| dist ${TL[@]} ${TR[@]} | |
| WIDTH=$RET | |
| dist ${TL[@]} ${BL[@]} | |
| HEIGHT=$RET | |
| rot ${TL[@]} ${TR[@]} $WIDTH | |
| ROT=$RET | |
| echo "$WIDTH x $HEIGHT, ${TL[0]}:${TL[1]}, @$ROT" | |
| OVERLAY_DX=0 | |
| OVERLAY_DY=0 | |
| if (( $(echo "$ROT > 0" | bc -l) )); then | |
| OVERLAY_DX="${HEIGHT}*sin($ROT)" | |
| fi | |
| if (( $(echo "$ROT < 0" | bc -l) )); then | |
| OVERLAY_DY="${WIDTH}*sin(-$ROT)" | |
| fi | |
| FILTER=" | |
| [0:v] scale=${WIDTH}x${HEIGHT}[src]; | |
| [src] rotate=$ROT:ow=rotw($ROT):oh=roth($ROT):fillcolor=magenta [vid]; | |
| [1:v][vid] overlay=x=${TL[0]}-${OVERLAY_DX}:y=${TL[1]}-${OVERLAY_DY} [scaledVid]; | |
| [scaledVid][1:v] overlay='" | |
| echo "====" | |
| echo $FILTER | |
| echo "====" | |
| ffmpeg -i animated.gif -i transparent_frame.png \ | |
| -filter_complex "${FILTER}" \ | |
| -pix_fmt yuv420p \ | |
| output.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment