Opened 7 years ago

Closed 7 years ago

#6616 closed defect (invalid)

Decoded frames contain information about previous encoded frame

Reported by: Ruben Sanchez Castellano Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I'm developing an application which decodes a video source, overlays an image and encodes the frame again to send it to an external endpoint.

With the new API to decode/encode frames the decoded frames contain information about the previous encoded frame on it pixel data. See the attached image. This does not happen with the old decode/encode functions.

Attachments (1)

image_131.png (487.0 KB ) - added by Ruben Sanchez Castellano 7 years ago.
In this image shows an overlay ob colour boxes moving around. You can appreciate the previous position of each one.

Download all attachments as: .zip

Change History (7)

by Ruben Sanchez Castellano, 7 years ago

Attachment: image_131.png added

In this image shows an overlay ob colour boxes moving around. You can appreciate the previous position of each one.

comment:1 by Carl Eugen Hoyos, 7 years ago

Priority: criticalnormal

comment:2 by Cigaes, 7 years ago

It looks like you are modifying the frame data returned by the decoder, are you not?

in reply to:  2 ; comment:3 by Ruben Sanchez Castellano, 7 years ago

Replying to Cigaes:

It looks like you are modifying the frame data returned by the decoder, are you not?

Yes, the application must modify the decoded frames in order to apply an overlay image.

in reply to:  3 ; comment:4 by Hendrik, 7 years ago

Replying to rubensanchez:

Replying to Cigaes:

It looks like you are modifying the frame data returned by the decoder, are you not?

Yes, the application must modify the decoded frames in order to apply an overlay image.

Well, there is your problem then. Frames are not guaranteed to be writeable, because they can still be used as reference frames by the decoder - which results in what you are seeing here.

If you need to write to a frame, you can use "av_frame_make_writable", which will copy the data if the frame is read-only, so you don't mess with the reference frame.

in reply to:  4 comment:5 by Ruben Sanchez Castellano, 7 years ago

Replying to heleppkes:

Replying to rubensanchez:

Replying to Cigaes:

It looks like you are modifying the frame data returned by the decoder, are you not?

Yes, the application must modify the decoded frames in order to apply an overlay image.

Well, there is your problem then. Frames are not guaranteed to be writeable, because they can still be used as reference frames by the decoder - which results in what you are seeing here.

If you need to write to a frame, you can use "av_frame_make_writable", which will copy the data if the frame is read-only, so you don't mess with the reference frame.

Great! You were right. I ended up creating a copy of the decoded frame and modifying this copy instead the original one. With this approach, the problem is solved.

Then this ticket must be closed as it is not a bug.

comment:6 by Ruben Sanchez Castellano, 7 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.