Skip to content

Instantly share code, notes, and snippets.

@mageddo

mageddo/script.sh

Last active Jan 1, 2020
Embed
What would you like to do?
Convert multiple videos inside dir
set -e
export AV_LOG_FORCE_NOCOLOR=1 &&\
FILES_TO_CONVERT="$(ls *.mp3)" &&\
TOTAL=$(echo "$FILES_TO_CONVERT" | wc -l) &&\
I=0 &&\
OUT_DIR=converted && mkdir -p ${OUT_DIR} &&\
(IFS='
'
for IN in $FILES_TO_CONVERT; do
I=$((I + 1)) &&\
OUT="${OUT_DIR}/${IN%.*}-30-fps.mp4" &&\
SIZE=$(ls -lha "$IN" | awk '{ print $5}') &&\
DURATION=$(ffmpeg -i "$IN" 2>&1 | grep -oP 'Duration: \K(\d+:\d+:\d+)') &&\
echo -e "\n\e[96m> converting ${IN} size=$SIZE, duration=$DURATION\e[96m (\e[92m${I}\e[96m of \e[92m${TOTAL}\e[96m)\e[39m" &&\
ffmpeg -v warning -hide_banner -stats -loop 1 -i IMG-20191220-WA0005.jpg -i "$IN" -c:v libx264 \
-tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p \
-shortest "$OUT"
# ffmpeg -v warning -hide_banner -stats -i "${IN}" -crf 28 -vcodec libx264 -acodec aac -strict -2 "${OUT}"
done)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment