image compression ffmpeg

Hey folks,

I’m trying to use FFmpeg in C++ to compress image buffers, but I keep running into a fundamental issue. I’m seeing this error:
1
2
3
4
5
[libx264 @ 00000000006d6100] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 00000000006d6100] profile High, level 5.0, 4:2:0, 8-bit
Error receiving packet!
[libx264 @ 00000000006d6100] final ratefactor: 42.29
Failed to compress screenshot!


Code: https://pastebin.com/isjxx0TF

Has anyone faced a similar issue or knows how to handle this? Any help would be much appreciated!

Thanks.

Luke
Read the manual page and understand how the functions are supposed to be used.

https://ffmpeg.org/doxygen/4.0/group__lavc__decoding.html#ga5b8eff59cf259747cf0b31563e38ded6

Returns
0 on success, otherwise negative error code: AVERROR(EAGAIN): output is not available in the current state - user must try to send input AVERROR_EOF: the encoder has been fully flushed, and there will be no more output packets AVERROR(EINVAL): codec not opened, or it is an encoder other errors: legitimate decoding errors

EAGAIN isn't a fatal error, yet you treat it as one.

On a more general point, maximise the information in your error messages. Like always printing the result of whatever comparison failed.


Examples:
encode_audio.c, encode_video.c, transcode_aac.c, vaapi_encode.c, and vaapi_transcode.c.


Go and study all those example codes.
Topic archived. No new replies allowed.