PDA

View Full Version : How do I get audio/video to sync


spottyrover
3rd August 2008, 15:58
any help on how to get the audio/video to sync would be appreciated
In the past I just recorded soccer (football) so syncing was not a big problem.
The information I have found all relates to dvd ripping which I assume is not relevent here.

Now I would like to record and make the ocasional DVD using devede
and editing with kdenlive.
Any sugestions would be appreciated

mencoder -oac mp3lame=1 -fps 25 -ovc x264=1 -x264encopts crf=22:threads=auto -tv driver=v4l2:norm=pal-i:input=1:adevice=/dev/dsp:audiorate=48000:width=384:height=288 -af volume=-7 -endpos 02:15:00 -o /media/sdb1_TV/1_TV/Soccer/soccer-game3.avi tv://

Thanks for your help
Dave

blaz
4th August 2008, 04:56
Not sure if this is what you want to do, but in the past I've fixed some out-of-sync avi files with this:

mencoder -ovc copy -oac copy -audio-delay -0.5 "outofsync.avi" -o "insync.avi"

This delays the video by half a second. +0.5 delays the audio by half a second. You have to play with it to get the right delay value.

robinsonlove
4th August 2008, 09:25
try another avi to dvd decoder to do that again, it depends on your file size or dvd burner quality,

spottyrover
4th August 2008, 09:49
Sorry for not being clear
It is in the initial recording (from the composite input)
The audio/video sync is spot on in the beginning but progressively goes out of sync as the recording goes on. By the time 2 hrs are up the video has stopped talking when the sound starts

Blaz your fix does it just shift the sound/video relation or stretch it?

Thanks for your help guys

Dave

blaz
5th August 2008, 01:02
Sorry for not being clear
It is in the initial recording (from the composite input)
The audio/video sync is spot on in the beginning but progressively goes out of sync as the recording goes on. By the time 2 hrs are up the video has stopped talking when the sound starts

Blaz your fix does it just shift the sound/video relation or stretch it?


Pretty sure -audio-delay just shifts, not stretch.
Sorry, never had this problem.

talen9
5th August 2008, 01:57
Try searching for "sync" into this same forum (Linux, Mac OS X & co.), you'll find more than one asking for solutions to notorious mencoder a/v sync ... like this one (http://forum.doom9.org/showthread.php?t=134896&highlight=sync) or this one (http://forum.doom9.org/showthread.php?t=132655&highlight=sync).

This other one (http://forum.doom9.org/showthread.php?t=122082&highlight=sync) specifically addresses A/V sync problems with mencoder/x264, see if it fits.


Please remember that (generally speaking) an x264 stream in an AVI container is usually not the optimal choice; since MEncoder's internal MP4 muxing is slightly borked (IIRC), maybe you're better stay with AVI, though (please wait for more answers about this matter!).


PS: now that I look better at your command line ... are you definitely sure that your audio sampling frequency is 48000 and not 44100, in a PAL TV recording? Please note that I *never* did any A/V capture, so possibly I'm only saying something very stupid :P

cord-factor
5th August 2008, 16:14
spottyrover, try to record with similar command (DV-Video):
mencoder tv:// -o "capture.dv" -tv input=3:width=720:height=576:audiorate=48000:amode=1:alsa -oac pcm -ovc lavc -lavcopts vcodec=dvvideo -of lavf
After that compress it with your favorites.

It is possible to record with else video codec and file format, but the sound must be PCM.

blaz
5th August 2008, 16:45
Please remember that (generally speaking) an x264 stream in an AVI container is usually not the optimal choice; since MEncoder's internal MP4 muxing is slightly borked (IIRC), maybe you're better stay with AVI, though

Yes, a script like h264enc creates a default avi with mencoder, but then extracts the h264 and audio parts with "MP4Box -aviraw".

It then puts the audio and video back together into containers like mp4, m2ts, mkv using better, container-specific tools, not mencoder.

The avi file with h264 that mencoder creates does play fine with mplayer though!

spottyrover
8th August 2008, 05:17
I tried changin the audio to 44100 but the recorded sound had a noise on top of it.
I will look at the rest of the suggestions tomorrow

Thanks for all of your replys

Dave

mousemurder
12th August 2008, 20:38
theres also avisync

i think part of transcode family...

edit: i think this shifts and not streches also...

have you tried changing the fps ?