Created
February 9, 2022 01:45
-
-
Save lucasburlingham/e87a6066728e82a92ab1040168905899 to your computer and use it in GitHub Desktop.
Loop photo over MP3 file for specified time
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 | |
# get audio, image, and output files | |
audio_file=`yad --file . --title "Select MP3 file:"` | |
image_file=`yad --file . --title "Select image file:"` | |
output_file=`yad --file . --save --title "Output file name:"` | |
hours_loop=`yad --entry --numeric --title "Hours to Loop:"` | |
minutes_loop=`yad --entry --numeric --title "Minutes to Loop:"` | |
seconds_loop=`yad --entry --numeric --title "Seconds to Loop:"` | |
# Get total loop time (duration of video) | |
total_loop=`expr $hours_loop \* 3600 + $minutes_loop \* 60 + $seconds_loop` | |
# Clean up after ourselves | |
tmp=tmp-`date +%s` | |
mkdir -p $tmp | |
cd $tmp | |
# process and encode the video with the libx265 for size | |
ffmpeg -loop 1 -i $image_file -i $audio_file -c:v libx265 -c:a aac -strict experimental -b:a 192k -shortest tempoutput.mp4 | |
ffmpeg -i tempoutput.mp4 -c copy temp.mkv | |
ffmpeg -stream_loop -1 -t $total_loop -i temp.mkv -t $total_loop -c copy $output_file | |
cd .. | |
echo "Done... Deleting temporary files and directories..." | |
rm -r $tmp | |
echo "Finished." | |
echo $output_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment