[Libav-user] bug report: avcodec_decode_video2 & pthreads
Ben Mesander
ben at cardinalpeak.com
Mon Oct 13 17:41:01 CEST 2014
Hi,
Recently I wrote some code using libavcodec & friends to extract the
first frame from a mpeg2ts containing H.264 and encode it as PNG still
image with user specified dimensions.
Later, when I wanted to display a default PNG image in the case where the
ts file was missing or corrupted, I realized I could use the same code and
provide it a PNG file as input and have it "transcode" to a PNG file that
had the correct dimensions. While I could write separate code to do this,
it was convenient to use the same code calling FFmpeg APIs to do both tasks.
However, when I did this PNG->PNG transcode, on some machines my code
worked, and on others, the code failed. I tracked this down through my code
and down into FFmpeg. The machines (both real and virtual) I was running on
had 2-4 cores, and I noted multiple threads were spun up to decode the PNG
image, and something went wrong on some machines but the code worked fine
on others. So this is a hard bug report to reproduce. I have trimmed my
code down to something which just reads in a PNG and tries to decode it,
hopefully it's small enough to be useful.
For what it's worth, whatever the race is, I found on some machines the
attached code always works, and on others, it never works. I am using
CentOS 6.4 amd64, and had the same RPM manifest on machines that worked and
machines that didn't. I spent a lot of time trying to track down
environmental issues and I could not find any.
If the underlying ffmpeg library is compiled withe --disable-pthreads the
code always works correctly. If that is not the case, sometimes
avcodec_decode_video2() returns the number of bytes in the PNG, but does
not set the frame complete flag to true. When this happens, the output is
corrupt, and subsequent calls to avcodec_decode_video2() fail.
Exact flags used to compile ffmpeg and command line to compile C test
program are in comments in the C code.
Regards,
Ben
--
*Ben Mesander*
(303)570-1606 | Email <email at cardinalpeak.com> | vCard
<http://www.cardinalpeak.com/vcard/bmesander.vcf> | Web
<http://www.cardinalpeak.com/> | Company Blog
<http://www.cardinalpeak.com/blog> | LinkedIn
<https://cardinalpeak.basecamphq.com/projects/6118601/file/79455231/Linked%20In%20url>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20141013/c2a28bc7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bugreport.c
Type: text/x-csrc
Size: 4079 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20141013/c2a28bc7/attachment.bin>
More information about the Libav-user
mailing list