ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Adding silence to audio track?

(1/3) > >>

I have several hour-long audio tracks to which I have to add silence. It should go 30 seconds of music, 30 seconds of silence, and so on, until the end of track.

My first try was Audacity, which can add silence, but I couldn't figure it out how to add it to the whole track in same interval.

Any recommendations?

Someone who uses Audacity or another program may have specific instructions.  In the meantime I would suggest checking the Sourceforge forum for Audacity as someone may have asked the same question.  Also I found a write-up of 25 free audio editors.  One of them may have an automation feature as well as batch processing.

I made a script, try it. It requires Autohotkey and ffmpeg (and ffprobe that is included with ffmpeg).

update: fixed bugs with ffmpeg path (previously only worked when ffmpeg was in same folder as script)

update2: get the newer version here

--- Code: Autohotkey ---#NoEnvSetWorkingDir %A_ScriptDir%#SingleInstance force ;30SecondSilencer;adds 30 seconds silence every 30 seconds to an mp3 file ;-------------------------;CHANGE THESE PARAMETERSsource = C:\folder\some music file.mp3workdir = C:\dir\chunksize = 30     ;length of each silence/music segmentffmpeg = C:\ffmpeg\ffmpeg.exe ;------------------------- ;check pathsSplitPath, source,,, ext, noextSplitPath, ffmpeg,,fdirif !FileExist(source) or !FileExist(workdir) or !FileExist(ffmpeg) or !FileExist(fdir "\ffprobe.exe") exitapp ;Clear old filesFiledelete %workdir%\30ss-silent.mp3Filedelete %workdir%\30ss_*.mp3Filedelete %workdir%\%noext%_30ss.mp3Filedelete %workdir%\30ss_*.txt ;Get source duration in seconds; %comspec% /c ""%fdir%\ffprobe.exe" -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "%source%" >> "%workdir%\30ss_duration.txt""FileRead, dur, %workdir%\30ss_duration.txtlength := Ceil(dur)if !length exitapp ;split source into 30 second mp3 chunks; := Ceil(length / chunksize) ; number of stepsstart = 0ToolTip, Split chunks...sleep 1000Loop, %steps%{c := StrLen(a_index)==1 ? "00" a_index : StrLen(a_index)==2 ? "0" a_index : a_indexRun "%ffmpeg%" -ss %start% -i "%source%" -t %chunksize% "%workdir%\30ss_%c%.mp3" ,,Minstart := start + chunksizeToolTip, %A_index% / %steps%} ToolTip, Processing...  ;wait for ffmpeg to make all chunksLoop{        pcount = 0        for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process")                if InStr(process.Name,"ffmpeg.exe")                 pcount++        if pcount < 1         break        ToolTip Processing %pcount% left        sleep 400} ;make 30 sec silent audio mp3 file;, make silent.mp3sleep 1000RunWait "%ffmpeg%" -f lavfi -i anullsrc -t 30 "%workdir%\30ss-silent.mp3",,Min  ;Concatenate chunks and silence;, Concatenate...Loop, Files, %workdir%\30ss_*.mp3 FileAppend, file '%workdir%\%A_LoopFileName%'`nfile '%workdir%\30ss-silent.mp3'`n, %workdir%\30ss_list.txtRunWait "%ffmpeg%" -nostats -loglevel 0 -f concat -i "%workdir%\30ss_list.txt" -c copy "%workdir%\%noext%_30ss.mp3" ,,Min ;clear chunksFiledelete %workdir%\30ss_*.mp3 ToolTip, Finished!sleep 1000
Out of curiousity what will you use the audio files for? crossfit/interval training perhaps?

Wow, thank you very much!

I've changed lines 10,11 and 13, but run into some trouble:


It is for my mother, she is Physical Education teacher, and among other things holds aerobic classes.

shouldn't the cuts fade in/out, instead of abrupt cutting?  :-\


[0] Message Index

[#] Next page

Go to full version