3 ms·
Cheap and free one-liner to cut silent audio with ffmpeg ffmpeg -i input.mkv -filter_complex "[0:a]silencedetect=n=-90dB:d=0.3[outa]" -map [outa] -f s16le -y /
by rschachte 4y ago
Cheap and free one-liner to cut silent audio with ffmpeg
ffmpeg -i input.mkv -filter_complex "[0:a]silencedetect=n=-90dB:d=0.3[outa]" -map [outa] -f s16le -y /dev/null |& F='-aq 70 -v warning' perl -ne 'INIT { $ss=0; $se=0; } if (/silence_start: (\S+)/) { $ss=$1; $ctr+=1; printf "ffmpeg -nostdin -i input.mkv -ss %f -t %f $ENV{F} -y %03d.mkv\n", $se, ($ss-$se), $ctr; } if (/silence_end: (\S+)/) { $se=$1; } END { printf "ffmpeg -nostdin -i input.mkv -ss %f $ENV{F} -y %03d.mkv\n", $se, $ctr+1; }' | bash -x
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- remram 4y agoThis seems very long considering that there is a built-in filter "silencedetect". Does it only do the detection and then you have to do this Perl loop to do the cutting, parsing a custom format that silencedetects writes?
- dceddia 4y agoYeah, silencedetect only finds the silent parts, it doesn't do any cutting. My first attempt at this problem before Recut was basically this, but in Node, and creating an EDL file. It works fine but the feedback loop is annoyingly long - run the script, import the result into an editor, listen back, realize the silence threshold was too high, try again... so that's what drove me to make an interactive version.