[FFmpeg-devel] Can av_write_frame() modify pkt.data?

Luca Abeni lucabe72
Tue Jun 17 14:23:00 CEST 2008


Hi all,

I just discovered that the mov muxer can modify the
"data" field of the AVPacket structure that it receives
as parameter (in case of H.264 video, mov_write_packet()
calls ff_avc_parse_nal_units(pkt->data, &pkt->data, &pkt->size);
which frees pkt->data and allocates a new buffer).

Is this intended? This behaviour is not a problem for
ffmpeg.c, because it dynamically allocates and deallocates
pkt->data for every output packet, but is a problem for
output_example.c (if you modify it for writing H.264 video
in mov).

So, should output_example.c be fixed, or should movenc.c
be fixed? (or is everything ok, since output_example does
not write H.264 in mov unless you modify it?)

BTW, I also noticed that output_example.c is slightly incorrect
when generating pkt.pts, because it uses c->coded_frame->pts
without checking if it is AV_NOPTS_VALUE... Again, this is a
problem only for streams generated by libx264.

If needed, I'll send some patches later.


			Luca




More information about the ffmpeg-devel mailing list