[FFmpeg-devel] [PATCH] avformat/mov: Don't allocate unnecessarily large blocks of memory

Hendi finalcountdown72 at googlemail.com
Fri Jun 9 16:34:49 EEST 2023

On 09.06.2023 04:47, "zhilizhao(赵志立)" wrote:
> It’s a quick fix, but I’m afraid the two tickets are caused by more deep
> pitfalls.
> It would be helpful if someone can provide a sample for test.

I've uploaded a sample called bear-640x360-v_frag-cenc-senc.mp4. You can 
play it with -decryption_key ebdd62f16814d27b68ef122afce4ae3c.

The code path is only taken for fragmented encrypted MP4 files. I was 
not able to use ffmpeg to produce a file that exhibits the same behavior.

The mov_try_read_block function will be called with a size of 82 in this 
case. It's a very short sample, but for longer content this will be done 
every few seconds, whenever a new fragment starts. The encryption info 
is only freed when the format context is closed. That's not an inherent 
problem imo, but it does quickly escalate if you allocate a megabyte 
each time only to store a couple bytes.

More information about the ffmpeg-devel mailing list