Advertisement
Guest User

VDJ MP4

a guest
May 1st, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.40 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. cd /home/web/site-jtx/vdj
  4. date >> liste_mp4.log
  5.  
  6. # Read VDJ list file
  7. fichier=`head -n 1 liste_mp4.txt`
  8. echo "$fichier" >> liste_mp4.log
  9.  
  10. # Remove first line for tomorrow
  11. tail -n +2 liste_mp4.txt > tmp_mp4.txt
  12. mv tmp_mp4.txt liste_mp4.txt
  13. chmod 777 liste_mp4.txt
  14.  
  15. # Test bitrate
  16. ffmpeg -i "$fichier" > bitrate.out 2>&1
  17. bitrate=`gawk 'match($0, /bitrate: (.[^,]*)b\/s/, matches) {print matches[1]}' bitrate.out`
  18. echo $bitrate > bitrate.out
  19. bitrate_value=`gawk 'match($0, /^([0-9]+)/, matches) {print matches[1]}' bitrate.out`
  20. bitrate_unit=`gawk 'match($0, /(k|M|G)$/, matches) {print matches[1]}' bitrate.out`
  21. reencode="0"
  22. if [ "$bitrate_unit" = "M" ]; then
  23.     if [ "$bitrate_value" -ge 1 ]; then
  24.         reencode="1"
  25.     fi
  26. else
  27.     if [ "$bitrate_value" -ge 1700 ]; then
  28.         reencode="1"
  29.     fi
  30. fi
  31. rm bitrate.out
  32.  
  33. # Reencode if necessary
  34. if [ "$reencode" = "1" ]; then
  35.     echo "Encodage du fichier" >> liste_mp4.log
  36.     ffmpeg -i "$fichier" -threads 0 -c:v libx264 -b:v 1.5M -r 25 -s 1280x720 -x264opts level=3 -pix_fmt yuv420p -c:a aac -strict experimental -b:a 192k -y vdj.mp4 > /dev/null 2>&1
  37. else
  38.     echo "Copie du fichier source" >> liste_mp4.log
  39.     cp -f "$fichier" vdj.mp4
  40. fi
  41.  
  42. # Generate thumbnail
  43. ffmpeg -y -ss 10 -t 5 -i vdj.mp4 -vframes 1 vdj_mp4.png > /dev/null 2>&1
  44.  
  45. # Echo to log
  46. echo "Script terminรฉ avec succรจs" >> liste_mp4.log
  47. echo "" >> liste_mp4.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement