[FFmpeg-user] mpeg-ts to mkv without sound delay

Peter Bašista pbasista at gmail.com
Sat May 21 17:07:11 CEST 2011


> Hi everyone,
>
> I wood like to change the container of some videos I record with my TV, and
> compress it for archiving purpose.
> The container is mpeg-ts, the video codec is h264 and the audio one is mp2.
> I wood like mkv, h264, aac. I also want the video stream to be more
> compress.

We seem to have similar goals :)

> So the first step is to change the container, I try :
>
> ffmpeg -i test.ts -vcodec copy -acodec copy movie.mkv
>
>  The process run normally except this message :
>
> [NULL @ 0x645bb0]missing picture in access unit
>
> The output file is fine but there is a delay between sound and video.

Can you be more specific? If I do the same thing with my captured
mpeg-ts file, I have no delay at all. Only for the first a few seconds
after the playback starts, there is an audio delay, but it is
continuously fading away and after about 10 seconds, everything is in
sync.

A piece from mplayer's status line:
A:   1.9 V:   3.4 A-V: -1.534

That is, I suppose, mplayer's issue. It is just not able to sync audio
and video from this file immediately after the start of the playback.
But then it all plays in sync. I don't think the reason is that the
audio and video are not synchronized in the resulting file.

> So my questions are :
>
>    1. How to avoid this delay ?

Explain in more detail what kind of delay you experience.

>    2. How to compress more the video stream ? Maybe try with a
>    different bitrate ? Is there a way to automatically choose a suitable
>    bitrate?

I do not have any bright ideas about that. However, since the source
is h264, I would try very hard to avoid reencoding, unless it is
absolutely necessary. I don't know how much you care about the
resulting file size, but I doubt that you can achieve significant file
size reduction (say, 50%) while maintaining the video quality. On the
other hand, I may be wrong. I am no expert in this field.

Another question is whether it is worth to reencode the video if you
know that it will reduce its size only by, say 20%. Would you sitll
want to do it? Most of the time, I would not.

>    3. To change the audio codec -acodec aac will be ok ?

This will only work if you add -strict experimental to your command
line. I do not have any experience with that, but you can also use the
non experimental codec libfaac.

Peter Basista


More information about the ffmpeg-user mailing list