View Full Version : XviD to h264 encoding problem
odin24
4th May 2008, 15:30
I'm trying to recode a .avi (XviD) to h264 for AVCHD with subtitles, my problem is after the recode the audio has a gradual sync issue, slightly off at the beginning and getting worse at the end. I use AVISynth with MeGui, any ideas where I'm going wrong. The source file has no sync issue.
Thanks,
daanking
10th May 2008, 14:03
I'm currently encoding all my old xvid rips to h264, en have encountered some weird sync issues. I've found different (possible) sources for these problems:
- packed bitstream
- duplicate frames (if using a temporary raw file)
- avisynth's directshowsource() (i'm guessing you have this problem)
- general weirdness possibly resulting from avisynth or mplayer (i still had issues when i came up with the solution below)
I found one way of avoiding the problems, which i have been using for a month now without any syncing issues. It takes a lot more time and disk size to encode, but since I'm not always checking my encodes, I just want a method to guarantee sync. I would hate to find out about a sync issue after a week of encoding...
Anyway, the thing i do is as follows:
- Use mencoder to encode to lossless ffv1 video codec and pcm audio (use format=i420 and harddup)
- Rip audio to wav using mplayer
- Encode wav to aac using Nero
- Use avisynth avisource() to open the video
- Encode with x264
- Mux using mkvmerge
Of course, this is all in a .bat file looping over all files i want encoded. Maybe some of the steps can be skipped or sped up, but actually I'm pretty tired of fooling around and just stick with this tried and tested method. As a bonus, you can use both mplayer and avisynth video filters (i suggest cropping and resizing at the mencoder step to keep the ffv1 file size down). Also, since all temporary files are lossless, no artifacts are introduced.
A small batch file would be, without any filters (note that my batch file is a lot more complicated, automatically adjusting sizes and such...):
mencoder -channels 2 -vf harddup,format=i420 -ovc lavc -lavcopts vcodec=ffv1 -oac pcm input.avi -o video.avi
mplayer -vo null -vc null -ao pcm:fast video.avi
neroAacEnc_SSE -2pass -br 48000 -if audiodump.wav -of audio.mp4
echo AviSource("video.avi",audio=false) >> temp.avs
x264.exe OPTIONS temp.avs
mkvmerge -o output.mkv video.mkv audio.mp4
rm video.mkv
rm audio.mp4
rm audiodump.wav
rm temp.avs
Might need some " here and there to make it work but this is the general idea. I'm confident that using this, you never encounter any sync issues at all!
[P]ako
11th May 2008, 03:28
Check the FPS for both, the source and the final.
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.