Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- trans() {
- ffmpeg -deinterlace -y -i "$1" -vcodec libx264 -level 41 -vpre normal -crf 24 -threads 0 -sn -acodec libfaac -ab 128k -ac 2 -ar 48000 -vsync 1 -async 1000 -map 0.0:0.0 -map 0.1:0.1 "$1".mkv
- }
- echo conversion of "$1" started on `date "+%m/%d/%y %l:%M:%S %p"` > ~/trans.log
- # Get duration and fps
- duration=( $(ffmpeg -i "$1" 2>&1 | sed -n "s/.* Duration: \([^,]*\), start: .*/\1/p") )
- fps=( $(ffmpeg -i "$1" 2>&1 | sed -n "s/.*, \(.*\) tbr.*/\1/p") )
- hours=( $(echo $duration | cut -d":" -f1) )
- minutes=( $(echo $duration | cut -d":" -f2) )
- seconds=( $(echo $duration | cut -d":" -f3) )
- # Get the integer part with cut
- frames=( $(echo "($hours*3600+$minutes*60+$seconds)*$fps" | bc | cut -d"." -f1) )
- echo ""$1" has $frames frames, now converting" >> ~/trans.log
- echo ""$1" has $frames frames, now converting" > ~/ffmpeg.log
- echo ""$1" has $frames frames, now converting"
- trans $1 &>> ~/ffmpeg.log &
- pid=$!
- echo "ffmpeg PID = $pid" >> ~/trans.log
- echo "ffmpeg PID = $pid"
- runtime=0
- while [ -e /proc/$pid ]; do
- runtime=( $(tac ~/ffmpeg.log | grep -m 1 "frame=" | awk '{ print $2 }') )
- echo "current frame is $runtime"
- sleep 5
- done
- echo ffmpeg stopped on `date "+%m/%d/%y %l:%M:%S %p"` >> ~/trans.log
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement