[Libav-user] libx264 randomly causing image tearing
Andy Shaules
bowljoman at gmail.com
Thu Jun 16 11:29:05 CEST 2016
On 6/15/2016 12:50 PM, DeHackEd wrote:
> On 06/15/2016 03:12 PM, Nicolas George wrote:
>> L'octidi 28 prairial, an CCXXIV, DeHackEd a écrit :
>>> Everything is working fine except for one anomaly. Occasionally I get this
>>> "tearing" effect (screen shot link at bottom of message) for a split
>>> second where it looks like the top portion of the frame, usually around
>>> 1/3 of it, looks like a frame from another part of the video. It is most
>>> noticeable around scene cuts but otherwise doesn't have any pattern. Just
>>> a glitch of sorts every few seconds.
>>> Switching to ffv1 I don't see any issues in the output so I'm fairly
>>> certain it's an libx264 or other encoding side issue.
>> I find that very unlikely, x264 is an extensively tested library and the bug
>> you describe does not seem subtle.
>>
>> It looks like a threading issue to me, in fact: application replacing the
>> frame data with the next frame while x264 is still accessing it. Since the
>> FFV1 encoder does not do frame threading, it would not trigger the issue.
> Yes, I believe it is threading issue now and am troubleshooting it as such. (Wish me luck..)
>
>> Regards,
>>
>>
>>
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/libav-user
>>
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
It could also be that you are not packing your PES correctly in the case
of multi slice video. You will have to determine the frame boundaries of
the coded pictures.
Sounds to me like you have upper/lower field encoding, and will need to
detect the first macroblock and avc frame number .
I expect that you receive a NALU sequence from the input of 7,8, 5,5,
1,1, 1,1, 1,1, 1,1, 1,1 ,5,5,
but your PES writer is breaking the frames up.
9,7,8,5, 9,7,8,5, 9,1 9,1 9,1 9,1
ANd should be
9,7,8,5,5, 9,1,1, 9,1,1 9,1,1
YOu may ask.... Can I just stuff two VC nals into each PES? No, you
must detect the frame boundaries which are not the nalu boundaries.
YOu must determin max frame num, and read first macroblock in slice header.
Technically you cannot know when a frame is finished being received
until you begin to receive the next frame.
Have Fun!
Andy
More information about the Libav-user
mailing list