[MPlayer-users] avi cut and A/V sync
Alexander Roalter
roalter at cs.tum.edu
Fri Sep 30 12:30:23 CEST 2005
Kovács Gábor wrote:
> Hi all,
>
> I'm capturing from my tv card with mencoder to avi files
> mpeg-4 video (libavcodec)
> mpeg-4 audio (faac)
> and everything is ok.
>
> But when I want to cut/extract a part of those files, the
> A/V gets out of sync if I use the -ss option. Audio is
> offset one second in advance of the video.
>
> The command line is:
> mencoder tvcapture_20050930-0836.avi -ss 1:00 -endpos 1:00
> -o cut1.avi -oac copy -ovc copy
>
> This is very fast, but has the above mentioned error.
> If I reencode the audio with the following command, the A/V
> sync is fine, but takes a LOT longer to process:
>
> mencoder tvcapture_20050930-0836.avi -ss 1:00 -endpos 1:00
> -o cut2.avi -oac faac -faacopts br=128:mpeg=4:object=1 -ovc copy
>
> I've also tried capturing the audio to mp3, and then doing
> the same (with the -ss option), and that also produces the
> same A/V desynchronization, so I assume this is not related
> to the audio codec.
>
> Has anyone encountered this problem, and know how to fix it
> so that copy (-ss) will produce the right result?
> Alternatively, if anyone can confirm that this is a bug..
> how can we get it fixed? :)
Although I'm not into the TV recording stuff, from the line you wrote
above it seems you're recording digitally broadcasted TV, which doesn't
have to be encoded again (since it already arrives as MPEG2-Stream via
satellite/cable/air).
One drawback with this solution is that (to my knowledge) the GOPs are
much larger than on say DVDs, and the audio can diverge up to one second
(or more ???) from the accoding video image, but if played correctly,
the sync is maintained via some specific offset applied to it, whatever.
I read something about it ca. one and half a year ago in german computer
magazine c't, but there should be other sources available on the net.
Your second solution reencodes the entire stream thus assuring the video
is in (perfect) sync with the audio.
I don't know how to do this, but completely reencoding should not be
necessary, but a new MPEG structure should be created with the right
amount of GOPs and tooling around with the audio packet positions, which
should be much faster than reencoding, and almost as fast as the direct
copy.
hth,
Alex
More information about the MPlayer-users
mailing list