Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save junmakii/0bbc515024e0114bb1f3 to your computer and use it in GitHub Desktop.

Select an option

Save junmakii/0bbc515024e0114bb1f3 to your computer and use it in GitHub Desktop.
#!/bin/bash
#set -e
FFMPEG=$(which ffmpeg)
#CODEC=libvpx
CODEC=libx264
PRESET=ultrafast
#ACODEC=libvorbis # for webm
#PRESET=fast
#CRF=63 # For libvpx
#CRF=51 # For libx264
CRF=30
for i in $1/*; do
file_name=$(basename "$i")
output="$2/${file_name}.mp4"
echo "INFO: ${output}"
if [ -f "${i}" ] && [ ! -f "${output}" ]; then
${FFMPEG} -i "$i" -c:v ${CODEC} -crf ${CRF} -preset ${PRESET} -b:v 1M -codec:a aac -b:a 128k -strict -2 -vf scale=320:-1 "${output}"
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment