Last active
December 11, 2015 18:59
-
-
Save sfelde/4645872 to your computer and use it in GitHub Desktop.
convert input video file to html5 video formats mod. from url: http://sandalov.org/blog/1184/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $1 ]] | |
then | |
filename=$(basename "$1") | |
filename=${filename%.*} | |
#$(dirname "$1") | |
directory=result | |
duration=$(ffmpeg -i "$1" 2>&1 | grep Duration | awk '{print $2}' | tr -d ,) | |
minutes=${duration%:*} | |
hours=${minutes%:*} | |
minutes=${minutes##*:} | |
seconds=${duration##*:} | |
seconds=${seconds%.*} | |
hours=$((hours*3600)) | |
minutes=$((minutes*60)) | |
total=$(expr $hours + $minutes + $seconds) | |
number=$RANDOM | |
let "number %= $total" | |
echo "make $directory folder" | |
mkdir -p "$directory" | |
echo "Generating thumbnail" | |
ffmpeg -i "$1" -filter:v yadif -an -ss $number -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg "$directory/$filename.jpg" 2>&1 | |
echo "Converting $filename to ogv" | |
ffmpeg -i "$1" -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b:v 1024k "$directory/$filename.ogv" | |
echo "Finished ogv" | |
echo "Converting $filename to webm" | |
ffmpeg -i "$1" -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b:v 1024k "$directory/$filename.webm" | |
echo "Finished webm" | |
echo "Converting $filename to h264" | |
#-b 345k | |
#ffmpeg -i "$1" -acodec libfaac -ab 96k -vcodec libx264 -level 21 -refs 2 -b:v 1024k -bt 1024k -threads 0 "$directory/$filename.v1.mp4" | |
ffmpeg -i "$1" -acodec aac -ab 160000 -vcodec libx264 -vpre ipod640 -b:v 1024k -threads 0 -pix_fmt yuv420p -f mp4 -strict -2 "$directory/$filename.mp4" | |
echo "Finished h264" | |
echo "All Done!" | |
else | |
echo "Usage: [filename]" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment