Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement