Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an AC3 5.1 audio file to which I would like to insert x seconds of silent audio at the beginning. This has nothing to do with video muxing, so itsoffset is useless since it seems to only work with an audio stream accompanying a video one. I would like to achieve this with ffmpeg. Any ideas?

share|improve this question
    
ffmpeg will append or join same codec same rate things? –  Psycogeek Apr 6 '13 at 19:14
    
I suppose... @Psycogeek –  Makaveli84 Apr 6 '13 at 19:21
    
And is it capable of generating a silent audio file of the exact same codec rate and channel? ffmpeg.org/ffmpeg-filters.html#Examples-34 ? Myself I use GUI methods, but doing what your asking should be fairly easy and very fast, as long as the parameters are all the same. Here is where it is shown adding it to a Mov. stackoverflow.com/questions/12368151/… in the answers –  Psycogeek Apr 6 '13 at 20:47
    
Use Ardour to add anything you want. If you want effects as well download the Calf plugins.. –  dashboard Apr 6 '13 at 21:25

2 Answers 2

You can use the aevalsrc audio source filter in ffmpeg as shown in the link Psycogeek provided: adding silent audio to mov in ffmpeg. Modifying the command for 6 channels and a duration of 1 second results in:

ffmpeg -f lavfi -i aevalsrc=0:0:0:0:0:0::duration=1 silence.ac3

Sample rate will default to 44100. You can change it, for example, by appending :sample_rate=48000 to your filter options. Note that the resulting duration may be greater than the specified duration, as the generated audio is always cut at the end of a complete frame.

Now you can concatenate the files using cat (I believe AC-3 is cat friendly, but I may be wrong. Anyway, the output plays fine for me.):

cat silence.ac3 audio.ac3 > combined.ac3

Or you can use the concat protocol:

ffmpeg -i concat:"silence.ac3|audio.ac3" -codec copy combined.ac3

Or you can do everything in one command with the concat filter:

ffmpeg -f lavfi -i aevalsrc=0:0:0:0:0:0::d=1 -i audio.ac3 -filter_complex \
"[0:0] [1:0] concat=n=2:v=0:a=1 [a]" -map [a] combined.ac3

This last example will result in re-encoding, while the other examples will not re-encode.

share|improve this answer
3  
[Parsed_aevalsrc_0 @ 000000000195fec0] This syntax is deprecated. Use '|' to sep arate the list items. New syntax is -i "aevalsrc=0|0|0|0|0|0:d=1" –  anon Mar 2 '14 at 19:24

Do it the easy way using Audacity. Import your audio file into Audacity, click in the audio track where you want to insert your silence, and from the Audacity menu select Generate -> Silence. You can see this illustrated in more detail here.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.