Bon voilà
Testé sur Archlinux et Debian Buster
/run/media/user/ pour Arch
/media/cdrom0 pour Debian
je me suis débrouillé bizarrement, mais ça fonctionne bien .
je fait en sort de sortir un point de montage unique comme "/run/media ou media" et par un find de ou des "VIDEO_TS.IFO", en faire des conditions.
J'ai testé avec 2 lecteurs sur le PC (en même temps)
1 cdrom + 1 CD-audio = abandon
1 cdrom = abandon
1 cd-audio = abandon
1 dvd-rom + 1 DVD-rom = abandon
1 dvd-vidéo + 1 dvd-vidéo = abandon
1 dvd-vidéo + autres = OK
1 dvd-vidéo = OK
Donc, ça devrait coller. J'ai retouché cette partie car le magnifique travail de notre ami enicar, pour ma part, j'ai du mal à l'assimiler
#!/bin/bash
## Anonyme
## Testeur smolski
## 01/03/2020
PATH=$PATH:/sbin:/usr/sbin
## CONDITION : UN SEUL DVD-VIDÉO.
mnt=$( mount | grep '/dev/sr' | grep -Po 'on\K.*(?=type)' | sed 's|\(.*\)/.*|\1|' | uniq )
COUNT_VIDEO_TS=$(find ${mnt} -name 'VIDEO_TS.IFO' | 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"
;;
[nN][oO]|[nN])
echo "No"
read -r -p "Entrer un nouveau nom: " TITLE
mkdir -p "$TITLE/IFOS"
;;
*)
echo "Invalid input..."
echo "Quit"
exit 1
;;
esac
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"
COUNT_AUDIO=$(ffprobe "$TITLE/$i-$TITLE.vob" 2>&1 | grep -c "Audio:")
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')
BITRATE_K=$((BITRATE/2))k
BUFSIZE_K=$((BITRATE/4))k
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 -analyzeduration 1000M -probesize 1000M -vsync passthrough -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 \
-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 \
-preset veryfast -y "$TITLE/$i-$TITLE.mkv"
rm -f "$TITLE/$i-$TITLE.vob"
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 -analyzeduration 1000M -probesize 1000M -vsync passthrough -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 \
-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 \
-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"
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 -analyzeduration 1000M -probesize 1000M -vsync passthrough -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 \
-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 \
-preset veryfast -y "$TITLE/$i-$TITLE.mkv"
rm -f "$TITLE/$i-$TITLE.vob"
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 -analyzeduration 1000M -probesize 1000M -vsync passthrough -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 \
-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 \
-preset veryfast -y "$TITLE/$i-$TITLE.mkv"
rm -f "$TITLE/$i-$TITLE.vob"
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
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" ; done
find . -type f \( -name "*.idx" -o -name "*.sub" \) -size -500c -delete
fi
## ON VÉRIFIE CE QUI RESTE DE BON EN IDX.
# COUNT_IDX_FR=`ls -1 $TITLE/*.idx 2>/dev/null | wc -l`
# COUNT_IDX_FR=$(find . -maxdepth 1 -name '*.idx' | wc -l)
COUNT_IDX_FR=$(find "$TITLE" -maxdepth 1 -name '*.idx' | wc -l)
## UN IDX OU PLUS.
if [[ -e "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters].mkv" ]] && [ "$COUNT_IDX_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"
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.
if [[ -e "$TITLE/$i-$TITLE-[Audio: $INFO + Chapters].mkv" ]] && [ "$COUNT_IDX_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
rm -f "$TITLE"/*.idx
rm -f "$TITLE"/*.sub
done
J'ai aussi divisé par deux la taille du fichier original.
BITRATE_K=$((BITRATE/2))k
BUFSIZE_K=$((BITRATE/4))k
shellcheck ne me montre rien de spécial mis à part quelques doubles quotes en proposition.
Mais il ne faut surtout pas les mettre.
Dernière modification par Anonyme (02-03-2020 15:03:08)