[Libav-user] muxer ignoring my PTS audio values
Michael R. Hines
michael at hinespot.com
Wed Jan 2 19:40:10 CET 2013
So, for the uneducated (like myself), the problem was that I was not
using a *actual* container to encapsulate my audio/video streams.
For example, if you make a call like this, for example:
avformat_alloc_output_context2(&ctx->outAudioFormatCtx, NULL, "ac3",
or avformat_alloc_output_context2(&ctx->outAudioFormatCtx, NULL,
.... the libraries happily go ahead and succeed with the understanding
"Oh, you don't want to use a container?
No problem - we'll just dump your packets to a file without any
This is easily fixed by using a TS container like this:
avformat_alloc_output_context2(&ctx->outAudioFormatCtx, NULL, "mpegts",
Followed by the approriate libav functions to open the *exact* codecs
that you wanted.
Ideally, the libraries should at least print a message that says:
"Warning! Your AVFormatContext does not use a container. Be warned!"
Or something threatening like that........
Is that an accurate observation?
On Mon, 2012-12-31 at 21:36 -0500, Michael R. Hines wrote:
> Following a few previous posts on libav-user, I've been trying to get
> my audio and video synchronized using the dranger tutorial.
> I'm transcoding (from mpeg2/ac3 to h264/ac3) to make a Blu-ray disc.
> So, I scrounged up some code from the tutorial and this mailing list
> and everything seems to be fine, except for the audio sync.
> In my case, I'm just copying the audio packets (not decoding them).
> Similar to this post:
> I noticed the the audio packets are always off from the video by a
> constant factor when I try to play the video.
> So, naturally, I tried a binary search by "tweaking" the PTS value
> by fixed offsets.
> But when I validate the PTS values with "ffprobe -show_packets", the
> muxer did not use the PTS values that I choose.
> Instead, the PTS values start from zero and continue up rather than
> the values I chose.
> The muxer did not print any errors - it wrote the "copied"
> audio packets just fine - so I assumed my chosen PTS values would
> have been written to.
> Playing the audio on my desktop also works fine - it's just that
> it has the wrong PTS values.
> Is there something I need to do to "make" the muxer respect the
> values I've chosen?
> - Michael
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libav-user