I have an audio file which has both leading and trailing silence and with the following specifics:
Codec: MPEG AAC Audio (mp4a) Channels: Stereo Sample rate: 44100 Hz Bitrate: 253 kbps
I want to remove the silences AND keep the quality intact.
So far I've tried
ffmpeg -i 1.m4a -af silenceremove=1:0.5:0:1:0.5:0 2.m4a
This is supposed to remove both the leading and trailing silences. But for some reason it doesn't remove the trailing silence. This seems to be a recurring problem. Found the following on another forum.
http://ffmpeg-users.933282.n4.nabble.com/How-to-delete-digital-silence-tp4667256p4667356.html
Also, ffmpeg reduces the bitrate to 128kbps. This I could fix by adding -ab 253k and making the command:
ffmpeg -i 1.m4a -af silenceremove=1:0.5:0:1:0.5:0 -ab 253k 3.m4a
Now the problem is that the trailing silence isn't removed and when I want to process a batch of files I can't use the same bitrate (like 253kbps ) for every file. I'd like to know how VBR could be used for this case.
I know I can use sox and use the silence and reverse features to trim the silences.
http://digitalcardboard.com/blog/2009/08/25/the-sox-of-silence "Example 3 in this post"
But sox has the following problems:
- It can't handle m4a files, I had to convert all files to mp3.
When using the silence filter in sox it caps the bitrate at 128kbps.
sox 1.mp3 2.mp3 silence 1 0.5 1% reverse silence 1 0.5 1% reverse