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 →
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
utilisateurs:slyfox:scripts:accueil [14/08/2018 17:30] Slyfox créée |
utilisateurs:slyfox:scripts:accueil [18/08/2018 23:24] Slyfox [Introduction] |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== Slymedia ====== | ====== Slymedia ====== | ||
- | * Objet : du tuto FIXME | + | * Objet : Script Slymedia |
- | * Niveau requis : FIXME {{tag>débutant avisé}} | + | * Niveau requis : {{tag>débutant}} |
- | * Commentaires : //Contexte d'utilisation du sujet du tuto. // FIXME | + | * Commentaires : - |
* Débutant, à savoir : [[:doc:systeme:commandes:le_debianiste_qui_papillonne|Utiliser GNU/Linux en ligne de commande, tout commence là !.]] :-) | * Débutant, à savoir : [[:doc:systeme:commandes:le_debianiste_qui_papillonne|Utiliser GNU/Linux en ligne de commande, tout commence là !.]] :-) | ||
+ | * Création par [[user>Slyfox]] 14.08.2018 | ||
+ | * Suivi : {{tag>à-placer}} | ||
- | ===== Script ===== | + | ===== Introduction ===== |
+ | Slymedia est un script (amateur) qui permet de convertir les fichiers vidéo et audio. | ||
- | <note warning>En cours d'écriture, peut fonctionner que partiellement !</note> | + | ===== Installation ===== |
+ | |||
+ | Paquets pour le fonctionne du script: | ||
+ | |||
+ | <code root>apt update | ||
+ | apt upgrade | ||
+ | apt install aptitude | ||
+ | aptitude install ffmpeg yad flac vorbis-tools eyed3 kid3-cli</code> | ||
+ | ===== Script ===== | ||
+ | <note important>En cours d'écriture, peut fonctionner que partiellement.</note> | ||
- | <note tip>Version du: 02.08.2018</note> | + | <note tip>Version du: 17.08.2018</note> |
<code user>#! /bin/bash | <code user>#! /bin/bash | ||
# Paquets à installer: ffmpeg yad flac vorbis-tools eyed3 kid3-cli | # Paquets à installer: ffmpeg yad flac vorbis-tools eyed3 kid3-cli | ||
- | # Version: 20180802 | + | # Version: 20180817 |
#=========================================================================================================== | #=========================================================================================================== | ||
Ligne 42: | Ligne 54: | ||
--button="Source!gtk-file!:4" \ | --button="Source!gtk-file!:4" \ | ||
--button="Lancer conversion!gtk-convert!:0" \ | --button="Lancer conversion!gtk-convert!:0" \ | ||
- | "${cdeYadStream[@]}") | + | "${TabYadStream[@]}") |
# Status de sortie Yad | # Status de sortie Yad | ||
Ligne 78: | Ligne 90: | ||
--field=" ":LBL " " \ | --field=" ":LBL " " \ | ||
--field="<b>Options</b>":LBL " " \ | --field="<b>Options</b>":LBL " " \ | ||
- | --field="Supprimer toutes les métadonnées":CHK "${metadata}" \ | + | --field="Supprimer tous les tags et images cover":CHK "${metadata}" \ |
--field="Ne pas encoder si même codec que l'original":CHK "${nocopy}" \ | --field="Ne pas encoder si même codec que l'original":CHK "${nocopy}" \ | ||
--field="Dossier source":DIR "${dirIn}" \ | --field="Dossier source":DIR "${dirIn}" \ | ||
Ligne 96: | Ligne 108: | ||
nocopy=$(awk -F [\|] '{print $20}' <<< "${yadPreference}") | nocopy=$(awk -F [\|] '{print $20}' <<< "${yadPreference}") | ||
dirIn=$(awk -F [\|] '{print $21}' <<< "${yadPreference}") | dirIn=$(awk -F [\|] '{print $21}' <<< "${yadPreference}") | ||
- | |||
- | |||
} | } | ||
#=========================================================================================================== | #=========================================================================================================== | ||
Ligne 117: | Ligne 127: | ||
--column="" \ | --column="" \ | ||
--column="Type de source" \ | --column="Type de source" \ | ||
+ | "FALSE" "Fichier avec analyse" \ | ||
"TRUE" "Fichier" \ | "TRUE" "Fichier" \ | ||
"FALSE" "DVD" \ | "FALSE" "DVD" \ | ||
Ligne 148: | Ligne 159: | ||
# Status de sortie Yad | # Status de sortie Yad | ||
status="$?" | status="$?" | ||
+ | } | ||
+ | #=========================================================================================================== | ||
+ | function YADPROGRESS() | ||
+ | { | ||
+ | yad --progress \ | ||
+ | --title "SlyEditImage ${version}" \ | ||
+ | --geometry="550x300" \ | ||
+ | --borders="25" \ | ||
+ | --auto-close \ | ||
+ | --auto-kill \ | ||
+ | --button="gtk-media-stop:1" | ||
+ | |||
+ | yadStatus="$?" | ||
} | } | ||
#=========================================================================================================== | #=========================================================================================================== | ||
Ligne 338: | Ligne 362: | ||
} | } | ||
#=========================================================================================================== | #=========================================================================================================== | ||
- | function STREAM() | + | function STREAM_SIMPLE() |
{ | { | ||
+ | |||
[[ -f "${dossierTmp}/stream.txt" ]] && rm "${dossierTmp}/stream.txt" | [[ -f "${dossierTmp}/stream.txt" ]] && rm "${dossierTmp}/stream.txt" | ||
- | cdeYadStream=() | + | TabYadStream=() |
- | + | ||
IFS=$'\n' | IFS=$'\n' | ||
- | + | ||
+ | |||
+ | # Initialisation | ||
+ | nbr="0" | ||
+ | pourcent="0" | ||
+ | timeGo="$(date +%s)" | ||
+ | |||
+ | # Nombre de fichier | ||
+ | nbrFichier=$(awk '/./ {print}' <<< "${fileIn}" | wc -l) | ||
+ | |||
+ | # Calcul le pourcent par fichier | ||
+ | pourcentFichier=$(echo "scale=15; 100/${nbrFichier}" | bc) | ||
+ | |||
for i in ${fileIn}; do | for i in ${fileIn}; do | ||
+ | |||
+ | # Titre et durée | ||
+ | #streamFormat=$(ffprobe -i "${i}" -hide_banner -v quiet -show_entries format=bit_rate -of csv=s="|") | ||
+ | #rateTotal=$(ffmpeg -y -i "${i}" 2>&1 | awk '/Duration:/ {printf "%s\n" ,$(NF-1)}') | ||
+ | |||
+ | # Mise en mémoire dans tableau TabYadStream | ||
+ | TabYadStream=(${TabYadStream[@]} --field="<b>TITRE:</b> $(basename "${i}")":LBL " ") | ||
+ | |||
+ | |||
+ | |||
+ | # Nom du fichier | ||
+ | fileNameExt=$(basename "${i}") | ||
+ | fileName="${fileNameExt%.*}" | ||
+ | |||
+ | # Envoi données vers YADPROGRESS | ||
+ | pourcent=$(echo "scale=15; (${pourcent}+${pourcentFichier})" | bc) | ||
+ | |||
+ | ((nbr+=1)) | ||
+ | |||
+ | # Calcul temps restant | ||
+ | timeT="$(date +%s)" | ||
+ | timeRemainingS=$(echo "scale=15; ((${timeT}-${timeGo})*${nbrFichier}/${nbr})-(${timeT}-${timeGo})" | bc | awk -F"." '{print $1}') | ||
+ | timeRemainingHMS=$(date +%T -d "0000-01-01 ${timeRemainingS} seconds") | ||
+ | |||
+ | # Envoi données à YADPROGRESS | ||
+ | echo "${pourcent}" | ||
+ | echo -e "\n#Chargement ${nbr} fichiers sur ${nbrFichier} - Temps restant environ: ${timeRemainingHMS}" | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | done | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | for i in "${TabYadStream[@]}"; do | ||
+ | echo "$i" >>"${dossierTmp}/yadStream.txt" | ||
+ | done | ||
+ | } | ||
+ | #=========================================================================================================== | ||
+ | function STREAM() | ||
+ | { | ||
+ | [[ -f "${dossierTmp}/stream.txt" ]] && rm "${dossierTmp}/stream.txt" | ||
+ | touch "${dossierTmp}/yadStream.txt" | ||
+ | TabYadStream=() | ||
+ | |||
+ | # Initialisation | ||
+ | nbr="0" | ||
+ | pourcent="0" | ||
+ | timeGo="$(date +%s)" | ||
+ | |||
+ | # Nombre de fichier | ||
+ | nbrFichier=$(awk '/./ {print}' <<< "${fileIn}" | wc -l) | ||
+ | |||
+ | # Calcul le pourcent par fichier | ||
+ | pourcentFichier=$(echo "scale=15; 100/${nbrFichier}" | bc) | ||
+ | |||
+ | IFS=$'\n' | ||
+ | |||
+ | for iFileIn in ${fileIn}; do | ||
STREAMTITLE | STREAMTITLE | ||
STREAMVIDEO | STREAMVIDEO | ||
STREAMAUDIO | STREAMAUDIO | ||
STREAMSUBTITLE | STREAMSUBTITLE | ||
- | cdeYadStream=(${cdeYadStream[@]} --field=" ":LBL " ") | + | |
- | + | TabYadStream+=( --field=" ":LBL " ") | |
+ | |||
+ | # Nom du fichier | ||
+ | fileNameExt=$(basename "${iFileIn}") | ||
+ | fileName="${fileNameExt%.*}" | ||
+ | |||
+ | # Envoi données vers YADPROGRESS | ||
+ | pourcent=$(echo "scale=15; (${pourcent}+${pourcentFichier})" | bc) | ||
+ | |||
+ | ((nbr+=1)) | ||
+ | |||
+ | # Calcul temps restant | ||
+ | timeT="$(date +%s)" | ||
+ | timeRemainingS=$(echo "scale=15; ((${timeT}-${timeGo})*${nbrFichier}/${nbr})-(${timeT}-${timeGo})" | bc | awk -F"." '{print $1}') | ||
+ | timeRemainingHMS=$(date +%T -d "0000-01-01 ${timeRemainingS} seconds") | ||
+ | |||
+ | # Envoi données à YADPROGRESS | ||
+ | echo "${pourcent}" | ||
+ | echo -e "\n#Analyse ${nbr} fichiers sur ${nbrFichier} - Temps restant environ: ${timeRemainingHMS}" | ||
+ | done | ||
+ | |||
+ | for i in "${TabYadStream[@]}"; do | ||
+ | echo "$i" >>"${dossierTmp}/yadStream.txt" | ||
done | done | ||
} | } | ||
Ligne 358: | Ligne 482: | ||
{ | { | ||
# Titre et durée | # Titre et durée | ||
- | streamFormat=$(ffprobe -i "${i}" -hide_banner -v quiet -show_entries format=duration,bit_rate -of csv=s="|") | + | streamFormat=$(ffprobe -i "${iFileIn}" -hide_banner -v quiet -show_entries format=duration,bit_rate -of csv=s="|") |
- | + | ||
durationS=$(awk -F [\|] '{print $2}' <<< "${streamFormat}") | durationS=$(awk -F [\|] '{print $2}' <<< "${streamFormat}") | ||
- | durationHMS=$(date -d@"${durationS}" -u +%H:%M:%S) | + | durationHMS=$(date +%T -d "0000-01-01 ${durationS} seconds") |
rateTotal=$(awk -F [\|] '{printf "%d kb/s" ,($3/1000)}' <<< "${streamFormat}") | rateTotal=$(awk -F [\|] '{printf "%d kb/s" ,($3/1000)}' <<< "${streamFormat}") | ||
- | # Mise en mémoire dans tableau cdeYadStream | + | # Mise en mémoire dans tableau TabYadStream |
- | cdeYadStream=(${cdeYadStream[@]} --field="<b>TITRE: $(basename "${i}") - ${durationHMS} - ${rateTotal}</b>":LBL " ") | + | TabYadStream+=( --field="<b>TITRE: $(basename "${iFileIn}") - ${durationHMS} - ${rateTotal}</b>":LBL " ") |
} | } | ||
#=========================================================================================================== | #=========================================================================================================== | ||
function STREAMVIDEO() | function STREAMVIDEO() | ||
{ | { | ||
- | streamVideo=$(ffprobe -i "${i}" -hide_banner -v quiet -select_streams v -show_entries stream=index,codec_name,width,height,r_frame_rate -of csv=s="|") | ||
- | |||
while read line; do | while read line; do | ||
Ligne 396: | Ligne 517: | ||
if [[ "${codec}" == "mjpeg" ]] || [[ "${codec}" == "png" ]]; then | if [[ "${codec}" == "mjpeg" ]] || [[ "${codec}" == "png" ]]; then | ||
- | # Recherche numéro id depuis la map | + | # Recherche map depuis numéro id |
id=$(awk -F [\:] '{print $2}' <<< "0:${index}") | id=$(awk -F [\:] '{print $2}' <<< "0:${index}") | ||
typeImage=$(ffprobe -i "${i}" -hide_banner -v quiet -select_streams ${id} -show_entries stream_tags=comment -of csv=s="|" | awk -F [\|] '{print $2}') | typeImage=$(ffprobe -i "${i}" -hide_banner -v quiet -select_streams ${id} -show_entries stream_tags=comment -of csv=s="|" | awk -F [\|] '{print $2}') | ||
- | # Mise en forme piste vidéo (envoi vers fichier tmp et envoi dans tableau cdeYadStream) | + | # Mise en forme piste vidéo (envoi vers fichier tmp et envoi dans tableau TabYadStream) |
if [[ "${index}" != "" ]]; then | if [[ "${index}" != "" ]]; then | ||
- | printf "|${i}|0:${index}|VIDEO|${typeImage}|${codec}|${width}|${height}\n" >> "${dossierTmp}/stream.txt" | + | printf "|${iFileIn}|0:${index}|VIDEO|${typeImage}|${codec}|${width}|${height}\n" >> "${dossierTmp}/stream.txt" |
- | cdeYadStream=(${cdeYadStream[@]} --field="0:${index} | VIDEO |${typeImage} ${codec} ${width}x${height}":CHK "TRUE") | + | TabYadStream+=( --field="0:${index} | VIDEO |${typeImage} ${codec} ${width}x${height}":CHK "TRUE") |
- | + | ||
fi | fi | ||
else | else | ||
- | # Mise en forme piste vidéo (envoi vers fichier tmp et envoi dans tableau cdeYadStream) | + | # Mise en forme piste vidéo (envoi vers fichier tmp et envoi dans tableau TabYadStream) |
if [[ "${index}" != "" ]]; then | if [[ "${index}" != "" ]]; then | ||
- | printf "|${i}|0:${index}|VIDEO|${codec}|${width}|${height}|${fps}\n" >> "${dossierTmp}/stream.txt" | + | printf "|${iFileIn}|0:${index}|VIDEO|${codec}|${width}|${height}|${fps}\n" >> "${dossierTmp}/stream.txt" |
- | cdeYadStream=(${cdeYadStream[@]} --field="0:${index} | VIDEO |${codec} ${width}x${height} ${fps} fps":CHK "TRUE") | + | TabYadStream+=( --field="0:${index} | VIDEO |${codec} ${width}x${height} ${fps} fps":CHK "TRUE") |
- | + | ||
fi | fi | ||
fi | fi | ||
- | + | done <<< $(ffprobe -i "${iFileIn}" -hide_banner -v quiet -select_streams v -show_entries stream=index,codec_name,width,height,r_frame_rate -of csv=s="|") | |
- | + | ||
- | done <<< "${streamVideo}" | + | |
} | } | ||
#=========================================================================================================== | #=========================================================================================================== | ||
function STREAMAUDIO() | function STREAMAUDIO() | ||
{ | { | ||
- | streamAudio=$(ffprobe -i "${i}" -hide_banner -v quiet -select_streams a -show_entries stream=index,codec_name,sample_rate,channel_layout,bit_rate -show_entries stream_tags=language -of csv=s="|") | + | while read line; do |
- | + | ||
- | while read line; do | + | index=$(awk -F [\|] '{print $2}' <<< "${line}") |
- | + | codec=$(awk -F [\|] '{print $3}' <<< "${line}") | |
- | index=$(awk -F [\|] '{print $2}' <<< "${line}") | + | rate=$(awk -F [\|] '{print $4}' <<< "${line}") |
- | codec=$(awk -F [\|] '{print $3}' <<< "${line}") | + | channelOut=$(awk -F [\|] '{print $5}' <<< "${line}") |
- | rate=$(awk -F [\|] '{print $4}' <<< "${line}") | + | lang=$(awk -F [\|] '{print $NF}' <<< "${line}") |
- | channelOut=$(awk -F [\|] '{print $5}' <<< "${line}") | + | |
- | lang=$(awk -F [\|] '{print $NF}' <<< "${line}") | + | LANGUE |
- | #debitAudio=$(awk -F [\|] '{print $6}' <<< "${line}") | + | |
- | + | # Affectation TRUE ou FALSE | |
- | LANGUE | + | if [[ "${language}" == "${langAudio}" ]] || [[ "${language}" == "Inconnu" ]] || [[ "${langAudio}" == "Toutes les langues" ]]; then |
- | + | bol="TRUE" | |
- | # Affectation TRUE ou FALSE | + | |
- | if [[ "${language}" == "${langAudio}" ]] || [[ "${language}" == "Inconnu" ]] || [[ "${langAudio}" == "Toutes les langues" ]]; then | + | else |
- | bol="TRUE" | + | bol="FALSE" |
- | + | fi | |
- | else | + | |
- | bol="FALSE" | + | # Mise en forme piste audio (envoi vers fichier tmp et envoi dans tableau TabYadStream) |
- | fi | + | if [[ "${index}" != "" ]]; then |
- | + | printf "|${iFileIn}|0:${index}|AUDIO|${codec}|${language}|${languageISO}|${rate}|${channelOut}|\n" >> "${dossierTmp}/stream.txt" | |
- | # Mise en forme piste audio (envoi vers fichier tmp et envoi dans tableau cdeYadStream) | + | TabYadStream+=( --field="0:${index}| AUDIO | ${language} ${codec} ${rate} Hz ${channelOut}":CHK "${bol}") |
- | if [[ "${index}" != "" ]]; then | + | fi |
- | printf "|${i}|0:${index}|AUDIO|${codec}|${language}|${languageISO}|${rate}|${channelOut}|\n" >> "${dossierTmp}/stream.txt" | + | |
- | cdeYadStream=(${cdeYadStream[@]} --field="0:${index}| AUDIO | ${language} ${codec} ${rate} Hz ${channelOut}":CHK "${bol}") | + | done <<< $(ffprobe -i "${iFileIn}" -hide_banner -v quiet -select_streams a -show_entries stream=index,codec_name,sample_rate,channel_layout,bit_rate -show_entries stream_tags=language -of csv=s="|") |
- | + | ||
- | fi | + | |
- | + | ||
- | done <<< "${streamAudio}" | + | |
} | } | ||
#=========================================================================================================== | #=========================================================================================================== | ||
function STREAMSUBTITLE() | function STREAMSUBTITLE() | ||
{ | { | ||
- | streamSub=$(ffprobe -i "${i}" -hide_banner -v quiet -select_streams s -show_entries stream=index,codec_name -show_entries stream_tags=language -of csv=s="|") | ||
- | |||
while read line; do | while read line; do | ||
Ligne 476: | Ligne 587: | ||
fi | fi | ||
- | # Mise en forme piste audio (envoi vers fichier tmp et envoi dans tableau cdeYadStream) | + | # Mise en forme piste audio (envoi vers fichier tmp et envoi dans tableau TabYadStream) |
if [[ "${index}" != "" ]]; then | if [[ "${index}" != "" ]]; then | ||
- | printf "|${i}|0:${index}|SUBTITLE|${codec}|${language}|${languageISO}|\n" >> "${dossierTmp}/stream.txt" | + | printf "|${iFileIn}|0:${index}|SUBTITLE|${codec}|${language}|${languageISO}|\n" >> "${dossierTmp}/stream.txt" |
- | cdeYadStream=(${cdeYadStream[@]} --field="0:${index} | SUBTITLE | ${language} ${codec}":CHK "${bol}") | + | TabYadStream+=( --field="0:${index} | SUBTITLE | ${language} ${codec}":CHK "${bol}") |
- | + | ||
fi | fi | ||
- | done <<< "${streamSub}" | + | done <<< $(ffprobe -i "${iFileIn}" -hide_banner -v quiet -select_streams s -show_entries stream=index,codec_name -show_entries stream_tags=language -of csv=s="|") |
} | } | ||
#=========================================================================================================== | #=========================================================================================================== | ||
Ligne 616: | Ligne 726: | ||
qAudio1=(-b:a 320k) | qAudio1=(-b:a 320k) | ||
qAudio2=(-b:a 256k) | qAudio2=(-b:a 256k) | ||
- | qAudio3=(-b:a 192k) | + | qAudio3=(-b:a 160k) |
qAudio4=(-b:a 128k) | qAudio4=(-b:a 128k) | ||
qAudio5=(-b:a 64k) | qAudio5=(-b:a 64k) | ||
Ligne 634: | Ligne 744: | ||
if [[ "${typeRate}" == "VBR" ]]; then | if [[ "${typeRate}" == "VBR" ]]; then | ||
- | qAudio1=(-q:a 0) | + | qAudio1=(-q:a 2) |
- | qAudio2=(-q:a 2) | + | qAudio2=(-q:a 1.5) |
- | qAudio3=(-q:a 5) | + | qAudio3=(-q:a 1) |
- | qAudio4=(-q:a 7) | + | qAudio4=(-q:a 0.7) |
- | qAudio5=(-q:a 9) | + | qAudio5=(-q:a 0.2) |
elif [[ "${typeRate}" == "CBR" ]]; then | elif [[ "${typeRate}" == "CBR" ]]; then | ||
qAudio1=(-b:a 320k) | qAudio1=(-b:a 320k) | ||
qAudio2=(-b:a 256k) | qAudio2=(-b:a 256k) | ||
- | qAudio3=(-b:a 192k) | + | qAudio3=(-b:a 160k) |
qAudio4=(-b:a 128k) | qAudio4=(-b:a 128k) | ||
qAudio5=(-b:a 64k) | qAudio5=(-b:a 64k) | ||
Ligne 662: | Ligne 772: | ||
if [[ "${typeRate}" == "VBR" ]]; then | if [[ "${typeRate}" == "VBR" ]]; then | ||
qAudio1=(-q:a 0) | qAudio1=(-q:a 0) | ||
- | qAudio2=(-q:a 2) | + | qAudio2=(-q:a 1) |
- | qAudio3=(-q:a 5) | + | qAudio3=(-q:a 4) |
qAudio4=(-q:a 7) | qAudio4=(-q:a 7) | ||
qAudio5=(-q:a 9) | qAudio5=(-q:a 9) | ||
Ligne 670: | Ligne 780: | ||
qAudio1=(-b:a 320k) | qAudio1=(-b:a 320k) | ||
qAudio2=(-b:a 256k) | qAudio2=(-b:a 256k) | ||
- | qAudio3=(-b:a 192k) | + | qAudio3=(-b:a 160k) |
qAudio4=(-b:a 128k) | qAudio4=(-b:a 128k) | ||
qAudio5=(-b:a 64k) | qAudio5=(-b:a 64k) | ||
Ligne 676: | Ligne 786: | ||
fi | fi | ||
} | } | ||
- | #=========================================================================================================== | + | function FFMPEG_SIMPLE |
- | function FFMPEG() | + | |
{ | { | ||
+ | |||
+ | |||
+ | |||
IFS=$'\n' | IFS=$'\n' | ||
for iFileIn in ${fileIn}; do | for iFileIn in ${fileIn}; do | ||
- | + | ||
# Initialisation commandes | # Initialisation commandes | ||
cdeVideo=() | cdeVideo=() | ||
Ligne 692: | Ligne 804: | ||
fileName="${fileNameExtension%.*}" | fileName="${fileNameExtension%.*}" | ||
extension="${fileNameExtension##*.}" | extension="${fileNameExtension##*.}" | ||
- | + | ||
+ | |||
+ | |||
+ | STREAMAUDIO | ||
+ | |||
+ | |||
+ | cat "${dossierTmp}/stream.txt" | ||
+ | |||
+ | |||
+ | exit | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | done | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | #=========================================================================================================== | ||
+ | function FFMPEG() | ||
+ | { | ||
+ | IFS=$'\n' | ||
+ | for iFileIn in ${fileIn}; do | ||
+ | |||
+ | # Initialisation commandes | ||
+ | cdeVideo=() | ||
+ | cdeAudio=() | ||
+ | cdeSub=() | ||
+ | |||
+ | # Nom fichier source | ||
+ | fileNameExtension=$(basename "${iFileIn}") | ||
+ | fileName="${fileNameExtension%.*}" | ||
+ | extension="${fileNameExtension##*.}" | ||
# Recherche map | # Recherche map | ||
- | mapVideo=$(awk -F [\|] '{if ($4 ~ /VIDEO/ && /'${fileName}'/) {printf "%s\n" ,$3}}' <<< "${stream}") | + | mapVideo=$(awk -v iFileIn="${iFileIn}" -v iMapAudio="${iMapAudio}" -F [\|] '{if ($4 == "VIDEO" && $2 == iFileIn) {printf "%s" ,$3}}' <<< "${stream}") |
- | mapAudio=$(awk -F [\|] '{if ($4 ~ /AUDIO/ && /'${fileName}'/) {printf "%s\n" ,$3}}' <<< "${stream}") | + | mapAudio=$(awk -v iFileIn="${iFileIn}" -v iMapAudio="${iMapAudio}" -F [\|] '{if ($4 == "AUDIO" && $2 == iFileIn) {printf "%s" ,$3}}' <<< "${stream}") |
- | mapSub=$(awk -F [\|] '{if ($4 ~ /SUBTITLE/ && /'${fileName}'/) {printf "%s\n" ,$3}}' <<< "${stream}") | + | mapSub=$(awk -v iFileIn="${iFileIn}" -v iMapAudio="${iMapAudio}" -F [\|] '{if ($4 == "SUBTITLE" && $2 == iFileIn) {printf "%s" ,$3}}' <<< "${stream}") |
- | + | ||
echo "==============================================" | echo "==============================================" | ||
echo " iFileIn: ${iFileIn}" | echo " iFileIn: ${iFileIn}" | ||
Ligne 704: | Ligne 863: | ||
echo " mapAudio: ${mapAudio}" | echo " mapAudio: ${mapAudio}" | ||
echo " mapSub: ${mapSub}" | echo " mapSub: ${mapSub}" | ||
- | + | ||
# Metadonnée | # Metadonnée | ||
if [[ "${metadata}" == "TRUE" ]]; then | if [[ "${metadata}" == "TRUE" ]]; then | ||
Ligne 711: | Ligne 870: | ||
cdeMetadata=() | cdeMetadata=() | ||
fi | fi | ||
- | + | ||
FFMPEG_VIDEO | FFMPEG_VIDEO | ||
FFMPEG_AUDIO | FFMPEG_AUDIO | ||
FFMPEG_OUT | FFMPEG_OUT | ||
- | + | ||
# Conversion fichier | # Conversion fichier | ||
- | ffmpeg -y -i "${iFileIn}" -loglevel debug "${cdeMetadata[@]}" "${cdeVideo[@]}" "${cdeAudio[@]}" "${dirOut}/${fileName}.${conteneur}" | + | ffmpeg -y -i "${iFileIn}" -loglevel debug "${cdeMetadata[@]}" "${cdeVideo[@]}" "${cdeAudio[@]}" -t 10 "${dirOut}/${fileName}.${conteneur}" |
ffmpeg -i "${dirOut}/${fileName}.${conteneur}" ## TEST ## | ffmpeg -i "${dirOut}/${fileName}.${conteneur}" ## TEST ## | ||
- | echo "ffmpeg -y -i ${iFileIn} ${cdeMetadata[@]} ${cdeVideo[@]} ${cdeAudio[@]} ${dirOut}/${fileName}.${conteneur} -------- ${rateTotal}" ## TEST ## | + | |
- | + | echo "==============================================" | |
+ | echo "ffmpeg -y -i ${iFileIn} ${cdeMetadata[@]} ${cdeVideo[@]} ${cdeAudio[@]} -t 10 ${dirOut}/${fileName}.${conteneur} | ||
+ | rateTotal: ${rateTotal}" ## TEST ## | ||
+ | echo "==============================================" | ||
# Image cover fichier audio | # Image cover fichier audio | ||
for iMapVideo in ${mapVideo}; do | for iMapVideo in ${mapVideo}; do | ||
- | + | ||
numImage="1" | numImage="1" | ||
- | + | ||
# Recherche codec vidéo (image) | # Recherche codec vidéo (image) | ||
codecVideoIn=$(awk -F [\|] '{if ($4 ~ /VIDEO/ && /'${iMapVideo}'/ && /'${fileName}'/) {printf "%s" ,$5}}' <<< "${stream}") | codecVideoIn=$(awk -F [\|] '{if ($4 ~ /VIDEO/ && /'${iMapVideo}'/ && /'${fileName}'/) {printf "%s" ,$5}}' <<< "${stream}") | ||
- | + | ||
if [[ "${codecVideoIn}" == "mjpeg" ]] || [[ "${codecVideoIn}" == "png" ]]; then | if [[ "${codecVideoIn}" == "mjpeg" ]] || [[ "${codecVideoIn}" == "png" ]]; then | ||
- | + | ||
COVER | COVER | ||
fi | fi | ||
- | + | ||
done | done | ||
- | + | ||
done | done | ||
+ | |||
} | } | ||
- | |||
#=========================================================================================================== | #=========================================================================================================== | ||
function FFMPEG_VIDEO() | function FFMPEG_VIDEO() | ||
Ligne 746: | Ligne 909: | ||
for iMapVideo in ${mapVideo}; do | for iMapVideo in ${mapVideo}; do | ||
- | codecVideoIn=$(awk -F [\|] '{if ($4 ~ /VIDEO/ && /'${iMapVideo}'/ && /'${fileName}'/) {printf "%s" ,$5}}' <<< "${stream}") | + | codecVideoIn=$(awk -v iFileIn="${iFileIn}" -v iMapVideo="${iMapVideo}" -F [\|] '{if ($4 == "VIDEO" && $2 == iFileIn && $3 == iMapVideo){printf "%s" ,$5}}' <<< "${stream}") |
PROFIL | PROFIL | ||
Ligne 768: | Ligne 931: | ||
{ | { | ||
numAudio="0" | numAudio="0" | ||
+ | |||
+ | |||
for iMapAudio in ${mapAudio}; do | for iMapAudio in ${mapAudio}; do | ||
- | codecAudioIn=$(awk -F [\|] '{if ($4 ~ /AUDIO/ && /'${iMapAudio}'/ && /'${fileName}'/) {printf "%s" ,$5}}' <<< "${stream}") | + | codecAudioIn=$(awk -v iFileIn="${iFileIn}" -v iMapAudio="${iMapAudio}" -F [\|] '{ |
- | languageISO=$(awk -F [\|] '{if ($4 ~ /AUDIO/ && $3 ~ /'${iMapAudio}'/ && /'${fileName}'/) {printf "%s" ,$7}}' <<< "${stream}") | + | |
- | + | if ($4 == "AUDIO" && $2 == iFileIn && $3 == iMapAudio) | |
+ | {printf "%s - %s" ,$5,iFileIn} | ||
+ | |||
+ | }' <<< "${stream}") | ||
+ | |||
+ | languageISO=$(awk -v iFileIn="${iFileIn}" -v iMapAudio="${iMapAudio}" -F [\|] '{ | ||
+ | |||
+ | if ($4 == "AUDIO" && $2 == iFileIn && $3 == iMapAudio) | ||
+ | {printf "%s" ,$7} | ||
+ | |||
+ | }' <<< "${stream}") | ||
+ | |||
PROFIL | PROFIL | ||
QUALITY_AUDIO | QUALITY_AUDIO | ||
- | |||
- | |||
- | #cdeQualityAudio=(-b:a "${rateTotal}k") ## TEST | ||
- | |||
- | |||
- | |||
- | |||
- | |||
cdeAudio=(${cdeAudio[@]} -map ${iMapAudio} -metadata:s:a:${numAudio} language="${languageISO}" -c:a ${cAudio} ${cdeQualityAudio[@]} ${channel[@]} -cutoff 20000) | cdeAudio=(${cdeAudio[@]} -map ${iMapAudio} -metadata:s:a:${numAudio} language="${languageISO}" -c:a ${cAudio} ${cdeQualityAudio[@]} ${channel[@]} -cutoff 20000) | ||
((numAudio+=1)) | ((numAudio+=1)) | ||
Ligne 800: | Ligne 968: | ||
cdeQualityAudio=() | cdeQualityAudio=() | ||
- | elif [[ "${typeRate}" == "CBR" ]]; then | + | elif [[ "${quality}" == "Excellente" ]]; then |
- | + | ||
- | if [[ "${quality}" == "Excellente" ]] && [[ "${rateTotal}" -gt "320" ]]; then | + | if [[ "${rateTotal}" -gt "320" ]]; then |
cdeQualityAudio=(${qAudio1[@]}) | cdeQualityAudio=(${qAudio1[@]}) | ||
+ | |||
+ | elif [[ "${codecAudioIn}" == "${codecAudioOut}" ]]; then | ||
+ | cAudio="copy" | ||
+ | cdeQualityAudio=() | ||
+ | else | ||
+ | cdeQualityAudio=(-b:a "${rateTotal}k") | ||
+ | fi | ||
+ | |||
+ | elif [[ "${quality}" == "Elevée" ]]; then | ||
- | elif [[ "${quality}" == "Elevée" ]] && [[ "${rateTotal}" -gt "256" ]]; then | + | if [[ "${rateTotal}" -gt "256" ]]; then |
cdeQualityAudio=(${qAudio2[@]}) | cdeQualityAudio=(${qAudio2[@]}) | ||
- | + | ||
- | elif [[ "${quality}" == "Moyenne" ]] && [[ "${rateTotal}" -gt "192" ]]; then | + | elif [[ "${codecAudioIn}" == "${codecAudioOut}" ]]; then |
+ | cAudio="copy" | ||
+ | cdeQualityAudio=() | ||
+ | else | ||
+ | cdeQualityAudio=(-b:a "${rateTotal}k") | ||
+ | fi | ||
+ | |||
+ | elif [[ "${quality}" == "Moyenne" ]]; then | ||
+ | if [[ "${rateTotal}" -gt "192" ]]; then | ||
cdeQualityAudio=(${qAudio3[@]}) | cdeQualityAudio=(${qAudio3[@]}) | ||
- | + | ||
- | elif [[ "${quality}" == "Minimum" ]] && [[ "${rateTotal}" -gt "128" ]]; then | + | elif [[ "${codecAudioIn}" == "${codecAudioOut}" ]]; then |
+ | cAudio="copy" | ||
+ | cdeQualityAudio=() | ||
+ | else | ||
+ | cdeQualityAudio=(-b:a "${rateTotal}k") | ||
+ | fi | ||
+ | |||
+ | elif [[ "${quality}" == "Minimum" ]]; then | ||
+ | if [[ "${rateTotal}" -gt "128" ]]; then | ||
cdeQualityAudio=(${qAudio4[@]}) | cdeQualityAudio=(${qAudio4[@]}) | ||
- | + | ||
- | elif [[ "${quality}" == "Faible" ]] && [[ "${rateTotal}" -gt "64" ]]; then | + | elif [[ "${codecAudioIn}" == "${codecAudioOut}" ]]; then |
- | cdeQualityAudio=(${qAudio5[@]}) | + | cAudio="copy" |
- | + | cdeQualityAudio=() | |
else | else | ||
- | + | cdeQualityAudio=(-b:a "${rateTotal}k") | |
- | if [[ "${codecAudioIn}" == "${codecAudioOut}" ]]; then | + | |
- | cAudio="copy" | + | |
- | cdeQualityAudio=() | + | |
- | + | ||
- | else | + | |
- | cdeQualityAudio=(-b:a "${rateTotal}k") | + | |
- | fi | + | |
- | + | ||
fi | fi | ||
- | + | ||
- | elif [[ "${typeRate}" == "VBR" ]]; then | + | elif [[ "${quality}" == "Faible" ]]; then |
- | + | if [[ "${rateTotal}" -gt "64" ]]; then | |
- | if [[ "${quality}" == "Excellente" ]]; then | + | |
- | cdeQualityAudio=(${qAudio1[@]}) | + | |
- | + | ||
- | elif [[ "${quality}" == "Elevée" ]]; then | + | |
- | cdeQualityAudio=(${qAudio2[@]}) | + | |
- | + | ||
- | elif [[ "${quality}" == "Moyenne" ]]; then | + | |
- | cdeQualityAudio=(${qAudio3[@]}) | + | |
- | + | ||
- | elif [[ "${quality}" == "Minimum" ]]; then | + | |
- | cdeQualityAudio=(${qAudio4[@]}) | + | |
- | + | ||
- | elif [[ "${quality}" == "Faible" ]]; then | + | |
cdeQualityAudio=(${qAudio5[@]}) | cdeQualityAudio=(${qAudio5[@]}) | ||
- | + | ||
+ | elif [[ "${codecAudioIn}" == "${codecAudioOut}" ]]; then | ||
+ | cAudio="copy" | ||
+ | cdeQualityAudio=() | ||
+ | |||
+ | else | ||
+ | cdeQualityAudio=(-b:a "${rateTotal}k") | ||
fi | fi | ||
fi | fi | ||
- | |||
- | |||
- | #cdeQualityAudio=(-b:a "${rateTotal}k") ## TEST | ||
- | |||
echo "typeRate: ${typeRate}" ## TEST | echo "typeRate: ${typeRate}" ## TEST | ||
Ligne 861: | Ligne 1035: | ||
function FFMPEG_OUT() | function FFMPEG_OUT() | ||
{ | { | ||
- | |||
- | |||
# Si fichier exsite déjà ajoute "copie" et numéro de la copie | # Si fichier exsite déjà ajoute "copie" et numéro de la copie | ||
nbrCopie="1" | nbrCopie="1" | ||
Ligne 949: | Ligne 1121: | ||
else [[ "${typeImage}" == "Other" ]] | else [[ "${typeImage}" == "Other" ]] | ||
typeImage="0" | typeImage="0" | ||
- | |||
- | |||
- | |||
fi | fi | ||
# Ajout de l'image au fichier audio | # Ajout de l'image au fichier audio | ||
metaflac --import-picture-from="${typeImage}||${nameImage}||${dossierTmp}/${nameImage}.${codecVideoIn}" "${dirOut}/${fileName}.${conteneur}" | metaflac --import-picture-from="${typeImage}||${nameImage}||${dossierTmp}/${nameImage}.${codecVideoIn}" "${dirOut}/${fileName}.${conteneur}" | ||
- | |||
} | } | ||
#=========================================================================================================== | #=========================================================================================================== | ||
Ligne 1093: | Ligne 1261: | ||
elif [[ "${status}" -eq "0" ]]; then | elif [[ "${status}" -eq "0" ]]; then | ||
SAVE | SAVE | ||
- | #STREAM | ||
MAIN | MAIN | ||
- | |||
fi | fi | ||
Ligne 1111: | Ligne 1277: | ||
elif [[ "${status}" -eq "2" ]]; then | elif [[ "${status}" -eq "2" ]]; then | ||
MAIN | MAIN | ||
+ | |||
- | # YADSOURCE choix "Fichier" | + | # YADSOURCE choix "Fichier avec analyse" |
- | elif [[ "${source}" == "Fichier" ]]; then | + | elif [[ "${source}" == "Fichier avec analyse" ]]; then |
YADFILE | YADFILE | ||
+ | |||
+ | # Si dossier selectionner, liste les fichiers contenu du dossier | ||
+ | [[ -d "${fileIn}" ]] && fileIn=$(ls "${fileIn}"/*) | ||
# YADFILE Bouton "Quitter" ou "Croix fenêtre" | # YADFILE Bouton "Quitter" ou "Croix fenêtre" | ||
Ligne 1127: | Ligne 1297: | ||
# YADFILE Bouton "Valider" | # YADFILE Bouton "Valider" | ||
elif [[ "${status}" -eq "0" ]]; then | elif [[ "${status}" -eq "0" ]]; then | ||
- | STREAM | + | |
+ | STREAM | YADPROGRESS | ||
+ | |||
+ | IFS=$'\n' | ||
+ | TabYadStream=($(cat "${dossierTmp}/yadStream.txt")) | ||
+ | rm "${dossierTmp}/yadStream.txt" | ||
+ | |||
MAIN | MAIN | ||
fi | fi | ||
+ | |||
+ | # YADSOURCE choix "Fichier" | ||
+ | elif [[ "${source}" == "Fichier" ]]; then | ||
+ | YADFILE | ||
+ | |||
+ | # Si dossier selectionner, liste les fichiers contenu du dossier | ||
+ | [[ -d "${fileIn}" ]] && fileIn=$(ls "${fileIn}"/*) | ||
+ | # YADFILE Bouton "Quitter" ou "Croix fenêtre" | ||
+ | if [[ "${status}" -eq "1" ]] || [[ "${status}" -eq "252" ]]; then | ||
+ | rm -rf "${dossierTmp}" | ||
+ | exit | ||
+ | |||
+ | # YADFILE Bouton "Annuler" | ||
+ | elif [[ "${status}" -eq "2" ]]; then | ||
+ | MAIN | ||
+ | |||
+ | # YADFILE Bouton "Valider" | ||
+ | elif [[ "${status}" -eq "0" ]]; then | ||
+ | STREAM_SIMPLE | YADPROGRESS | ||
+ | |||
+ | IFS=$'\n' | ||
+ | TabYadStream=($(cat "${dossierTmp}/yadStream.txt")) | ||
+ | rm "${dossierTmp}/yadStream.txt" | ||
+ | |||
+ | MAIN | ||
+ | fi | ||
+ | |||
# YADSOURCE choix "DVD" | # YADSOURCE choix "DVD" | ||
elif [[ "${source}" == "DVD" ]]; then | elif [[ "${source}" == "DVD" ]]; then | ||
Ligne 1144: | Ligne 1347: | ||
fi | fi | ||
- | + | ||
# YADMAIN Bouton "Lancer conversion" | # YADMAIN Bouton "Lancer conversion" | ||
elif [[ "${status}" -eq "0" ]]; then | elif [[ "${status}" -eq "0" ]]; then | ||
SAVE | SAVE | ||
- | + | ||
- | # Récupération de la valeur TRUE et FALSE depuis YADMAIN et fusion avec les données du fichier stream.txt | + | if [[ "${source}" == "Fichier avec analyse" ]]; then |
- | IFS=$"|" | + | # Récupération de la valeur TRUE et FALSE depuis YADMAIN et fusion avec les données du fichier stream.txt |
- | numLine="4" | + | IFS=$"|" |
- | stream=$( | + | numLine="4" # Ligne 4 première ligne avec valeur TRUE ou FALSE |
- | while read line; do | + | stream=$( |
- | bol=$(awk 'NR == '${numLine}' {printf "%s" ,$1}' <<< "$(printf "%s\n" ${yadMain} | awk NF)") | + | while read line; do |
- | printf "${bol}${line}\n" | + | bol=$(awk 'NR == '${numLine}' {printf "%s" ,$1}' <<< "$(printf "%s\n" ${yadMain} | awk NF)") |
- | ((numLine+=1)) | + | printf "${bol}${line}\n" |
- | done <<< $(cat "${dossierTmp}/stream.txt") | awk -F [\|] '{if ($1 ~ /TRUE/) {print $0}}') | + | ((numLine+=1)) |
- | + | done <<< $(cat "${dossierTmp}/stream.txt") | awk -F [\|] '{if ($1 ~ /TRUE/) {print $0}}') | |
- | SAVE | + | |
- | FFMPEG | + | SAVE |
- | MAIN | + | FFMPEG |
- | + | MAIN | |
+ | |||
+ | elif [[ "${source}" == "Fichier" ]]; then | ||
+ | |||
+ | SAVE | ||
+ | FFMPEG_SIMPLE | ||
+ | MAIN | ||
+ | fi | ||
fi | fi | ||
} | } | ||
#=========================================================================================================== | #=========================================================================================================== | ||
CONFIGURATION | CONFIGURATION | ||
+ | |||
+ | #fileIn="/home/$USER/Bureau/0in.m4a" ## TEST | ||
+ | #STREAM ## TEST | ||
+ | |||
MAIN | MAIN | ||
+ | |||
+ | |||
+ | |||
</code> | </code> | ||