Skip to content

Instantly share code, notes, and snippets.

@hoangdh
Last active January 19, 2019 15:26
Show Gist options
  • Save hoangdh/e11f8226cbf720e0bde7d0a95f17695a to your computer and use it in GitHub Desktop.
Save hoangdh/e11f8226cbf720e0bde7d0a95f17695a to your computer and use it in GitHub Desktop.
Loop videos to 1 minute.
#!/bin/bash
mkdir -p output/
ls *.mp4 | while read -r l;
do
sec=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$l")
round_sec=${sec%.*}
if [[ $round_sec -lt 60 ]]; then
loop=$(expr 60 / $round_sec)
round_loop=$(expr ${loop%.*} + 2)
# echo $l $round_loop $round_sec
echo "ffmpeg -stream_loop ${round_loop} -i "${l}" -c copy output/${round_loop}_${l}" >> run.sh
fi
done
bash run.sh
rm -rf run.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment