Skip to content

Instantly share code, notes, and snippets.

@aleksas
Last active December 15, 2021 20:15
Show Gist options
  • Save aleksas/19e7513acbb6e94bc2ddaa0247d9c179 to your computer and use it in GitHub Desktop.
Save aleksas/19e7513acbb6e94bc2ddaa0247d9c179 to your computer and use it in GitHub Desktop.
FFMPEG trim silence from audio files and concatenate them with specified lengh silence interval.
#!/bin/sh
in_1_fname=./wavefile1.wav
in_2_fname=./wavefile2.wav
out_fname=./out.wav
threshold=-50dB
pause=1.5 # seconds
ffmpeg -loglevel verbose -y \
-i $in_1_fname -i $in_2_fname -filter_complex \
"\
[0:a] silenceremove=stop_periods=1:stop_duration=1:stop_threshold=$threshold [first],\
[1:a] silenceremove=start_periods=1:start_duration=0:start_threshold=$threshold [second],\
aevalsrc=exprs=0:d=$pause[silence],\
[first] [silence] [second] concat=n=3:v=0:a=1[outa]\
" \
-map [outa] $out_fname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment