Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 javascript that records video from a webcam as webm and audio from microphone as wav together. I am encoding these webm and wave files to generate a mp4 file using ffmpeg/avconv. But i've noticed a small differrence in length of audio and length of video which makes the output out of sync.

I tried the async/asyncts option, but i've noticed no differrence in output, still out of sync

ffmpeg -async 1 -y -i audio.wav -i  video.webm -vcodec libx264 output.mp4

I tried using areasample filter with avconv gave me error

No such filter: 'areasample'
Error opening filters!


avconv -y -i audio.wav -i  video.webm -vcodec libx264 -filter "areasample=asyncts:compensate" output.mp4

How can i make the video in sync?


My audio length is less than that of video. I'm using the command ffmpeg -itsoffset -00:00:01 -y -i audio.wav -i video.webm -vcodec libx264 output.mp4 to make them in sync. But I'm not sure there will be a 1 sec difference always. So I'm looking for a solution that could manage this dynamically(add the offset for missing audio length).

share|improve this question
You mean aresample (from "re-sample")? – slhck Nov 27 '13 at 12:19
sorry. i don't know about that, all these stuffs are new to me .. – Khaleel Nov 27 '13 at 12:55
@slhck i tried with aresample and got No such filter: 'aresample' – Khaleel Nov 27 '13 at 13:04
You haven't given a lot of information. If your ffmpeg is too old, it will not have the filter. Also, asyncts is another filter, so the syntax looks a little off to me. Can you please include the full, uncut output of both commands? – slhck Nov 27 '13 at 13:26
up vote 4 down vote accepted

Option -async help only if you have timestamps in your audio and video streams. I doubt you have it. Tha's why you don't see any difference in output.

So probably your problem is that video and audio have different duration and start time. If it's so you should trim your audio or video stream (it depends whether your audio or video is longer).

You have not specified which one is longer and what is out of sync time in seconds. So I've give an example. Let's assume you have your audio early by 0.5 sec. Then you should run:

ffmpeg -i audio.wav -af "atrim=start=0.5" -i video.webm -vcodec libx264 output.mp4

P.S. use ffmpeg from git or find latest package for your OS.

Update: Ffmpeg does not have any information about which audio package is should be displayed at the same time as some video frame. You should use some container that have timestampts in streams like mpegts, not wav.

share|improve this answer
The Updated message was the most usefull. Thanks. – Vyacheslav Jan 3 '15 at 8:03

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.