Skip to content

Instantly share code, notes, and snippets.

@denisnazarov
Last active October 31, 2016 13:40
Show Gist options
  • Save denisnazarov/9338340 to your computer and use it in GitHub Desktop.
Save denisnazarov/9338340 to your computer and use it in GitHub Desktop.
FFMPEG batch convert to h264 mp4 and webm
#! /bin/bash
# Based on Batch Convert Script originally by Beterhans
# Put all video files need to be converted in a folder!
# the name of files must not have " " Space!
# Rename the File if contain space
# Target dir
indir=$1
cd "$indir"
if mkdir -p output
then
echo "\nUsing $indir/output as Output Folder"
else
echo "\n\nErr: Check you have the rights to write in $indir ?"
exit
fi
for file in *.mov;
do
ffmpeg -y -i $file -c:v libx264 -pix_fmt yuv420p -vprofile high -preset slow -b:v 3000k -maxrate 3000k -bufsize 6000k -threads 0 -pass 1 -an -f mp4 /dev/null && \
ffmpeg -i $file -c:v libx264 -pix_fmt yuv420p -vprofile high -preset slow -b:v 3000k -maxrate 3000k -bufsize 6000k -threads 0 -movflags faststart -pass 2 ./output/${file%.*}.mp4
ffmpeg -i $file -c:v libvpx -b:v 1555k -c:a libvorbis ./output/${file%.*}.webm
done
echo ALL Processed!
###################
echo "DONE"
exit
@denisnazarov
Copy link
Author

You can specify resolution with -s hd720.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment