[FFmpeg-user] MJPEG encoder large memory allocation issue

Carl Eugen Hoyos cehoyos at ag.or.at
Fri Sep 5 14:41:50 CEST 2014

Tithi Patel <tithi.patel <at> einfochips.com> writes:

> Output #0, image2, to 'out.jpg':
>   Metadata:
>     encoder         : Lavf54.29.104
>     Stream #0:0: Video: mjpeg, yuvj422p, 4000x2992

This image has 250 x 187 macroblocks.
Currently (since nearly ten years), FFmpeg assumes a 
theoretical maximum size for one macroblock of 
3000 bytes (see libavcodec/mpegvideo.h line 75).
A small overhead for safety is added in 
libavcodec/mpegvideo_enc.c line 1702.

Could you explain your usecase? I would assume that 
on a modern system where you want to encode 4k a 
100 MB allocation (that does not leak) is no 
problem or am I wrong?

Carl Eugen

More information about the ffmpeg-user mailing list