[Libav-user] interleaving AVI format and av_interleaved_write_frame

YIRAN LI mrfun.china at gmail.com
Wed Nov 13 12:06:59 CET 2013


Hi friends, here I have several questions about AVI format interleave need
your help.

Basically what my program is doing is quite simple, it has a loop reading
out video/audio content, and send them to encode to get packets, and
finally call av_write_frame to write packets into file.

So when I did this for AVI format (huffYUV + mp3), I found that the packets
in generated AVI files looks like this.

-V1
-V2
-V3
-V4
-V5
-V6
-V7
-V8
-V9
-A1
-A2
-A3
-A4
-V10
-V11

I mean there're too many video frames between two chunks of audio samples,
and this video file has some problems while playing in my own player (I
guess the AV interleaving is the cause). and if I use ffmpoeg -i -vcodec
copy -acodec copy to convert this avi into another avi, I can find that the
AV interleaving in the ffmpeg converted AVI is quite good, like v1 v2 a1 a2
v3 v4 a3 a4. and it plays correctly in my own player.


This program uses av_write_frame to write packet (there seems to have no
special code to arrange A/V packets before calling av_write_frame) so I
changed it to use av_interleaved_write_frame instead, and
with av_interleaved_write_frame, generated AVI has perfect A/V interleaving
and file plays perfectly in my player.

So now I'd like to know.

1. If my program has no code to arrange A/V packets order, the order of A/V
packets completely are based on the order of data read out from source.
should I use av_interleaved_write_frame to generate an AVI file?

2. for AVI format, is it safe to use av_interleaved_write_frame to replace
av_write_frame? (if packets not properly ordered, then of course should use
av_interleaved_write_frame, but if packets were correctly ordered, will
av_interleaved_write_frame causing any problem excepts performance penalty?)

Great thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20131113/fe267c05/attachment.html>


More information about the Libav-user mailing list