[Libav-user] Fill AVFrame from a Cairo surface

Nicolas George george at nsup.org
Mon Aug 16 15:57:38 EEST 2021


Colossus (12021-08-16):
> Hello Nicolas,
> 
> thanks for replying. The documentation is not very clear. I already
> looked at encode_video.c and it wasn't useful as it creates a dummy
> image, I have to read data from a cairo surface instead.

The only difference it makes is what you put on the right hand side of
the = sign; FFmpeg is on the left hand side of the = equal sign, a dummy
image or an image from Cairo makes no difference from FFmpeg's
perspective.

> There should be more documentation on *HOW* to put the single puzzle
> pieces *TOGETHER, *not just describing the *SINGLE*
> pieces to my humble opinion.

Please feel free to suggest enhancements once you have grasped how it
works.

> Also I'm not sure what you mean with: "Calling
> av_frame_make_writable() on a frame you just allocated makes no
> sense." as in encode_video.c at line 140 I see the call to
> av_frame_allloc() and then at line 160, so after line 140 I read the
> call to av_frame_make_writable()...

And on line 155 you have the beginning of a loop. The
av_frame_make_writable() on line 160 is useless on the first round of
the loop, because the frame is freshly allocated and you can be sure it
is writable. But on the second round of the loop, it comes after the
first round, and in particular after encode() → avcodec_send_frame();
avcodec_send_frame() can keep a reference on the frame, and therefore
make it unwritable.

> I know where the flaw is as I used return codes not visible in the
> code above. I clearly stated it in my message:

You must check the return code of all the functions that can fail. If
you do not, your code is obviously invalid. Start by fixing that before
asking for more help.

> Did you reply from the beach...?

Ahem.

> On Mon, 16 Aug 2021 at 10:20, Nicolas George <george-ls1+KW1iHyU at public.gmane.org> wrote:

Top-posting is forbidden on this mailing-list; do not do it again if you
want more help. Look it up if you do not know what it means.

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20210816/b457e5d9/attachment.sig>


More information about the Libav-user mailing list