Advertisement
Guest User

Untitled

a guest
May 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.24 KB | None | 0 0
  1. #!/bin/bash
  2. trans() {
  3. 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
  4. }
  5.  
  6.  
  7.  
  8. echo conversion of "$1" started on `date "+%m/%d/%y %l:%M:%S %p"` > ~/trans.log
  9. # Get duration and fps
  10. duration=( $(ffmpeg -i "$1" 2>&1 | sed -n "s/.* Duration: \([^,]*\), start: .*/\1/p") )
  11. fps=( $(ffmpeg -i "$1" 2>&1 | sed -n "s/.*, \(.*\) tbr.*/\1/p") )
  12.  
  13. hours=( $(echo $duration | cut -d":" -f1) )
  14. minutes=( $(echo $duration | cut -d":" -f2) )
  15. seconds=( $(echo $duration | cut -d":" -f3) )
  16. # Get the integer part with cut
  17. frames=( $(echo "($hours*3600+$minutes*60+$seconds)*$fps" | bc | cut -d"." -f1) )
  18. echo ""$1" has $frames frames, now converting" >> ~/trans.log
  19. echo ""$1" has $frames frames, now converting" > ~/ffmpeg.log
  20. echo ""$1" has $frames frames, now converting"
  21. trans $1 &>> ~/ffmpeg.log &
  22. pid=$!
  23. echo "ffmpeg PID = $pid" >> ~/trans.log
  24. echo "ffmpeg PID = $pid"
  25. runtime=0
  26. while [ -e /proc/$pid ]; do
  27.     runtime=( $(tac ~/ffmpeg.log | grep -m 1 "frame=" | awk '{ print $2 }') )
  28.     echo "current frame is $runtime"
  29.     sleep 5
  30. done
  31.  
  32. echo ffmpeg stopped on `date "+%m/%d/%y %l:%M:%S %p"` >> ~/trans.log
  33.  
  34. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement