[Libav-user] Muxing mpeg4-ts and raw audio to AVI file

Nicholas Butts nbutts at appareo.com
Mon Aug 15 15:30:47 CEST 2011


Dmitry Gorbunov wrote:

> Why dts? Because it's more reliable than pts after decoding (I presume you
> avcodec_decode_video on input packet to get raw video frame suitable for
> encoding).

I am not currently using avcodec_decode_video, I don't want to recompress
the image data. I just want to take the MPEG4-TS stream and mux it with raw
audio data. This is the basic flow of the encoding chain:

image sensor -> hardware capture -> hardware codec -> muxed with audio to an
AVI file

I've been assigned the MPEG-4 data directly to AVPacket data pointer and
then calling av_interleaved_write_frame. I can use ffmpeg to extract the
audio and video, so it kinda of works, it just doesn't play back nicely in
mplayer or vlc. I will look more into the dts member.

Thanks.


On Sun, Aug 14, 2011 at 10:53 PM, Dmitry Gorbunov <atskiisotona at gmail.com>wrote:

>
> Nicholas Butts wrote:
> >
> >     if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)
> >         pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base,
> > _videoStream->time_base);
> >
>
> c->coded_frame->pts is a synthetic value produced by video encoder (usually
> 0, 1, 2, 3, etc). It may be good for constant frame rates, but sometimes
> fails even then. And I believe that your case is related to variable frame
> rate. I don't know for sure, but most hardware devices seem to produce
> variable frame rate streams. My two web cameras do that at least.
>
> You should use input_packet.dts (packet you read from input mpeg stream via
> av_read_frame) and rescale it by input_stream->time_base and
> output_stream->time_base:
>
> pkt.pts = av_rescale_q(input_packet.pts, input_stream->time_base,
> output_stream->time_base); // of course condition is not required
>
> Why dts? Because it's more reliable than pts after decoding (I presume you
> avcodec_decode_video on input packet to get raw video frame suitable for
> encoding).
>
> The above solution works for me on my web cameras, I hope it helps you.
>
> --
> View this message in context:
> http://libav-users.943685.n4.nabble.com/Libav-user-Muxing-mpeg4-ts-and-raw-audio-to-AVI-file-tp3740515p3743865.html
> Sent from the libav-users mailing list archive at Nabble.com.
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>



-- 
Nicholas Butts
SENIOR FIRMWARE ENGINEER

Appareo Systems, LLC
1810 NDSU Research Circle N
Fargo, ND 58102

P: (701) 356-2200
F: (701) 356-3157

http://www.appareo.com

nbutts at appareo.com



NOTICE: This message {including attachments} is covered by the Electronic
Communication Privacy Act, 18 U.S.C. sections 2510-2521, is CONFIDENTIAL and
may also be protected by ATTORNEY-CLIENT OR OTHER PRIVILEGE. If you believe
that it has been sent to you in error, do not read it. If you are not the
intended recipient, you are hereby notified that any retention,
dissemination, distribution, or copying of this communication is strictly
prohibited. Please reply to the sender that you have received the message in
error and then delete it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20110815/b69ce0ab/attachment.html>


More information about the Libav-user mailing list