Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- cd /home/web/site-jtx/vdj
- date >> liste_mp4.log
- # Read VDJ list file
- fichier=`head -n 1 liste_mp4.txt`
- echo "$fichier" >> liste_mp4.log
- # Remove first line for tomorrow
- tail -n +2 liste_mp4.txt > tmp_mp4.txt
- mv tmp_mp4.txt liste_mp4.txt
- chmod 777 liste_mp4.txt
- # Test bitrate
- ffmpeg -i "$fichier" > bitrate.out 2>&1
- bitrate=`gawk 'match($0, /bitrate: (.[^,]*)b\/s/, matches) {print matches[1]}' bitrate.out`
- echo $bitrate > bitrate.out
- bitrate_value=`gawk 'match($0, /^([0-9]+)/, matches) {print matches[1]}' bitrate.out`
- bitrate_unit=`gawk 'match($0, /(k|M|G)$/, matches) {print matches[1]}' bitrate.out`
- reencode="0"
- if [ "$bitrate_unit" = "M" ]; then
- if [ "$bitrate_value" -ge 1 ]; then
- reencode="1"
- fi
- else
- if [ "$bitrate_value" -ge 1700 ]; then
- reencode="1"
- fi
- fi
- rm bitrate.out
- # Reencode if necessary
- if [ "$reencode" = "1" ]; then
- echo "Encodage du fichier" >> liste_mp4.log
- 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
- else
- echo "Copie du fichier source" >> liste_mp4.log
- cp -f "$fichier" vdj.mp4
- fi
- # Generate thumbnail
- ffmpeg -y -ss 10 -t 5 -i vdj.mp4 -vframes 1 vdj_mp4.png > /dev/null 2>&1
- # Echo to log
- echo "Script terminรฉ avec succรจs" >> liste_mp4.log
- echo "" >> liste_mp4.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement