zefie icon

split audio by time

zefie | PRO | 11/24/22 05:45:39 PM UTC (Edited) | 0 ⭐ | 7170 👁️ | Never ⏰ | []
Winbatch |

1.17 KB

|

None

|

0 👍

/

0 👎

@echo off
setlocal EnableDelayedExpansion
 
rem Update these paths as needed
set FFMPEG=C:\bin\foobar2000\encoders\x64\ffmpeg.exe
set SOX=C:\bin\foobar2000\encoders\sox\sox.exe
 
rem Usage: slice.bat pathtofile.ext sec
rem Example: slice.bat music.wav 16
 
rem clean old data
del *.wav
del *.flac
 
if %2==element (
    set splittime=13.71
) else (
    if %2==lunar160 (
        set splittime=6
    ) else (
        set splittime=%2
    )
)
 
echo Easy Cheesy Loopy Peasy
echo Splitting %1 into slices (Segment Time: !splittime!) ...
 
rem Convert to WAV
if %~x1==".mp3" (
    set FILTER=-af "silenceremove=start_periods=1:start_duration=1:start_threshold=-60dB:detection=peak,aformat=dblp,areverse,silenceremove=start_periods=1:start_duration=1:start_threshold=-60dB:detection=peak,aformat=dblp,areverse"
)
%FFMPEG% -loglevel quiet -i %1 -c:a pcm_s24le -ac 2 -ar 48000 %FILTER% temp.wav
 
rem Use sox for accurate time splitting
%SOX% temp.wav slice.wav trim 0 !splittime! : newfile : restart
del temp.wav
 
rem Encode FLAC
for /f "delims=" %%D in ('dir /b *.wav') do (
    echo Converting %%D to flac ...
    C:\bin\foobar2000\encoders\x64\flac -8 --totally-silent %%D
    del %%D
)
 
goto :EOF

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎