[FFmpeg-user] ffmpeg is oom-killed when converting an image to AVIF
Dmitry Katsubo
dma_k at mail.ru
Fri Oct 6 03:28:07 EEST 2023
Dear community,
Re-posting the issue concerning too extensive memory usage by ffmpeg when converting the image to AV1. Any ideas how to overcome the issue (except of plugging more memory)?
Thanks in advance!
On 2023-09-27 23:03, Dmitry Katsubo wrote:
> Dear FFmpeg users,
>
> I've encountered OOM "issue" when encoding PNG image to AVIF using ffmpeg. I have an example of successful conversion for the image about 6000x1800x32, but a bit larger image 7147×1783×32 causes OOM.
>
> Any idea why image raster of 7147×1783×4 ~ 50 MB requires ~ 3 GB of memory (which is at least ×50 more memory than raster)? And how to workaround the issue?
>
> Many thanks in advance!
>
> $ ffmpeg -i test.png -c:v libaom-av1 -crf 30 test.avif
> ffmpeg version 5.1.3-1 Copyright (c) 2000-2022 the FFmpeg developers
> built with gcc 12 (Debian 12.2.0-14)
> configuration: --prefix=/usr --extra-version=1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping
> --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite
> --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg
> --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex
> --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2
> --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl
> --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo
> --enable-librav1e --enable-shared
> Input #0, png_pipe, from 'test.png':
> Duration: N/A, bitrate: N/A
> Stream #0:0: Video: png, rgba(pc), 7147x1783 [SAR 2835:2835 DAR 7147:1783], 25 fps, 25 tbr, 25 tbn
> Stream mapping:
> Stream #0:0 -> #0:0 (png (native) -> av1 (libaom-av1))
> Press [q] to stop, [?] for help
> [libaom-av1 @ 0x55b79026db40] v3.6.0
> Output #0, avif, to 'test.avif':
> Metadata:
> encoder : Lavf59.27.100
> Stream #0:0: Video: av1 (av01 / 0x31307661), gbrp(pc, gbr/unknown/unknown, progressive), 7147x1783 [SAR 1:1 DAR 7147:1783], q=2-31, 25 fps, 12800 tbn (default)
> Metadata:
> encoder : Lavc59.37.100 libaom-av1
> Side data:
> cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
> Killed 1 fps=0.6 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
>
> # free -t
> total used free shared buff/cache available
> Mem: 8017020 4833284 1275188 119672 2330812 3183736
> Swap: 102396 102396 0
> Total: 8119416 4935680 1275188
>
> From /var/log/kernel.log
>
> kernel: ffmpeg invoked oom-killer: gfp_mask=0x140dca(GFP_HIGHUSER_MOVABLE|__GFP_COMP|__GFP_ZERO), order=0, oom_score_adj=0
> kernel: CPU: 0 PID: 466425 Comm: ffmpeg Not tainted 6.1.0-10-amd64 #1 Debian 6.1.38-1
> kernel: Call Trace:
> kernel: <TASK>
> kernel: dump_stack_lvl+0x44/0x5c
> kernel: dump_header+0x4a/0x211
> kernel: oom_kill_process.cold+0xb/0x10
> kernel: out_of_memory+0x1fd/0x4c0
> kernel: __alloc_pages_slowpath.constprop.0+0xc73/0xdc0
> kernel: __alloc_pages+0x305/0x330
> kernel: __folio_alloc+0x17/0x50
> kernel: ? policy_node+0x51/0x70
> kernel: vma_alloc_folio+0x9c/0x370
> kernel: __handle_mm_fault+0x92f/0xfa0
> kernel: handle_mm_fault+0xdb/0x2d0
> kernel: do_user_addr_fault+0x19c/0x570
> kernel: exc_page_fault+0x70/0x170
> kernel: asm_exc_page_fault+0x22/0x30
> kernel: RIP: 0033:0x7f3cf8f7204a
> ...
> kernel: Mem-Info:
> kernel: active_anon:153032 inactive_anon:1662278 isolated_anon:0
> kernel: active_file:382 inactive_file:2194 isolated_file:98
> kernel: unevictable:11644 dirty:356 writeback:0
> kernel: slab_reclaimable:48560 slab_unreclaimable:43800
> kernel: mapped:9888 shmem:25129 pagetables:11368
> kernel: sec_pagetables:0 bounce:0
> kernel: kernel_misc_reclaimable:0
> kernel: free:24673 free_pcp:174 free_cma:0
> kernel: 28496 total pagecache pages
> kernel: 332 pages in swap cache
> kernel: Free swap = 0kB
> kernel: Total swap = 102396kB
> kernel: 2068610 pages RAM
> kernel: 0 pages HighMem/MovableOnly
> kernel: 64355 pages reserved
> kernel: 0 pages hwpoisoned
> kernel: Tasks state (memory values in pages):
> kernel: [ pid ] uid tgid total_vm rss pgtables_bytes swapents oom_score_adj name
> kernel: [ 466425] 1000 466425 1093593 808340 7086080 0 0 ffmpeg
> ...
> kernel: oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=user.slice,mems_allowed=0,global_oom,task_memcg=/user.slice/user-1000.slice/session-c1.scope,task=ffmpeg,pid=466425,uid=1000
> kernel: Out of memory: Killed process 466425 (ffmpeg) total-vm:4374372kB, anon-rss:3233360kB, file-rss:0kB, shmem-rss:0kB, UID:1000 pgtables:6920kB oom_score_adj:0
>
>
--
With best regards,
Dmitry
More information about the ffmpeg-user
mailing list