Audio and video not sync
Moderator: HuggiL
Audio and video not sync
When I use h.264 video and nero aac target quality, then audio is not sync with video. Container I use is .mkv or .mp4. How to fix this?
Simple solution, do not use -nosound when encoding the video. The encoded video stream will get variable audio desync if there is no audio stream during the video encoding process.
Lengthy explanation as follows:
Lengthy explanation as follows:
14.1.11. Audio wrote: Do not use -nosound when encoding a file with audio, even if you will be encoding and muxing audio separately later. Though it may work in ideal cases, using -nosound is likely to hide some problems in your encoding command line setting. In other words, having a soundtrack during your encode assures you that, provided you do not see messages such as “Too many audio packets in the buffer”, you will be able to get proper sync.
You need to have MEncoder process the sound. You can for example copy the orignal soundtrack during the encode with -oac copy or convert it to a "light" 4 kHz mono WAV PCM with -oac pcm -channels 1 -srate 4000. Otherwise, in some cases, it will generate a video file that will not sync with the audio. Such cases are when the number of video frames in the source file does not match up to the total length of audio frames or whenever there are discontinuities/splices where there are missing or extra audio frames. The correct way to handle this kind of problem is to insert silence or cut audio at these points. However MPlayer cannot do that, so if you demux the AC3 audio and encode it with a separate app (or dump it to PCM with MPlayer), the splices will be left incorrect and the only way to correct them is to drop/dup video frames at the splice. As long as MEncoder sees the audio when it is encoding the video, it can do this dropping/duping (which is usually OK since it takes place at full black/scenechange, but if MEncoder cannot see the audio, it will just process all frames as-is and they will not fit the final audio stream when you for example merge your audio and video track into a Matroska file.
Re: Audio and video not sync
Have u tried specifying fps.triacc wrote:When I use h.264 video and nero aac target quality, then audio is not sync with video. Container I use is .mkv or .mp4. How to fix this?
When things work together, things work.
I can't relate directly because I've been using the commandlines (mencoder, oggenc, mkvmerge) lately, instead of MediaCoder. But what I do (to create a x264 + Vorbis MKV) is:
- Use mencoder to extract the audio stream as .wav.
- Encode the .wav file with oggenc.
- Calculate the video bitrate needed by hand: (target size - audio size) / time <- incomplete formula
- Modify the video encoding commandline with the bitrate and replace the '-nosound' parameter with '-oac pcm -channels 1 -srate 4000'.
- Encode with the modified commandline.
- Use mkvmerge to create the MKV from the .ogg and .avi (throw away the dummy pcm audio in the AVI).