Debian-facile

Bienvenue sur Debian-Facile, site d'aide pour les nouveaux utilisateurs de Debian.

Vous n'êtes pas identifié(e).


L'icône rouge permet de télécharger chaque page du wiki visitée au format PDF et la grise au format ODT → ODT PDF Export

Table des matières

Script - Copie DVD-VIDÉO

Introduction

Voici un script permettant le rippage et l'encodage de tous les titres sur DVD-VIDÉO.

Installation

Installer handbrake et handbrake-cli comme indiqué dans le tuto handbraque. tuto handbrake

Ajoutez :

apt install handbrake-cli mkvmerge mplayer lsdvd mediainfo

Script

Un script utilisant l'encodeur x264 :

ripdvd
#!/bin/bash
 
## Golgot200
## sudo pacman -S ffmpeg handbrake-cli mkvtoolnix-cli mplayer lsdvd mediainfo
 
##                               x264
##                               x264_10bit
##                               nvenc_h264
##                               x265
##                               x265_10bit
##                               x265_12bit
##                               nvenc_h265
##                               mpeg4
##                               mpeg2
##                               VP8
##                               VP9
##                               theora
 
 
 
 
PATH=$PATH:/sbin:/usr/sbin
 
## Condition : un seul dvd-vidéo.
mapfile -t  BLKID < <(blkid /dev/sr* |sed -E 's/^([^:]+): .*/\1/')
 
if [[ "${#BLKID[@]}" -eq  "0" ]] ; then
    echo "Aucun DVD trouvé: abandon"
    exit 0
fi
 
idx=0
for dev in "${BLKID[@]}"; do
    mnt=$(mount |sed -n -E "s/^${dev//\//\\\/} on (.*) type .*\$/\\1/p")
    [[ -z "$mnt" ]] && continue
    if [[ -f "$mnt/VIDEO_TS/VIDEO_TS.IFO" ]]; then
        DEVICES[$idx]="$dev"
        MOUNT_POINTS[$idx]="$mnt"
        idx=$((idx+1))
    fi
done
 
if [[ "${#DEVICES[@]}" -eq 0 ]]; then
    echo "Aucun dvd vidéo monté : Abandon"
    exit 0
elif [[ "${#DEVICES[@]}" -gt 1 ]];  then
    echo "Il y a plus d'un dvd video détecté : Abandon"
    exit 0
fi
 
DEVICE=${DEVICES[0]}
MOUNT_POINT=${MOUNT_POINTS[0]}
 
## Label du dvd-vidéo & nombre total de titres sur celui-ci.
idx=0
TITLE_COUNT=0
regexp='^Title: '
while read -r line; do
    idx=$((idx+1))
    if [[ "$idx" -eq 1 ]]; then
        TITLE=${line#*: }
    elif [[ "$line" =~ $regexp ]]; then
        TITLE_COUNT=$((TITLE_COUNT+1))
    fi
done < <(lsdvd "$DEVICE" 2>/dev/null)
 
unset regexp dev mnt idx BLKID DEVICES MOUNT_POINTS
 
if [[ -z "$TITLE" ]]; then
    echo "Pas de dvd vidéo trouvé : abandon"
    exit 0
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 -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
 
 
## Titres d'une durée de plus de .... secondes [ ici, 2 seconde]
 
    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=10
    [[ "$LENGTH" -le "$LIMIT" ]] && continue
 
 
 
 
## COMPARAISON ENTRE DVDNAV (INFO RÉEL) & LSDVD (INFO) SUR LA RÉALITÉ EXISTANTE DES STREAMS AUDIOS.
LAVF_STREAM_DVDNAV=$(mplayer -vo null -ao null -frames 0 -identify -dvd-device "$DEVICE" dvdnav://"$i"  2>/dev/null | awk '/-aid/ { print $7 }')
COUNT_LAVF_STREAM_DVDNAV=$(echo "$LAVF_STREAM_DVDNAV" |wc -w)
COUNT_AUDIO_LSDVD=$(lsdvd -a "$DEVICE" -t "$i"  2>/dev/null | grep -c "Audio:" )
 
 
## POUR N'AVOIR QUE LE FRANÇAIS. 
AUDIO_FRENCH=$(lsdvd -a "$DEVICE" -t "$i" 2> /dev/null | grep "Language: fr" | awk '{print$4}' )
COUNT_AUDIO_FRENCH=$(lsdvd -a "$DEVICE" -t "$i" 2> /dev/null |grep -c 'Language: fr')  
AUDIO_LANG_LIST_FRENCH=$(echo $AUDIO_FRENCH | sed 's/[[:blank:]]/,/g')
 
## BITRATE ORIGINAL.
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') 
 
RATIO=$(lsdvd -x $DEVICE -t "$i" | grep -m1 "Aspect ratio:" | awk '{print$11}' | sed -e 's/\//\:/g' | tr -d ',')
 
## [OPTION 1 ALL]
## ICI, ON ÉVITERA UN MKV SANS AUDIO. STREAM(S) SIGNALÉ(S) FR MAIS D'UNE DURÉE NUL PAR RAPPORT AU(X) AUTRE(S) SUPPRIMÉES EN [ OPTION 2 ]
## EX : PLUTO "-t 15" (fr null ===> eng seul valide) = OK  
if [[ "$COUNT_LAVF_STREAM_DVDNAV" != "$COUNT_AUDIO_LSDVD" ]]; then
 
 
#### SANS CROP
 
HandBrakeCLI --no-dvdnav \
--input $DEVICE --title $i \
--all-audio --all-subtitles --subtitle-lang-list fr \
-e x264 -b $BITRATE --loose-anamorphic --modulus 2 \
--hqdn3d=y-spatial=1.5:cb-spatial=1.5:cr-spatial=1.5:y-temporal=4:cb-temporal=4:cr-temporal=4 --unsharp=y-strength=0.5:y-size=5:cb-strength=0.5:cb-size=5 \
--crop 0:0:0:0 \
--aencoder copy \
--output "$TITLE/$i-$TITLE-[OPTION 1 ALL].mkv"
 
 
 
 
#### AJOUT CORRECTION STREAMS AUDIOS INVALIDES 
DETECT_VALID_AUDIO=$(ffprobe "$TITLE/$i-$TITLE-[OPTION 1 ALL].mkv" 2>&1 | awk '/Audio:/ && /Stream/ && /ac3,/ && /kb\/s/ { print $2 }'| cut -c4-4)
VALID_AUDIO_PREPARE=$(echo $DETECT_VALID_AUDIO | sed -e 's/\ /\,/g' >> "$TITLE/$i-choix.txt")
VALID_AUDIO=$(head -n 1 "$TITLE/$i-choix.txt" | tail -n 1)
 
 
       mkvmerge -o "$TITLE/$i-$TITLE-[OPTION 1 RETOUCHE].mkv" --atracks $VALID_AUDIO "$TITLE/$i-$TITLE-[OPTION 1 ALL].mkv" 
 
 
rm -f "$TITLE/$i-$TITLE-[OPTION 1 ALL].mkv"
rm -f "$TITLE/$i-choix.txt"
 
 
INFO_1=$(mplayer -vo null -ao null -frames 0 -identify "$TITLE/$i-$TITLE-[OPTION 1 RETOUCHE].mkv" 2>/dev/null | \
          awk '/alang/  { x = x $9 ""}
              END { sub(/,*$/, "", x); print x }')
 
      mv "$TITLE/$i-$TITLE-[OPTION 1 RETOUCHE].mkv" "$TITLE/$i-$TITLE-[Language: $INFO_1].mkv"
      mediainfo "$TITLE/$i-$TITLE-[Language: $INFO_1].mkv" >> "$TITLE/IFOS/$i-$TITLE-[Language: $INFO_1].log"                
 
 
 
 
    fi
 
 
 
 
VERIF_AUDIOFR=$(mplayer -vo null -ao null -frames 0 -identify "$TITLE/$i-$TITLE-[Language: $INFO_1].mkv" 2>/dev/null | \
   grep -c "alang fre,") 
 
if [[ "$VERIF_AUDIOFR" -ge "1" ]]; then
      mkvmerge -o "$TITLE/$i-$TITLE-[Language: Français].mkv" -a fre "$TITLE/$i-$TITLE-[Language: $INFO_1].mkv" 
 
rm -f "$TITLE/$i-$TITLE-[Language: $INFO_1].mkv"
 
INFO_AUDIOFR=$(mplayer -vo null -ao null -frames 0 -identify "$TITLE/$i-$TITLE-[Language: Français].mkv" 2>/dev/null | \
          awk '/alang/  { x = x $9 ""}
              END { sub(/,*$/, "", x); print x }')
 
      mv "$TITLE/$i-$TITLE-[Language: Français].mkv" "$TITLE/$i-$TITLE-[Language: $INFO_AUDIOFR].mkv"
      mediainfo "$TITLE/$i-$TITLE-[Language: $INFO_AUDIOFR].mkv" >> "$TITLE/IFOS/$i-$TITLE-[Language: $INFO_AUDIOFR].log"
rm -f "$TITLE/IFOS/$i-$TITLE-[Language: $INFO_1].log" 
 
 
 
   fi
 
 
 
## [OPTION 2]
## QUE FRANÇAIS SI PRÉSENT OU AUTRES SI PAS LE CHOIX.
## SOUSTITRES FRANÇAIS DANS LES DEUX CAS.
## SANS AUDIO = OK
## ANY (UNKNOWN AUDIO) = OK
## LPCM ==> AAC = OK
if [[ "$COUNT_LAVF_STREAM_DVDNAV" == "$COUNT_AUDIO_LSDVD" ]]; then
 
 
#### SANS CROP
 
HandBrakeCLI --no-dvdnav \
--input $DEVICE --title $i \
--all-audio --audio-lang-list "$AUDIO_LANG_LIST_FRENCH" --all-subtitles --subtitle-lang-list fr \
-e x264 -b $BITRATE --loose-anamorphic --modulus 2 \
--hqdn3d=y-spatial=1.5:cb-spatial=1.5:cr-spatial=1.5:y-temporal=4:cb-temporal=4:cr-temporal=4 --unsharp=y-strength=0.5:y-size=5:cb-strength=0.5:cb-size=5 \
--crop 0:0:0:0 \
--aencoder copy \
--output "$TITLE/$i-$TITLE-[OPTION 2].mkv"
 
 
 
INFO_2=$(mplayer -vo null -ao null -frames 0 -identify "$TITLE/$i-$TITLE-[OPTION 2].mkv" 2>/dev/null | \
          awk '/alang/  { x = x $9 ""}
              END { sub(/,*$/, "", x); print x }')
 
 
          mv "$TITLE/$i-$TITLE-[OPTION 2].mkv" "$TITLE/$i-$TITLE-[Language: $INFO_2].mkv"                   
          mediainfo "$TITLE/$i-$TITLE-[Language: $INFO_2].mkv" >> "$TITLE/IFOS/$i-$TITLE-[Language: $INFO_2].log" 
 
    fi
 
 
 
## DUMPAUDIO ET SAUVEGARDE DU LPCM EN WAVE D'UN DVD DE CONCERT LIVE.
AIDS_LPCM=$(lsdvd -a "$DEVICE" -t "$i" 2>/dev/null | awk '/lpcm|id:/ { print $22 }')  
COUNT_AUDIO_LPCM=$(lsdvd -a "$DEVICE" -t "$i" 2>/dev/null | grep -c "lpcm" )   
 
if [[ "$COUNT_AUDIO_LPCM" -ge "1" ]]; then
 
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
 
 
done

Ou le dernier né test5 :

cat test5
test5
#!/bin/bash
 
## golgot200
## Testeur smolski
## 02/03/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' | 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 2 -r 25 -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 2 -r 25 -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 2 -r 25 -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 2 -r 25 -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
 
conf
1)
N'hésitez pas à y faire part de vos remarques, succès, améliorations ou échecs !
doc/programmation/bash/handbrake.txt · Dernière modification: 12/03/2020 05:25 par smolski

Pied de page des forums

Propulsé par FluxBB