Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- clear
- echo " 2 pass compression program for FFmpeg"
- echo " -------------------------------------"
- echo "Enter the size in MB of the finished video"
- read totSizeMB
- echo "How many kilobits would you like your sound. Enter 128 if not sure"
- read sound
- ffmpegResize=/tmp/sizetime
- ffprobe -i "$@" 2>$ffmpegResize
- title=$(grep Input $ffmpegResize |awk -F "'" '{print $2}')
- movieTimeSec=$(awk '/Duration/ {gsub(/,/, "", $2); split($2, a, /:/); print 3600*a[1] + 60*a[2] + a[3]}' $ffmpegResize)
- audioSize=$(awk "BEGIN { print $sound*$movieTimeSec/8192 }")
- videoSize=$(awk "BEGIN { print $totSizeMB-$audioSize }")
- videoBitRate=$(awk "BEGIN { print $videoSize*8192/$movieTimeSec }")
- videoBR="${videoBitRate}k"
- audioBR="${sound}k"
- clear
- echo
- echo "Do you want to compress your video as follows y/n"
- echo "---------------------------------------"
- echo "Title ::" $title
- echo "Sound Bit Rate ::" $sound "Kbps"
- echo "Avg Video Rate ::" $videoBitRate "Kbps"
- echo "Size When Done ::" $totSizeMB "MB"
- echo "Video Size ::" $videoSize "MB"
- echo "Audio Size ::" $audioSize "MB"
- echo "Film Duration ::" $movieTimeSec "sec"
- read
- #ffmpeg -i $title -pass 1 -vcodec libx264 -preset veryslow -b:v $videoBR -f matroska -sn -an -y /dev/null && ffmpeg -i $title -pass 2 -vcodec libx264 -preset veryslow -b:v $videoBR -acodec libfaac -b:a $audioBR -ac 2 -sn -y ${title%.*}.$totSizeMB.mkv
- # Read on Arch https://wiki.archlinux.org/index.php/FFmpeg
- ffmpeg -i $title -an -vcodec libx264 -pass 1 -preset veryslow -threads 0 -b $videoBR -x264opts frameref=15:fast_pskip=0 -f rawvideo -y /dev/null
- ffmpeg -i $title -acodec libfaac -b:a $audioBR -ac 2 -vcodec libx264 -pass 2 -preset veryslow -threads 0 -b $videoBR -x264opts frameref=15:fast_pskip=0 ${title%.*}.$totSizeMB.mkv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement