Merge pull request 'Gros changements : automatisation du processus , plus besoin de modifier les commandes manuellement. Il suffit de choisir le nb de SRT externes ou internes au début du script et de bien remplir les champs.' (#128) from BatchMergeSubtitleswithMKVMerge into master
Reviewed-on: #128
This commit is contained in:
commit
6fb044e248
@ -24,8 +24,8 @@
|
||||
## ##
|
||||
##==============================================================================================
|
||||
|
||||
#Set MKVMerge.exe Path
|
||||
$MKVMerge = 'H:\z_MKV\mkvtoolnix\mkvmerge.exe'
|
||||
# Set MKVMerge.exe Path
|
||||
$MKVMerge = "`"H:\z_MKV\mkvtoolnix\mkvmerge.exe`""
|
||||
|
||||
#Set Source and Target directories (Don't put an \ at the end)
|
||||
$sourceDirectory_1 = "PATH_TO_SOURCE_1"
|
||||
@ -33,8 +33,10 @@ $sourceDirectory_2 = "PATH_TO_SOURCE_2"
|
||||
$destinationDirectory = "PATH_TO_DESTINATION"
|
||||
|
||||
# Rename output file with this settings :
|
||||
$chain_to_search = '(.*) - S(\d*)E(\d*) - (.*)x264(.*)'
|
||||
$chain__to_replace = '$1 - S$2E$3 - $4x265-10bits$5--Reencoded'
|
||||
$chain_to_search = '(.*).S(\d*)E(\d*).(.*)H264(.*)'
|
||||
#$chain_to_search = '(\w+)\.S(\d{2})E(\d{2}).720p.(.*)x264(.*)'
|
||||
$chain__to_replace = '$1 (2003) - S$2E$3 - $4x265-10bits$5--Reencoded'
|
||||
|
||||
# The filenames must be like : blabla.S00E00.blabla.H.264.blabla
|
||||
# They will be renamed to : blabla - S00E00 - blabla.x265-10bits.blabla--Reencoded
|
||||
# If you don't want the rename to be made, juste set to '' the variables.
|
||||
@ -42,27 +44,43 @@ $chain__to_replace = '$1 - S$2E$3 - $4x265-10bits$5--Reencoded'
|
||||
|
||||
# Is there an external subtitle ? Set the number of .SRT (0 - 2)
|
||||
# It's exclusive, no internal SUB will be proceed..
|
||||
$NB_External_SUB = 2
|
||||
$NB_External_SUB = 0
|
||||
|
||||
# Extension without the .
|
||||
$MkvExtension = "mkv"
|
||||
#Set Subtitle Extension (Don't add the . before the extension)
|
||||
$SubExtension_1 = 'eng.srt'
|
||||
$SubExtension_1 = 'srt'
|
||||
$SubExtension_2 = 'fre.srt'
|
||||
|
||||
#If source and destination are the same folder, set this to True, Otherwise let it to "False"
|
||||
$merged_SUFFIX_name = "False"
|
||||
|
||||
# Initialization for those 2 variables, do not change them !
|
||||
$MKVMerge_sub_param = ""
|
||||
$MKVMerge_audio_param = ""
|
||||
# ##################
|
||||
|
||||
#### FILE 1 - Keeping all but the video
|
||||
# ================== AUDIO ==================
|
||||
# Track 1 = Audio n°1
|
||||
# Name and language of Audio Track n°1
|
||||
$AudioTrackName_1 = "1:English - DTS-HD MA"
|
||||
$AudioTrackName_1 = "`"1:English - DDP 5.1`""
|
||||
$AudioLang_1 = "1:en"
|
||||
$AudioTrack_1_default = "1:yes"
|
||||
#$file_1_options = "--no-video"
|
||||
# Define track order
|
||||
$track_order = "1:0,0:1"
|
||||
# $MKVMerge_audio_param = '--language', "$AudioLang_1", '--track-name', "$AudioTrackName_1", '--default-track', "$AudioTrack_1_default"
|
||||
$MKVMerge_audio_param = "--language $AudioLang_1 --track-name $AudioTrackName_1 --default-track $AudioTrack_1_default"
|
||||
|
||||
# # Track 2 = Audio n°2
|
||||
# # Name and language of Audio Track n°2
|
||||
# $AudioTrackName_1 = "`"2:English - DDP 5.1`""
|
||||
# $AudioLang_1 = "2:en"
|
||||
# $AudioTrack_1_default = "2:yes"
|
||||
# # Define track order
|
||||
# $track_order = "1:0,0:1,0:2"
|
||||
# $MKVMerge_audio_param += "--language $AudioLang_2 --track-name $AudioTrackName_2 --default-track $AudioTrack_2_default"
|
||||
|
||||
##########################################
|
||||
#### FILE 2 - MKV - Keeping only the video
|
||||
#### $file_2_options = "--no-audio --no-track-tags --no-global-tags"
|
||||
@ -75,7 +93,7 @@ if ( $NB_External_SUB -ne 0 ) {
|
||||
# ================== SUBTITLES ==================
|
||||
# Track 0 = Sub n°1 to keep
|
||||
# Name and language of Subtitle Track n°0 + Sync Value
|
||||
$ExtSubTrackName_1 = "0:English - SRT"
|
||||
$ExtSubTrackName_1 = "`"0:English - SRT`""
|
||||
$ExtSubTrackLang_1 = "0:eng"
|
||||
$ExtSubTrack_1_default = "0:yes"
|
||||
$ExtSub_charset_1 = "0:UTF-8"
|
||||
@ -86,7 +104,7 @@ if ( $NB_External_SUB -ne 0 ) {
|
||||
# ================== SUBTITLES ==================
|
||||
# Track 0 = Sub n°1 to keep
|
||||
# Name and language of Subtitle Track n°0 + Sync Value
|
||||
$ExtSubTrackName_2 = "0:Français - SRT"
|
||||
$ExtSubTrackName_2 = "`"0:Français - SRT`""
|
||||
$ExtSubTrackLang_2 = "0:fr"
|
||||
$ExtSubTrack_2_default = "0:no"
|
||||
$ExtSub_charset_2 = "0:UTF-8"
|
||||
@ -99,25 +117,29 @@ else {
|
||||
# ================== INTERNAL SUBTITLES ==================
|
||||
# Track 2 = Sub n°1 to keep
|
||||
# Name and language of Subtitle Track n°1 + Sync Value
|
||||
# $SubTrackName_1 = "2:English SDH - SRT"
|
||||
# $SubTrackLang_1 = "2:en"
|
||||
# $SubTrack_1_default = "2:yes"
|
||||
# $sub_charset_1 = "2:UTF-8"
|
||||
$SubTrackName_1 = "`"2:English - SRT`""
|
||||
$SubTrackLang_1 = "2:en"
|
||||
$SubTrack_1_default = "2:yes"
|
||||
$sub_charset_1 = "2:UTF-8"
|
||||
# Define track order
|
||||
$track_order += ",0:2"
|
||||
$subtitle_tracks = "2"
|
||||
# $MKVMerge_sub_param = '--sub-charset', "$sub_charset_1", '--language', "$SubTrackLang_1", '--track-name', "$SubTrackName_1", '--default-track', "$SubTrack_1_default"
|
||||
$MKVMerge_sub_param = "--sub-charset $sub_charset_1 --language $SubTrackLang_1 --track-name $SubTrackName_1 --default-track $SubTrack_1_default"
|
||||
|
||||
# Track 3 = Sub n°2 to keep
|
||||
# Name and language of Subtitle Track n°1 + Sync Value
|
||||
$SubTrackName_1 = "3:English SDH - SRT"
|
||||
$SubTrackLang_1 = "3:eng"
|
||||
$SubTrack_1_default = "3:yes"
|
||||
$sub_charset_1 = "3:UTF-8"
|
||||
# $SubTrackName_1 = "3:English SDH - SRT"
|
||||
# $SubTrackLang_1 = "3:eng"
|
||||
# $SubTrack_1_default = "3:yes"
|
||||
# $sub_charset_1 = "3:UTF-8"
|
||||
# # Define track order
|
||||
# $track_order += ",0:3"
|
||||
# $subtitle_tracks = "3"
|
||||
# $MKVMerge_sub_param += "--sub-charset $sub_charset_2 --language $SubTrackLang_2 --track-name $SubTrackName_2 --default-track $SubTrack_2_default"
|
||||
####
|
||||
}
|
||||
## End of part where there is something to change !
|
||||
##==============================================================================================
|
||||
|
||||
# Testing if the Not-Merged folder already exists : if yes, it will be renamed, else it will be created.
|
||||
@ -139,7 +161,6 @@ If(!(test-path $Path_Folder_NotMerged_1)) {
|
||||
#Move-Item -Path $Path_Folder_NotMerged_2 -Destination "$sourceDirectory\Not-Merged--backup" -Verbose
|
||||
}
|
||||
|
||||
|
||||
#Process
|
||||
$MKV_1_List = Get-ChildItem $sourceDirectory_1 -Filter "*.mkv" | ForEach-Object { $_.FullName } | Sort-Object
|
||||
$Count_1 = $MKV_1_List.count
|
||||
@ -209,167 +230,153 @@ Foreach ($MKV_1 in $MKV_1_List) {
|
||||
$MKV_2_name = $FormatName_2.Substring(0,$FormatName_2.Length-($MkvExtension.Length+1))
|
||||
$MKV_2 = $sourceDirectory_2 + "\" + $MKV_2_name + ".$MkvExtension"
|
||||
|
||||
if ( $NB_External_SUB -ne 0 ) {
|
||||
$SRT_1_Name = $MKV_1_name + ".$SubExtension_1"
|
||||
$SRT_1 = $sourceDirectory_1 + "\" + $SRT_1_name
|
||||
$SRT_2_Name = $MKV_1_name + ".$SubExtension_2"
|
||||
$SRT_2 = $sourceDirectory_1 + "\" + $SRT_2_name
|
||||
}
|
||||
# Title for the video track and for the destination file
|
||||
#$VideoTrackName = $MKV_1_name -replace '(.*).S(\d*)E(\d*).(.*)H.264(.*)', '$1 - S$2E$3 - $4x265-10bits$5--Reencoded'
|
||||
$VideoTrackName = $MKV_1_name -replace $chain_to_search, $chain__to_replace
|
||||
$VideoTrackName = "$VideoTrackName"
|
||||
|
||||
#########################################################
|
||||
# Exceptions for some files with other than 2 SRT inside
|
||||
# You must copy paste the default entries set in the begining of this script in the Default section
|
||||
# switch ($MKV_1_name)
|
||||
# {
|
||||
# "FILE-1-blabla"
|
||||
# {
|
||||
# # ================== AUDIO ==================
|
||||
# # Track 1 = Audio n°1
|
||||
# # Name and language of Audio Track n°1
|
||||
# $AudioTrackName_1 = "1:English - DDP 5.1"
|
||||
# $AudioLang_1 = "1:en"
|
||||
# $AudioTrack_1_default = "1:yes"
|
||||
switch ($MKV_1_name)
|
||||
{
|
||||
"Defiance.S03E01E02.720p.The World We Seize.HDTV.X264-DIMENSION"
|
||||
{
|
||||
# # ================== AUDIO ==================
|
||||
# # Track 1 = Audio n°1
|
||||
# # Name and language of Audio Track n°1
|
||||
# $AudioTrackName_1 = "1:English - DDP 5.1"
|
||||
# $AudioLang_1 = "1:en"
|
||||
# $AudioTrack_1_default = "1:yes"
|
||||
|
||||
# # Only One subtitle track : n°2
|
||||
# $SubTrackName_1 = "3:English SDH - SRT"
|
||||
# $SubTrackLang_1 = "3:en"
|
||||
# $SubTrack_1_default = "3:yes"
|
||||
# $sub_charset_1 = "3:UTF-8"
|
||||
# # Define track order
|
||||
# $track_order = "1:0,0:1,0:3"
|
||||
# # Define subtitles track to keep
|
||||
# $subtitle_tracks = "3"
|
||||
# break
|
||||
# }
|
||||
# "FILE-2-blabla"
|
||||
# {
|
||||
# # Track 1 = Audio n°1
|
||||
# # Name and language of Audio Track n°1
|
||||
# $AudioTrackName_1 = "1:English - AAC 2.0"
|
||||
# $AudioLang_1 = "1:en"
|
||||
# $AudioTrack_1_default = "1:yes"
|
||||
# # Only One subtitle track : n°2
|
||||
# $SubTrackName_1 = "3:English SDH - SRT"
|
||||
# $SubTrackLang_1 = "3:en"
|
||||
# $SubTrack_1_default = "3:yes"
|
||||
# $sub_charset_1 = "3:UTF-8"
|
||||
# # Define track order
|
||||
# $track_order = "1:0,0:1,0:3"
|
||||
# # Define subtitles track to keep
|
||||
# $subtitle_tracks = "3"
|
||||
|
||||
# # Only One subtitle track : n°2
|
||||
# $SubTrackName_1 = "2:English - SRT"
|
||||
# $SubTrackLang_1 = "2:en"
|
||||
# $SubTrack_1_default = "2:yes"
|
||||
# $sub_charset_1 = "2:UTF-8"
|
||||
# # Define track order
|
||||
# $track_order = "1:0,0:1,0:2"
|
||||
# # Define subtitles track to keep
|
||||
# $subtitle_tracks = "2"
|
||||
# break
|
||||
# }
|
||||
# #Default state
|
||||
# Default
|
||||
# {
|
||||
# # If not an exception, we don't want to modify the variables
|
||||
# $SubTrackName_1 = "3:English SDH - SRT"
|
||||
# $SubTrackLang_1 = "3:eng"
|
||||
# $SubTrack_1_default = "3:yes"
|
||||
# $sub_charset_1 = "3:UTF-8"
|
||||
# # Define track order
|
||||
# $track_order = "1:0,0:1,0:3"
|
||||
# # Define subtitles track to keep
|
||||
# $subtitle_tracks = "3"
|
||||
# break
|
||||
# }
|
||||
# }
|
||||
$VideoTrackName = "Defiance - S03E01-E02 - 720p.HDTV.x265-10bits-DIMENSION--Reencoded"
|
||||
break
|
||||
}
|
||||
"Defiance.S02S02E12-E13.720p.All Things Must Pass--I Almost Prayed.HDTV.x264-KILLERS"
|
||||
{
|
||||
# # Track 1 = Audio n°1
|
||||
# # Name and language of Audio Track n°1
|
||||
# $AudioTrackName_1 = "1:English - AAC 2.0"
|
||||
# $AudioLang_1 = "1:en"
|
||||
# $AudioTrack_1_default = "1:yes"
|
||||
|
||||
# # Only One subtitle track : n°2
|
||||
# $SubTrackName_1 = "2:English - SRT"
|
||||
# $SubTrackLang_1 = "2:en"
|
||||
# $SubTrack_1_default = "2:yes"
|
||||
# $sub_charset_1 = "2:UTF-8"
|
||||
# # Define track order
|
||||
# $track_order = "1:0,0:1,0:2"
|
||||
# # Define subtitles track to keep
|
||||
# $subtitle_tracks = "2"
|
||||
|
||||
$VideoTrackName = "Defiance - S02S02E12-E13 - PROPER.720p.HDTV.x265-10bits-KILLERS--Reencoded"
|
||||
|
||||
break
|
||||
}
|
||||
#Default state
|
||||
Default
|
||||
{
|
||||
# If not an exception, we don't want to modify the variables
|
||||
# $SubTrackName_1 = "3:English SDH - SRT"
|
||||
# $SubTrackLang_1 = "3:eng"
|
||||
# $SubTrack_1_default = "3:yes"
|
||||
# $sub_charset_1 = "3:UTF-8"
|
||||
# # Define track order
|
||||
# $track_order = "1:0,0:1,0:3"
|
||||
# # Define subtitles track to keep
|
||||
# $subtitle_tracks = "3"
|
||||
break
|
||||
}
|
||||
}
|
||||
#########################################################
|
||||
|
||||
|
||||
|
||||
|
||||
#Set Output File Name
|
||||
#$Output = $Name + '___MERGED' + '.mkv'
|
||||
# Set Output File Name
|
||||
If ($merged_SUFFIX_name -eq "True") {
|
||||
$Output = $destinationDirectory + "\" + $VideoTrackName + '___MERGED' + '.mkv'
|
||||
$Output = "`"$Output`""
|
||||
} elseif ($merged_SUFFIX_name -eq "False") {
|
||||
$Output = $destinationDirectory + "\" + $VideoTrackName + '.mkv'
|
||||
# $Output = $destinationDirectory + "\" + $VideoTrackName + '.mkv'
|
||||
$Output = "$destinationDirectory" + "\" + "$VideoTrackName" + ".mkv"
|
||||
$Output = "`"$Output`""
|
||||
} else {
|
||||
write-host "Error in the value of the merged_SUFFIX_name variable. Current value = $merged_SUFFIX_name" -foreground "red"
|
||||
write-host "Should be set to True or False.`nScript is exiting now..." -foreground "white"
|
||||
write-host "Error in the value of the merged_SUFFIX_name variable. Current value = $merged_SUFFIX_name" -ForegroundColor "red"
|
||||
write-host "Should be set to True or False.`nScript is exiting now..." -ForegroundColor "white"
|
||||
Exit
|
||||
}
|
||||
# write-host "Output file will be :" -foreground "white"
|
||||
# write-host "$Output"
|
||||
# write-host "--"
|
||||
# write-host "Output file will be :" -ForegroundColor "white"
|
||||
# write-host "$Output" -ForegroundColor "white"
|
||||
# write-host "--" -ForegroundColor "white"
|
||||
|
||||
#Execute
|
||||
# Keep Audio/Subtitles/tags from MKV_1 + Only video from MKV_2
|
||||
<# Command to edit
|
||||
& $MKVMerge --title "$VideoTrackName" --track-order "$track_order" --subtitle-tracks "$subtitle_tracks" -o "$Output"
|
||||
--no-video
|
||||
--language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default"
|
||||
--sub-charset "$sub_charset_1" --language "$SubTrackLang_1" --track-name "$SubTrackName_1" --default-track "$SubTrack_1_default"
|
||||
--sub-charset "$sub_charset_2" --language "$SubTrackLang_2" --track-name "$SubTrackName_2" --default-track "$SubTrack_2_default"
|
||||
"$MKV_1"
|
||||
-no-audio --no-track-tags --no-global-tags
|
||||
--language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes"
|
||||
"$MKV_2"
|
||||
#>
|
||||
Write-Host "" -ForegroundColor "black" -BackgroundColor "white"
|
||||
Write-Host "Traitement du fichier n° $compteur / $Count_1..." -ForegroundColor "black" -BackgroundColor "white"
|
||||
Write-Host "" -ForegroundColor "black" -BackgroundColor "white"
|
||||
|
||||
if ( $NB_External_SUB -eq 1 ) {
|
||||
<# Command to edit
|
||||
& $MKVMerge --title "$VideoTrackName" --track-order "$track_order" -o "$Output"
|
||||
--no-video --no-subtitles
|
||||
--language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default"
|
||||
--language "$AudioLang_2" --track-name "$AudioTrackName_2" --default-track "$AudioTrack_2_default"
|
||||
|
||||
"$MKV_1"
|
||||
-no-audio --no-track-tags --no-global-tags
|
||||
--language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes"
|
||||
"$MKV_2"
|
||||
--sub-charset "$Extsub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default"
|
||||
"$SRT_1"
|
||||
#>
|
||||
|
||||
& $MKVMerge --title "$VideoTrackName" --track-order "$track_order" -o "$Output" --no-video --no-subtitles --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" "$MKV_2" --sub-charset "$Extsub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default" "$SRT_1"
|
||||
}
|
||||
elseif ( $NB_External_SUB -eq 2 ) {
|
||||
<# Command to edit
|
||||
& $MKVMerge --title "$VideoTrackName" --track-order "$track_order" -o "$Output"
|
||||
--no-video --no-subtitles
|
||||
--language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default"
|
||||
--language "$AudioLang_2" --track-name "$AudioTrackName_2" --default-track "$AudioTrack_2_default"
|
||||
|
||||
"$MKV_1"
|
||||
--no-audio --no-track-tags --no-global-tags
|
||||
--language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes"
|
||||
"$MKV_2"
|
||||
--sub-charset "$Extsub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default"
|
||||
"$SRT_1"
|
||||
--sub-charset "$Extsub_charset_2" --language "$ExtSubTrackLang_2" --track-name "$ExtSubTrackName_2" --default-track "$ExtSubTrack_2_default"
|
||||
"$SRT_2"
|
||||
#>
|
||||
|
||||
# Write-Host "Commande qui va être lancée : " -foreground "green"
|
||||
# Write-Host "MKVMerge --title "$VideoTrackName" --track-order "$track_order" -o "$Output" --no-video --no-subtitles --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --language "$AudioLang_2" --track-name "$AudioTrackName_2" --default-track "$AudioTrack_2_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" "$MKV_2" --sub-charset "$ExtSub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default" "$SRT_1"" -foreground "green"
|
||||
|
||||
|
||||
& $MKVMerge --title "$VideoTrackName" --track-order "$track_order" -o "$Output" --no-video --no-subtitles --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" "$MKV_2" --sub-charset "$ExtSub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default" "$SRT_1" --sub-charset "$ExtSub_charset_2" --language "$ExtSubTrackLang_2" --track-name "$ExtSubTrackName_2" --default-track "$ExtSubTrack_2_default" "$SRT_2"
|
||||
if ( $NB_External_SUB -ne 0 ) {
|
||||
|
||||
}
|
||||
# First external SRT to include
|
||||
$SRT_1_Name = $MKV_1_name + ".$SubExtension_1"
|
||||
$SRT_1 = $sourceDirectory_1 + "\" + $SRT_1_name
|
||||
|
||||
$MKVMerge_param_start = "---output $Output --title `"$VideoTrackName`" --track-order `"$track_order`" --no-video --no-subtitles"
|
||||
$MKVMerge_param_mkv1 = "$MKVMerge_audio_param `"$MKV_1`""
|
||||
$MKVMerge_param_mkv2 = "--no-audio --no-track-tags --no-global-tags --language 0:en --track-name `"0:$VideoTrackName`" --default-track 0:yes --no-subtitles --no-audio `"$MKV_2`""
|
||||
|
||||
$MKVMerge_param_srt1 = "--sub-charset $Extsub_charset_1 --language $ExtSubTrackLang_1 --track-name `"$ExtSubTrackName_1`" --default-track $ExtSubTrack_1_default `"$SRT_1`""
|
||||
|
||||
$MKVMerge_param_srt_all = "$MKVMerge_param_srt1"
|
||||
|
||||
if ( $NB_External_SUB -ne 0 ) {
|
||||
# Second external SRT to include
|
||||
$SRT_2_Name = $MKV_1_name + ".$SubExtension_2"
|
||||
$SRT_2 = $sourceDirectory_1 + "\" + $SRT_2_name
|
||||
|
||||
$MKVMerge_param_srt2 = "--sub-charset $Extsub_charset_2 --language $ExtSubTrackLang_2 --track-name `"$ExtSubTrackName_2`" --default-track $ExtSubTrack_2_default `"$SRT_2`""
|
||||
$MKVMerge_param_srt_all += " $MKVMerge_param_srt2"
|
||||
}
|
||||
|
||||
$MKVMerge_param_all = "$MKVMerge_param_start $MKVMerge_param_mkv1 $MKVMerge_param_mkv2 $MKVMerge_param_srt_all"
|
||||
|
||||
}
|
||||
else {
|
||||
# INTERNAL SUB to keep
|
||||
|
||||
$MKVMerge_param_start = "--output $Output --title `"$VideoTrackName`" --track-order `"$track_order`" --subtitle-tracks $subtitle_tracks --no-video"
|
||||
$MKVMerge_param_mkv1 = "$MKVMerge_audio_param $MKVMerge_sub_param `"$MKV_1`""
|
||||
$MKVMerge_param_mkv2 = "--no-audio --no-track-tags --no-global-tags --language 0:en --track-name `"0:$VideoTrackName`" --default-track 0:yes --no-subtitles --no-audio `"$MKV_2`""
|
||||
|
||||
# two subtiles to keep :
|
||||
#& $MKVMerge --title "$VideoTrackName" --track-order "$track_order" --subtitle-tracks "$subtitle_tracks" -o "$Output" --no-video --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --sub-charset "$sub_charset_1" --language "$SubTrackLang_1" --track-name "$SubTrackName_1" --default-track "$SubTrack_1_default" --sub-charset "$sub_charset_2" --language "$SubTrackLang_2" --track-name "$SubTrackName_2" --default-track "$SubTrack_2_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" --no-subtitles --no-audio "$MKV_2"
|
||||
|
||||
# Only one subtitles to keep
|
||||
& $MKVMerge --title "$VideoTrackName" --track-order "$track_order" --subtitle-tracks "$subtitle_tracks" -o "$Output" --no-video --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --sub-charset "$sub_charset_1" --language "$SubTrackLang_1" --track-name "$SubTrackName_1" --default-track "$SubTrack_1_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" --no-subtitles --no-audio "$MKV_2"
|
||||
|
||||
$MKVMerge_param_all = "$MKVMerge_param_start $MKVMerge_param_mkv1 $MKVMerge_param_mkv2"
|
||||
|
||||
# ##################
|
||||
# Debug
|
||||
# Write-Host "$MKVMerge_param_start" -ForegroundColor "black" -BackgroundColor "DarkGray"
|
||||
# Write-Host "$MKVMerge_audio_param" -ForegroundColor "black" -BackgroundColor "DarkGray"
|
||||
# Write-Host "$MKVMerge_sub_param" -ForegroundColor "black" -BackgroundColor "DarkGray"
|
||||
# Write-Host "$MKVMerge_param_mkv2" -ForegroundColor "black" -BackgroundColor "DarkGray"
|
||||
# Write-Host "" -ForegroundColor "black" -BackgroundColor "DarkGray"
|
||||
# Write-Host "$MKVMerge_param_all" -ForegroundColor "black" -BackgroundColor "DarkGray"
|
||||
# Write-Host "" -ForegroundColor "black" -BackgroundColor "DarkGray"
|
||||
# Write-Host "Commande qui sera lancée :" -ForegroundColor "black" -BackgroundColor "DarkGray"
|
||||
|
||||
# Write-Host "& $MKVMerge" "$MKVMerge_param_all" -ForegroundColor "black" -BackgroundColor "DarkGray"
|
||||
# ##################
|
||||
}
|
||||
|
||||
# Last step to command construction
|
||||
$command = "& $MKVMerge $MKVMerge_param_all"
|
||||
# Launch begin...
|
||||
Invoke-Expression $command
|
||||
|
||||
Write-Host "" -ForegroundColor "black" -BackgroundColor "white"
|
||||
Write-Host "Fin du traitement du fichier n° $compteur / $Count_1." -ForegroundColor "black" -BackgroundColor "white"
|
||||
Write-Host "" -ForegroundColor "black" -BackgroundColor "white"
|
||||
@ -383,21 +390,36 @@ Foreach ($MKV_1 in $MKV_1_List) {
|
||||
Move-Item -Path $MKV_1 -Destination $Path_Folder_NotMerged_1 -Verbose
|
||||
Move-Item -Path $MKV_2 -Destination $Path_Folder_NotMerged_2 -Verbose
|
||||
|
||||
|
||||
if ( $NB_External_SUB -ne 0 ) {
|
||||
Move-Item -Path $SRT_1 -Destination $Path_Folder_NotMerged_1 -Verbose
|
||||
if ( $NB_External_SUB -eq 2 ) {
|
||||
Move-Item -Path $SRT_2 -Destination $Path_Folder_NotMerged_2 -Verbose
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Renaming the output file is not necessary if the output filename doesn't have __MERGED in it
|
||||
#Rename-Item -Path $Output -NewName $MKV -Verbose
|
||||
|
||||
} Else {
|
||||
}
|
||||
Else {
|
||||
write-host "File NON-EXISTANT - $Output" -foreground "red"
|
||||
"File NON-EXISTANT - $Output" | Out-File "$destinationDirectory\Errors.txt" -Append
|
||||
}
|
||||
$compteur++
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
# ##############################
|
||||
# Command History
|
||||
#
|
||||
# internal Subtitles :
|
||||
# two subtiles to keep :
|
||||
#& $MKVMerge --title "$VideoTrackName" --track-order "$track_order" --subtitle-tracks "$subtitle_tracks" -o "$Output" --no-video --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --sub-charset "$sub_charset_1" --language "$SubTrackLang_1" --track-name "$SubTrackName_1" --default-track "$SubTrack_1_default" --sub-charset "$sub_charset_2" --language "$SubTrackLang_2" --track-name "$SubTrackName_2" --default-track "$SubTrack_2_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" --no-subtitles --no-audio "$MKV_2"
|
||||
|
||||
# Only one subtitles to keep
|
||||
# & $MKVMerge --title "$VideoTrackName" --track-order "$track_order" --subtitle-tracks "$subtitle_tracks" -o "$Output" --no-video --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --sub-charset "$sub_charset_1" --language "$SubTrackLang_1" --track-name "$SubTrackName_1" --default-track "$SubTrack_1_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" --no-subtitles --no-audio "$MKV_2"
|
||||
#
|
||||
#
|
||||
# External Subtitles
|
||||
# # 1 SRT
|
||||
# & $MKVMerge --output "$Output" --title "$VideoTrackName" --track-order "$track_order" --no-video --no-subtitles --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" "$MKV_2" --sub-charset "$Extsub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default" "$SRT_1"
|
||||
#
|
||||
# # 2 SRTs
|
||||
# & $MKVMerge --title "$VideoTrackName" --track-order "$track_order" -o "$Output" --no-video --no-subtitles --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" --language "$AudioLang_1" --track-name "$AudioTrackName_1" --default-track "$AudioTrack_1_default" "$MKV_1" --no-audio --no-track-tags --no-global-tags --language "0:en" --track-name "0:$VideoTrackName" --default-track "0:yes" "$MKV_2" --sub-charset "$ExtSub_charset_1" --language "$ExtSubTrackLang_1" --track-name "$ExtSubTrackName_1" --default-track "$ExtSubTrack_1_default" "$SRT_1" --sub-charset "$ExtSub_charset_2" --language "$ExtSubTrackLang_2" --track-name "$ExtSubTrackName_2" --default-track "$ExtSubTrack_2_default" "$SRT_2"
|
Loading…
Reference in New Issue
Block a user