Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a MKV video file. The audio track is ac3. I extracted the AC3 and now want to convert it to Flac. But I need to add a delay/offset of 150ms. The offset should be permanent; the actual duration of the resulting Flac should be 150ms longer than the Ac3 input.

What is the command line to do this?

Thank you in advance.

share|improve this question

I would do it with SoX (Sound eXchange) and ffmpeg (or avconv instead of ffmpeg). SoX is "the Swiss Army knife of audio manipulation", an effects and audio manupilation & generation tool for the command line.

Install both:

sudo apt-get install sox ffmpeg

Convert your ac3 file to a wave file. Since SoX cannot read ac3 files directly, this step is unfortunately required:

ffmpeg -i sound.ac3 sound.wav

Use SoX with the pad switch to insert silence at the beginning:

sox sound.wav sound.flac pad 0.150

This inserts 150ms of silence at the beginning of the audio file.

Look at the SoX Manual for more infos.

You can also do this in a single line, without the need for creating an intermediate wav file, by using a pipe:

ffmpeg -i sound.ac3 -f wav - | sox - sound.flac pad 0.150
share|improve this answer

MediaCoder should be able to handle that.

Do you want to remux the FLAC into the MKV? Otherwise I don't understand why you'd be concerned about the delay.

share|improve this answer
Only works with wine – damien Sep 22 '12 at 0:01

Your Answer


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.