TEST8Avec soit bitrate d'origine (par défaut) ou alors, on rentre le bitrate désiré, si le non "n" est choisi.
Je recommande
2500
#!/bin/bash
## Anonyme
## Testeur smolski
## 23/04/2020
PATH=$PATH:/sbin:/usr/sbin
## CONDITION : UN SEUL DVD-VIDÉO.
mounting_directory=$( mount | grep '/dev/sr' | grep -Po 'on\K.*(?=type)' | sed 's|\(.*\)/.*|\1|' | uniq )
COUNT_VIDEO_TS=$(find ${mounting_directory} -maxdepth 3 -name 'VIDEO_TS.IFO' 2> /dev/null | wc -l)
DEVICE=$(blkid /dev/sr* | awk '{print $1}' | sed -e 's/://g')
COUNT_DEVICE=$(blkid /dev/sr* | awk '{print $1}' | sed -e 's/://g' | wc -l)
if [[ "$COUNT_VIDEO_TS" -eq 0 ]]; then
echo "Aucun dvd vidéo monté : Abandon"
exit 0
elif [[ "$COUNT_VIDEO_TS" -gt 1 ]]; then
echo "Il y a plus d'un dvd video détecté : Abandon"
exit 0
fi
if [[ "$COUNT_VIDEO_TS" -eq 1 ]] && [[ "$COUNT_DEVICE" -eq 1 ]]; then
echo "Les conditions sont réunies : On continue"
TITLE=$(lsdvd "$DEVICE" | head -1 | awk '{print $3}')
TITLE_COUNT=$(lsdvd "$DEVICE" | grep -c ^'Title: ')
fi
echo "Proceed..."
echo "DVD-Vidéo : $TITLE"
read -r -p "Ce nom convient-il ? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
echo "Yes"
mkdir -p "$TITLE/IFOS"
mkdir -p "$TITLE/VOBSUBS"
;;
[nN][oO]|[nN])
echo "No"
read -r -p "Entrer un nouveau nom: " TITLE
mkdir -p "$TITLE/IFOS"
mkdir -p "$TITLE/VOBSUBS"
;;
*)
echo "Invalid input..."
echo "Quit"
exit 1
;;
esac
BITRATE=$(mplayer -noconfig all -nocache -vo null -ao null -frames 0 -identify -dvd-device "$DEVICE" dvdnav://"$i" 2>/dev/null | \
grep "VIDEO:" | awk '{print$8}' | sed 's/\.[^ ]*/ /g')
echo "Original Bitrate : $BITRATE"
read -r -p "Ce Bitrate convient-il ? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
echo "Yes"
echo -e "$BITRATE" > "$TITLE/bitrate.txt"
;;
[nN][oO]|[nN])
echo "No"
read -r -p "Entrer un nouveau Bitrate: " newbitrate
echo -e "$newbitrate" > "$TITLE/bitrate.txt"
;;
*)
echo "Invalid input..."
echo "Quit"
exit 1
;;
esac
bv=$(sed q "$TITLE/bitrate.txt")
bitrate_k=$((bv/1))k
bufsize_k=$((bv/2))k
for (( i=1; i<=TITLE_COUNT; i++ ))
do
LENGTH=$(mplayer -noconfig all -nocache -vo null -ao null -frames 0 -identify -dvd-device "$DEVICE" dvdnav://"$i" 2>/dev/null | \
sed -E -n 's/^.*ID_LENGTH=([0-9]+).*$/\1/p')
LIMIT=0
[[ "$LENGTH" -le "$LIMIT" ]] && continue
mplayer -noconfig all -nocache -dvd-device "$DEVICE" dvdnav://"$i" \
-dumpstream -dumpfile "$TITLE/$i-$TITLE.vob"
INTERLEAVED_FRAMES=$(ffmpeg -filter:v idet -frames:v 200 -an -f rawvideo \
-y /dev/null -i "$TITLE/$i-$TITLE.vob" 2>&1 | \
awk '/(Single|Multi) frame detection/ {sum += $8+$10}
END { print sum }')
if [[ "$INTERLEAVED_FRAMES" -gt "100" ]]; then
FILTERS='-filter:v yadif=0:-1:0,hue=b=0.0:s=0.7,hqdn3d=1.5:1.5:4:4,unsharp=luma_msize_x=5:luma_msize_y=5:luma_amount=0.5,noise=c0s=2:c1s=2:c2s=2:c0f=a+t'
else
FILTERS='-filter:v hue=b=0.0:s=0.7,hqdn3d=1.5:1.5:4:4,unsharp=luma_msize_x=5:luma_msize_y=5:luma_amount=0.5,noise=c0s=2:c1s=2:c2s=2:c0f=a+t'
fi
COUNT_AUDIO=$(ffprobe "$TITLE/$i-$TITLE.vob" 2>&1 | grep -c "Audio:")
FPS=$(mplayer -noconfig all -nocache -vo null -ao null -frames 0 -identify "$TITLE/$i-$TITLE.vob" 2>/dev/null | grep "VIDEO:" | awk '{print$6}')
RATIO=$(lsdvd -x "$DEVICE" -t "$i" | grep -m1 "Aspect ratio:" | awk '{print$11}' | sed -e 's/\//\:/g' | tr -d ',')
O_CHANNELS=$(ffprobe "$TITLE/$i-$TITLE.vob" 2>&1 | grep -c '(Audio: ac3, 0 channels)')
REMOVE_O_CHANNELS=$(ffprobe "$TITLE/$i-$TITLE.vob" 2>&1 | awk '/Stream/ && /Audio:/ && /kb\/s|\(LC\),/ { print $2 }' | \
cut -d "[" -f2 | cut -d "]" -f1 | awk '{ printf " -map i:"$0" " }')
ALLSHOW_TAG=$(mplayer -vo null -ao null -frames 0 -identify dvdnav://"$i" -dvd-device "$DEVICE" 2>/dev/null | \
awk '/audio stream:/ {printf " -metadata:s:a:"$3" language="$8" -metadata:s:a:"$3" title="$5$6""}')
MAP_ID_STREAMS=$(lsdvd -a "$DEVICE" -t "$i" 2> /dev/null | grep "Language:" | sed -e 's/c/1c/g' | awk '{ printf " -map i:"$21"" }')
MAP_ID_STREAMS_LPCM=$(lsdvd -a "$DEVICE" -t "$i" 2> /dev/null | grep "lpcm" | awk '{ printf " -map i:"$22"" }')
COUNT_LPCM=$(lsdvd -a "$DEVICE" -t "$i" |grep -c 'lpcm')
AIDS_LPCM=$(lsdvd -a "$DEVICE" -t "$i" | awk '/lpcm/ { print $22 }')
## VOB PRÉSENT.
## AUCUN AUDIO.
if [[ -e "$TITLE/$i-$TITLE.vob" ]] && [[ "$COUNT_AUDIO" -eq "0" ]]; then
ffmpeg -hide_banner -analyzeduration 1000M -probesize 1000M -vsync 2 -r "$FPS" -i "$TITLE/$i-$TITLE.vob" \
-map 0:v -metadata title="$TITLE" \
-c:v libx264 -b:v "$bitrate_k" -maxrate "$bitrate_k" -bufsize "$bufsize_k" \
-loglevel repeat+verbose -movflags faststart \
-x264opts 'keyint=300:min-keyint=25:8x8dct:sliced-threads=0' \
-an -movflags +faststart -max_muxing_queue_size 9999 \
-deblock 1:1 -flags +loop -qcomp 0.60 -qblur 0.5 -coder 1 -me_range 6 -sc_threshold 42 -bf 10 -trellis 2 -mbtree 1 -qmin 0 -qmax 52 \
$FILTERS \
-preset veryfast -y "$TITLE/$i-$TITLE.mkv"
rm -f "$TITLE/$i-$TITLE.vob"
rm -f "$TITLE/bitrate.txt"
fi
## VOB PRÉSENT.
## AVEC OU SANS AUDIO(S).
## SANS 0 CHANNEL.
## SANS LPCM.
if [[ -e "$TITLE/$i-$TITLE.vob" ]] && [[ "$COUNT_AUDIO" -ge "0" ]] && [[ "$O_CHANNELS" -eq "0" ]] && [[ "$COUNT_LPCM" -eq "0" ]]; then
ffmpeg -hide_banner -analyzeduration 1000M -probesize 1000M -vsync 2 -r "$FPS" -i "$TITLE/$i-$TITLE.vob" \
-map 0:v -metadata title="$TITLE" \
-c:v libx264 -b:v "$bitrate_k" -maxrate "$bitrate_k" -bufsize "$bufsize_k" \
-loglevel repeat+verbose -movflags faststart \
-x264opts 'keyint=300:min-keyint=25:8x8dct:sliced-threads=0' \
${MAP_ID_STREAMS} -c:a copy ${ALLSHOW_TAG} -movflags +faststart -max_muxing_queue_size 9999 \
-deblock 1:1 -flags +loop -qcomp 0.60 -qblur 0.5 -coder 1 -me_range 6 -sc_threshold 42 -bf 10 -trellis 2 -mbtree 1 -qmin 0 -qmax 52 \
$FILTERS \
-preset veryfast -y "$TITLE/$i-$TITLE.mkv"
# ffmpeg -hwaccel auto -c:v mpeg2_cuvid -analyzeduration 1000M -probesize 1000M -i "$TITLE/$i-$TITLE.vob" \
# -map 0:v -metadata title="$TITLE" \
# -c:v h264_nvenc -preset medium -b:v $BITRATE_K -bufsize $BUFSIZE_K -profile:v high -bf 3 -b_ref_mode 0 -temporal-aq 1 -rc-lookahead 20 -vsync 0 \
# -loglevel repeat+verbose \
# -filter:v hue=b=0.0:s=0.7,hqdn3d=1.5:1.5:4:4,unsharp=luma_msize_x=5:luma_msize_y=5:luma_amount=0.5,noise=c0s=2:c1s=2:c2s=2:c0f=a+t \
# ${MAP_ID_STREAMS} -c:a copy $ALLSHOW_TAG -movflags +faststart \
# -y "$TITLE/$i-$TITLE.mkv"
rm -f "$TITLE/$i-$TITLE.vob"
rm -f "$TITLE/bitrate.txt"
fi
## VOB PRÉSENT.
## AU MOINS UN AUDIO OU PLUS.
## UN 0 CHANNEL OU PLUS.
## SANS LPCM.
if [[ -e "$TITLE/$i-$TITLE.vob" ]] && [[ "$COUNT_AUDIO" -ge "1" ]] && [[ "$O_CHANNELS" -ge "1" ]] && [[ "$COUNT_LPCM" -eq "0" ]]; then
ffmpeg -hide_banner -analyzeduration 1000M -probesize 1000M -vsync 2 -r "$FPS" -i "$TITLE/$i-$TITLE.vob" \
-map 0:v -metadata title="$TITLE" \
-c:v libx264 -b:v "$bitrate_k" -maxrate "$bitrate_k" -bufsize "$bufsize_k" \
-loglevel repeat+verbose -movflags faststart \
-x264opts 'keyint=300:min-keyint=25:8x8dct:sliced-threads=0' \
${REMOVE_O_CHANNELS} -c:a copy ${ALLSHOW_TAG} -movflags +faststart -max_muxing_queue_size 9999 \
-deblock 1:1 -flags +loop -qcomp 0.60 -qblur 0.5 -coder 1 -me_range 6 -sc_threshold 42 -bf 10 -trellis 2 -mbtree 1 -qmin 0 -qmax 52 \
$FILTERS \
-preset veryfast -y "$TITLE/$i-$TITLE.mkv"
rm -f "$TITLE/$i-$TITLE.vob"
rm -f "$TITLE/bitrate.txt"
fi
## VOB PRÉSENT.
## AVEC OU SANS AUDIO(S).
## SANS 0 CHANNEL.
## AU MOINS UN LPCM OU PLUS.
if [[ -e "$TITLE/$i-$TITLE.vob" ]] && [[ "$COUNT_AUDIO" -ge "0" ]] && [[ "$O_CHANNELS" -eq "0" ]] && [[ "$COUNT_LPCM" -ge "1" ]]; then
ffmpeg -hide_banner -analyzeduration 1000M -probesize 1000M -vsync 2 -r "$FPS" -i "$TITLE/$i-$TITLE.vob" \
-map 0:v -metadata title="$TITLE" \
-c:v libx264 -b:v "$bitrate_k" -maxrate "$bitrate_k" -bufsize "$bufsize_k" \
-loglevel repeat+verbose -movflags faststart \
-x264opts 'keyint=300:min-keyint=25:8x8dct:sliced-threads=0' \
${MAP_ID_STREAMS_LPCM} -acodec pcm_s16be ${ALLSHOW_TAG} -movflags +faststart -max_muxing_queue_size 9999 \
-deblock 1:1 -flags +loop -qcomp 0.60 -qblur 0.5 -coder 1 -me_range 6 -sc_threshold 42 -bf 10 -trellis 2 -mbtree 1 -qmin 0 -qmax 52 \
$FILTERS \
-preset veryfast -y "$TITLE/$i-$TITLE.mkv"
rm -f "$TITLE/$i-$TITLE.vob"
rm -f "$TITLE/bitrate.txt"
dvdxchap -t "$i" "$DEVICE" > "$TITLE/$i-$TITLE-Chapters.txt"
mkvmerge "$TITLE/$i-$TITLE.mkv" --chapters "$TITLE/$i-$TITLE-Chapters.txt" \
-o "$TITLE/$i-$TITLE-[Out_Chapters].mkv"
rm -f "$TITLE/$i-$TITLE.mkv"
rm -f "$TITLE/$i-$TITLE-Chapters.txt"
mv "$TITLE/$i-$TITLE-[Out_Chapters].mkv" "$TITLE/$i-$TITLE.mkv"
mkdir -p "$TITLE/WAVE"
for n in $AIDS_LPCM; do
mplayer -noconfig all -nocache -benchmark -vc null -vo null \
-ao pcm:fast:file="$TITLE/WAVE/[$i-($n)]-$TITLE.wav" \
-identify -dvd-device "$DEVICE" dvdnav://"$i" -ni -aid "$n"
done
fi
COUNT_AUDIO_FR=$(mplayer -noconfig all -nocache -vo null -ao null -frames 0 -identify "$TITLE/$i-$TITLE.mkv" 2>/dev/null |awk '/-alang fr,/ { print $9 }' | wc -w)
## AU MOINS UN AUDIO FRANÇAIS OU PLUS.
if [[ "$COUNT_AUDIO_FR" -ge "1" ]]; then
mkvmerge -o "$TITLE/$i-$TITLE-[Language: Français].mkv" -a fre "$TITLE/$i-$TITLE.mkv"
rm -f "$TITLE/$i-$TITLE.mkv"
mv "$TITLE/$i-$TITLE-[Language: Français].mkv" "$TITLE/$i-$TITLE.mkv"
fi
## ON INDIQUE LA LANGUE DE L'AUDIO DANS LE RENOMAGE DU TITRE ET LE NOMBRE.
INFO=$(mplayer -vo null -ao null -frames 0 -identify "$TITLE/$i-$TITLE.mkv" 2>/dev/null | \
awk '/alang/ { x = x $9 ""}
END { sub(/,*$/, "", x); print x }')
COUNT_INFO=$(mplayer -vo null -ao null -frames 0 -identify "$TITLE/$i-$TITLE.mkv" 2>/dev/null | grep -c "alang")
COUNT=$(mplayer -vo null -ao null -frames 0 -identify "$TITLE/$i-$TITLE.mkv" 2>/dev/null | grep -c "aid")
## UNE OU PLUSIEURS INFOS SUR L'AUDIO ET UN OU PLUSIEURS AUDIOS.
## INTÉGRATION DES CHAPITRES.
if [[ -e "$TITLE/$i-$TITLE.mkv" ]] && [[ "$COUNT_INFO" -ge "1" ]] && [[ "$COUNT" -ge "1" ]] ; then
mv "$TITLE/$i-$TITLE.mkv" "$TITLE/$i-$TITLE-[Audio: $INFO].mkv"
dvdxchap -t "$i" "$DEVICE" > "$TITLE/$i-$TITLE-Chapters.txt"
mkvmerge "$TITLE/$i-$TITLE-[Audio: $INFO].mkv" --chapters "$TITLE/$i-$TITLE-Chapters.txt" -o "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters].mkv"
rm -f "$TITLE/$i-$TITLE-[Audio: $INFO].mkv"
rm -f "$TITLE/$i-$TITLE-Chapters.txt"
mediainfo "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters].mkv" >> "$TITLE/IFOS/$i-$TITLE-[Audio: $INFO + Chapters].log"
fi
SIDFR=$(lsdvd -s "$DEVICE" -t "$i" 2> /dev/null |awk '/Subtitle:/ && /Language: fr/ { sub(/,$/ ,"", $2);
if ($2 ~ /^[0-9]+$/) print (--$2) }')
COUNT_SID_FR=$(echo "$SIDFR" |wc -w)
## AU MOINS UN SUB FRANÇAIS OU PLUS (ON EXTRAIT TOUT ÇA).
if [[ "$COUNT_SID_FR" -ge "1" ]]; then
mkdir -p "$TITLE/VOBSUBS/$i-$TITLE"
for n in $SIDFR; do mencoder -dvd-device "$DEVICE" dvdnav://"$i" -nosound -ovc frameno -force-avi-aspect "$RATIO" -o /dev/null \
-ifo "/run/media/$USER/$TITLE/VIDEO_TS/VTS_01_0.IFO" -sid "$n" -vobsubout "$TITLE/$n-vobsubs-fr" -vobsuboutindex "$n"
## ON CORRIGE LES ID VIDES SI BESOIN.
sed -i 's/id:.*,/id: fr,/g' "$TITLE/$n-vobsubs-fr.idx"
taille_idx=$(stat -c%s "$TITLE/$n-vobsubs-fr.idx")
taille_sub=$(stat -c%s "$TITLE/$n-vobsubs-fr.sub")
if [[ "$taille_idx" -gt 1000 ]] && [[ "$taille_sub" -gt 0 ]] ; then
echo "$n-vobsubs-fr.idx et $n-vobsubs-fr.sub sont bon"
else
## ON ISOLE LES VOBSUBS INVALIDES DANS LE DOSSIER VOBSUBS
echo "$n-vobsubs-fr.idx ou $n-vobsubs-fr.sub est incorrect ... déplacement"
mv "$TITLE/$n-vobsubs-fr.idx" "$TITLE/$n-vobsubs-fr.sub" "$TITLE/VOBSUBS/$i-$TITLE"
fi
done
fi
## ON COMPTE CE QU'IL RESTE DE BON EN IDX/SUB.
COUNT_IDX_FR=$(find "$TITLE" -maxdepth 1 -name '*.idx' | wc -l)
COUNT_SUB_FR=$(find "$TITLE" -maxdepth 1 -name '*.sub' | wc -l)
## CONDITION : UN IDX/SUB OU PLUS.
if [[ -e "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters].mkv" ]] && [ "$COUNT_IDX_FR" -ge "1" ] && [ "$COUNT_SUB_FR" -ge "1" ]
then
mkvmerge "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters].mkv" --language "0:fre" "$TITLE"/*.idx -o "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters + Sub].mkv"
## ON DÉPLACE LE RESTANT DES VOBSUBS UNE FOIS MIXÉS AVEC LES INVALIDES.
mv "$TITLE"/*.idx "$TITLE"/*.sub "$TITLE/VOBSUBS/$i-$TITLE"
rm -f "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters].mkv"
INFO_SUB=$(mplayer -vo null -ao null -frames 0 -identify "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters + Sub].mkv" 2>/dev/null | \
awk '/slang/ && /fre/ { x = x $9 ","}
END { sub(/,*$/, "", x); print x }')
mv "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters + Sub].mkv" "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters + Sub: $INFO_SUB].mkv"
mediainfo "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters + Sub: $INFO_SUB].mkv" >> "$TITLE/IFOS/$i-$TITLE-[Audio: $INFO + Chapters + Sub: $INFO_SUB].log"
rm -f "$TITLE/IFOS/$i-$TITLE-[Audio: $INFO + Chapters].log"
fi
## AUCUN IDX ou SUB.
if [[ -e "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters].mkv" ]] && [ "$COUNT_IDX_FR" -eq "0" ] || [ "$COUNT_SUB_FR" -eq "0" ]
then
mv "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters].mkv" "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters NoSub].mkv"
mediainfo "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters NoSub].mkv" >> "$TITLE/IFOS/$i-$TITLE-[Audio: $INFO + Chapters NoSub].log"
rm -f "$TITLE/IFOS/$i-$TITLE-[Audio: $INFO + Chapters].log"
fi
## PAS D'INFO ET UN SEUL AUDIO.
if [[ -e "$TITLE/$i-$TITLE.mkv" ]] && [[ "$COUNT_INFO" -eq "0" ]] && [[ "$COUNT" -eq "1" ]] ; then
mv "$TITLE/$i-$TITLE.mkv" "$TITLE/$i-$TITLE-[Audio: Und].mkv"
mediainfo "$TITLE/$i-$TITLE-[Audio: Und].mkv" >> "$TITLE/IFOS/$i-$TITLE-[Audio: Und].log"
fi
## PAS D'AUDIO DONC PAS D'INFO.
if [[ -e "$TITLE/$i-$TITLE.mkv" ]] && [[ "$COUNT_INFO" -eq "0" ]] && [[ "$COUNT" -eq "0" ]] ; then
mv "$TITLE/$i-$TITLE.mkv" "$TITLE/$i-$TITLE-[Audio: NoSound].mkv"
mediainfo "$TITLE/$i-$TITLE-[Audio: NoSound].mkv" >> "$TITLE/IFOS/$i-$TITLE-[Audio: NoSound].log"
fi
done
Dernière modification par Anonyme (23-04-2020 07:57:19)