[MPlayer-users] Separating audio and video without losing sync?
ticmanis at gmx.de
Tue Apr 12 16:38:59 CEST 2011
Hello Nico and thank you for your reply!
On 04/12/2011 04:13 PM, Nico Sabbi wrote:
> you simply can't. What you are trying to do is to dump separate streams
> which, by definition,
> don't have timestamps AND are asynchronous: in 99.99999999% of cases
> they start from
> different timestamps.
I know, and I just want to find out at WHICH timestamps they start. If I
know this, and if I managed to decode them to a totally constant video
frame rate and audio PCM rate, I can add samples of silence in front of
the decoded audio stream and/or black frames in front of the decoded
video. Then it *should* be easy to fit them together again.
> Since audio streams are always preloaded by some
> hundred milliseconds
> the best approximation you can get is to run some tool that drops as
> many audio frames as necessary
> to resync the two streams, but you will never get to a 0.0 difference...
By dropping single audio samples from the *decoded* audio raw stream, I
should be able to get the difference down to 1/48000 of a second, which
is good enough for me. ;-)
The point is, how do I find out how many samples to drop (or add)? For
that I have to find out the exact timestamps at which the streams start.
Can mencoder or mplayer give me that information? If so, the rest should
be fairly easy.
> let alone that the video stream
> may start with a B or P frame.
The decoded video stream won't. It contains only uncompressed,
independent frames. So any whole number of them can be dropped, or black
> And I didn't take into account DVB streams where timestamps reset often.
Well, I don't need to handle those at the moment.
> forget it:-)
<tantrum> No! No! No, I won't </tantrum> ;-)
> or use the mpeg2 muxer in mencoder (with the right parameters) that does
> all that for you:-)
Yeah, except that I'm hacking at mpeg2enc code... transferring that code
into mencoder would certainly be a major effort, plus I like the
encoding quality of mpeg2enc (if it's allowed to say so on this list).
More information about the MPlayer-users