13 Sep 2023
Reduce Video Size with Script
Hier mein Shell-Skript zum erzeugen verschiedener Video-Formate für das Internet.
Achtung - Aspect-Ratio fuür mein iPhone - YMMV
- html5-video-conv.sh
#!/bin/bash
usage(){
cat <<EOF 1>&2
usage: html5-video-conv.sh my-film.mov
convert film to mp4, ogv, webm
for use to embed there
generates html snippet
EOF
exit 1
}
INPUT_FILENAME="$1"
[ -z "$INPUT_FILENAME" ] && usage
# scale values optimized for iphone5s / 16:9 videos
#INPUT_FILENAME=my-film.mov
# remove filename extension
OUTPUT_FILENAME=${INPUT_FILENAME%.*}
#mp4
/usr/bin/ffmpeg -i $INPUT_FILENAME -vcodec libx264 -acodec aac -minrate 1M -maxrate 1M -b:v 1M -vf scale=854:480 ${OUTPUT_FILENAME}-480.mp4
#ogv
/usr/bin/ffmpeg -i $INPUT_FILENAME -acodec libvorbis -ac 2 -ab 256k -ar 44100 -vcodec libtheora -b:v 1M -vf scale=-1:480 ${OUTPUT_FILENAME}-480.ogv
#webm
/usr/bin/ffmpeg -i $INPUT_FILENAME -c:v libvpx-vp9 -minrate 1M -maxrate 1M -b:v 1M -vf scale=-1:480 ${OUTPUT_FILENAME}-480.webm
echo " "
echo " "
echo "please copy now videos to desired locations ...."
echo " "
echo "cp *480* /my/location/where/are/films/
echo " "
echo " "
echo " html source code"
echo " "
echo "<html>"
echo "<video controls>"
echo " <source src="/films/${OUTPUT_FILENAME}-480.mp4" type="video/mp4">"
echo " <source src="/films/${OUTPUT_FILENAME}-480.ogv" type="video/ogg">"
echo " <source src="/films/${OUTPUT_FILENAME}-480.webm" type="video/webm">"
echo "Your browser does not support the video tag."
echo "</video>"
echo "</html>"
echo " "