[FFmpeg-trac] #3586(avcodec:new): [discrepancy with libav] avcodec_encode_video2 merges packet side data with the packet body
FFmpeg
trac at avcodec.org
Thu Apr 24 11:45:04 CEST 2014
#3586: [discrepancy with libav] avcodec_encode_video2 merges packet side data with
the packet body
----------------------------------+-----------------------------------
Reporter: Lastique | Owner:
Type: defect | Status: new
Priority: normal | Component: avcodec
Version: 2.2.1 | Resolution:
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
----------------------------------+-----------------------------------
Comment (by Lastique):
I managed to create a test case that roughly reflects our application
behavior and shows the problem.
1. Compile and run without arguments, the test will produce output.avi.
This file contains encoded video with junk at the end. This file does not
play correctly with ffmpeg's ffplay and plays fine by avplay from Kubuntu
13.10 (version 0.8.10-6:0.8.10-0ubuntu0.13.10.1).
2. Rename output.avi to output_bad.avi for future reference.
3. Run the test again with --without_side_data command line argument. It
will produce the correct output.avi, which can be played by both ffplay
and avplay.
4. During both runs the test program outputs encoded frame size, you can
notice that the first run produces larger frames. output_bad.avi will also
be larger than the correct output.avi.
I have another note to add. av_packet_merge_side_data() reallocates the
packet buffer and puts encoded data and side data in the new buffer. It
frees the old buffer and sets AVPacket::data to the new buffer. This
breaks the interface of avcodec_encode_video2(), which is documented to
use the user's buffer if provided. We rely on that contract in our code,
that's why we're basically using the freed memory with junk at the end.
This is reflected in the test case.
After this discovery I have to agree with gjdfgh (comment:5). Please,
remove side data merging.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/3586#comment:7>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list