Forked from anguyen8/make_crossfade_ffmpeg_video_from_images.sh
Created
October 24, 2016 04:31
-
-
Save eugeneware/111f46297f94368e51344ea3f6295627 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
| #!/bin/bash | |
| # Anh Nguyen <anh.ng8@gmail.com> | |
| # 2016-04-30 | |
| # MIT License | |
| # This script takes in images from a folder and make a crossfade video from the images. | |
| # Crossfade between each pair of images is 0.5 seconds | |
| #---------------------------------------------------------------- | |
| # SETTINGS | |
| input_dir="accuracy_in_frames" | |
| n_files=10 | |
| files=`ls ${input_dir}/*.jpg | head -${n_files}` | |
| #---------------------------------------------------------------- | |
| # Making an ffmpeg script... | |
| input="" | |
| filters="" | |
| output="[0:v]" | |
| i=0 | |
| for f in ${files}; do | |
| input+=" -loop 1 -t 1 -i $f" | |
| next=$((i+1)) | |
| if [ "${i}" -ne "$((n_files-1))" ]; then | |
| filters+=" [${next}:v][${i}:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b${next}v];" | |
| fi | |
| if [ "${i}" -gt "0" ]; then | |
| output+="[b${i}v][${i}:v]" | |
| fi | |
| i=$((i+1)) | |
| done | |
| output+="concat=n=$((i * 2 - 1)):v=1:a=0,format=yuv420p[v]\" -map \"[v]\" out.mp4" | |
| script="ffmpeg ${input} -filter_complex \"${filters} ${output}" | |
| echo ${script} | |
| # Run it | |
| eval "${script}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment