Skip to content

Instantly share code, notes, and snippets.

@glebmachine
Created February 15, 2021 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glebmachine/0d7bb521d8e8268be5fd6ac8fe972b9c to your computer and use it in GitHub Desktop.
Save glebmachine/0d7bb521d8e8268be5fd6ac8fe972b9c to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$#" -eq 0 ]; then
echo "Нужно указать имя файла +_+"
exit
fi
echo -n "Битрэйт (2000k): "
read bitrate
if [ "$bitrate" == "" ]; then
bitrate='2000'
fi
echo -n "размер (1280x720): "
read size
if [ "$size" == "" ]; then
size='1280x720'
fi
echo -n "нужно аудио (y/n, default y): "
read audiocodec
if [ "$audiocodec" == "n" ]; then
audiocodec_mp4='-an'
audiocodec_mov='-an'
audiocodec_webm='-an'
audiocodec_ogv='-an'
else
audiocodec_mp4='-acodec aac -strict -2'
audiocodec_webm=' -c:a libvorbis'
fi
common='-threads 4 -qmin 0 -qmax 30 -q:v 4 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -trellis 0';
options="-y -s $size -b:v ${bitrate}K"
echo "${options}"
for file in "$@"
do
DIR="${file}_${bitrate}k_${size}"
mkdir -p "$DIR" 2> /dev/null
rm "$DIR/*"
ffmpeg -i "${file}" -vcodec h264 ${options} -vf format=yuv420p ${audiocodec_mp4} -movflags frag_keyframe+empty_moov "${DIR}/${file}.mp4"
ffmpeg -i "${file}" -c:v libvpx ${options} ${audiocodec_webm} "${DIR}/${file}.webm"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment