Opened 4 months ago

Closed 4 months ago

#6616 closed defect (invalid)

Decoded frames contain information about previous encoded frame

Reported by: rubensanchez 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 rubensanchez 4 months 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)

Changed 4 months ago by rubensanchez

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

comment:1 Changed 4 months ago by cehoyos

  • Priority changed from critical to normal

comment:2 follow-up: Changed 4 months ago by Cigaes

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

comment:3 in reply to: ↑ 2 ; follow-up: Changed 4 months ago by 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.

comment:4 in reply to: ↑ 3 ; follow-up: Changed 4 months ago by 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.

comment:5 in reply to: ↑ 4 Changed 4 months ago by rubensanchez

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 Changed 4 months ago by rubensanchez

  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.