THE ACTUAL SCRIPT:
function getMp3Leange($path)
{
$shell = New-Object -COMObject Shell.Application
$folder = Split-Path $path
$file = Split-Path $path -Leaf
$shellfolder = $shell.Namespace($folder)
$shellfile = $shellfolder.ParseName($file)
$hoch = 2
[int]$mp3Lange = 0
$shellfolder.GetDetailsOf($shellfile, 27) -split ":"|ForEach-Object{$mp3Lange= $mp3Lange + ([int]$_*[math]::pow(60,$hoch));$hoch--}
return $mp3Lange
}
function ffmpeg_caller{
param($datei_FullName=[STRING]"",
$i_minDuraton = [int] 0,
$i_maxDuraton = [int] ($i_minDuraton*1.2)
)
#Start paramter
$PartArr = [System.Collections.ArrayList]@()
$SD_PARAMS ="-55dB:d=0.3"
$paramDB = -20
$w_paramDB = $paramDB
$repeat_search = $true
while($repeat_search){
# working parameter
$StartPart = 0
#$w_paramDB
$silparam = [string]$w_paramDB+"dB:d=0.2"
$repeat_search = $false
C:\ffmpeg\bin\ffmpeg.exe -v warning -i $datei_FullName -af silencedetect=$silparam,ametadata=mode=print:file=-:key=lavfi.silence_start -vn -sn -f s16le -y D:\Mailbox\09_Tools\PS_Scripte\mp3\Tmp_silents_part.txt|
%{ if ($_ -match "start" -and -not $repeat_search){
$text,$time = $_ -split "="
$p_Duration = $time - $StartPart
if($p_Duration -ge $i_minDuraton ){
Write-Host "Gefundene Zeit $p_Duration vergleich mit Schwelle $i_maxDuraton."
if($p_Duration -gt ($i_maxDuraton +10)){
# Stop ffmepg and restart with new parameter
$repeat_search = $true
# editing Parameter
$w_paramDB = [INT]($w_paramDB * 0.90)
Write-Host "New threthold $w_paramDB!"
}else{
Write-Host "duration ok."
$null = $PartArr.Add($time)
$StartPart = $time
} # end max dura
}# end min
}# end pipe
}
}#end while
return $PartArr
}
#>
$t_mp3 = "C:\inTest.mp3" #1h input MP3
getMp3Leange -path $t_mp3
$o_PartArr = ffmpeg_caller -i_minDuraton 180 -datei_FullName $t_mp3 #getSilenceList
$o_path = '"'+(Split-Path $t_mp3) +"\Track03%d.mp3"+ '"'#(Split-Path $t_mp3 -Leaf).Substring(0,(Split-Path $t_mp3 -Leaf).Length -4)+"%03d.mp3"+'"'
$o_path
$segments = ($o_PartArr) -join "," #PartArr | Join-String -Separator ','
$segments
C:\ffmpeg\bin\ffmpeg.exe -i $t_mp3 -f segment -segment_times $segments $o_path
The Output Error is:
"C:\mp3\Track03%d.mp3"
183.278,366.713,547.452,729.559,913.986,1094.58,1278.08,1462.63,1645.03,1829.3,2009.97,2191.22,2372.46,2555.37,2738.9,2919.16,3099.74,3282.06,3463
.24,3646.01,3829.36,4012.69,4194,4375.28,4557,4737.06,4924.8,182.717,366.651,547.198,729.555,913.762,1094.51,1276.73,1457.69,1638.29,1825.49,2006.
11,2186.91,2371.55,2552.35,2734.93,2917.19,3097.53,3280.21,3460.72,3642.22,3824.97,4006.01,4187.38,4370.03,4556.99,4737.05,4924.71,181.699,362.249
,543.036,723.354,906.665,1088.82,1269.36,1449.85,1632.4,1824.88,2006.11,2186.91,2371.43,2552.34,2734.54,2916.13,3096.24,3276.56,3460.02,3641.2,382
2.72,4003.58,4184.35,4366.73,4547.16,4727.22,4909.2,5117.49,5300.67,5481.75,5666.94
C:\ffmpeg\bin\ffmpeg.exe : ffmpeg version 2023-11-09-git-acf63d5350-full_build-www.gyan.dev Copyright (c) 2000-2023 the
FFmpeg developers
In C:\mp3\Split by silence.ps1:77 Zeichen:1
+ C:\ffmpeg\bin\ffmpeg.exe -i $t_mp3 -f segment -se ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (ffmpeg version ...mpeg developers:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect
--enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib
--enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2
--enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e
--enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl
--enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi
--enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid
--enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan
--enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb
--enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc
--enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b
--enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 58. 32.100 / 58. 32.100
libavcodec 60. 33.100 / 60. 33.100
libavformat 60. 17.100 / 60. 17.100
libavdevice 60. 4.100 / 60. 4.100
libavfilter 9. 13.100 / 9. 13.100
libswscale 7. 6.100 / 7. 6.100
libswresample 4. 13.100 / 4. 13.100
libpostproc 57. 4.100 / 57. 4.100
Input #0, mp3, from 'C:\inTest.mp3':
Metadata:
...
date : 2018
Duration: 01:36:22.13, start: 0.025056, bitrate: 160 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 160 kb/s
Metadata:
encoder : LAME3.99r
Side data:
replaygain: track gain - -4.900000, track peak - unknown, album gain - unknown, album peak - unknown,
Stream #0:1: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 2550x2550 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn (attached pic)
Metadata:
comment : Cover (front)
Stream mapping:
Stream #0:1 -> #0:0 (mjpeg (native) -> png (native))
Stream #0:0 -> #0:1 (mp3 (mp3float) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[swscaler @ 000002785e492000] deprecated pixel format used, make sure you did set range correctly
Last message repeated 3 times
[segment @ 000002785e438540] Specified time 182.716995 is smaller than the last time 4924.799805
[out#0/segment @ 000002785e48a340] Could not write header (incorrect codec parameters ?): Invalid argument
Error while filtering: Invalid argument
[out#0/segment @ 000002785e48a340] Nothing was written into output file, because at least one of its streams received no packets.
frame= 0 fps=0.0 q=-0.0 Lsize= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
Conversion failed!
-> Don't know where the error is...