reticivis-net / mediaforge

A Discord bot for editing and creating videos, images, GIFs, and more!
GNU General Public License v3.0
82 stars 28 forks source link

ffmpeg: malloc_consolidate(): invalid chunk size #149

Closed dorukayhan closed 1 year ago

dorukayhan commented 1 year ago

I tried to run /esmcaption caption: bind p "say сука блять" on this image and FFmpeg exploded as such:

DATETIME:2023-01-14 03:08:18.617366
COMMAND:
TRACEBACK:
processing.common.CMDError: ffmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-9)
  configuration: --disable-decoder=amrnb --disable-decoder=libopenjpeg --disable-gnutls --disable-liblensfun --disable-libopencv --disable-podpages --disable-sndio --disable-stripping --enable-avfilter --enable-chromaprint --enable-frei0r --enable-gcrypt --enable-gpl --enable-ladspa --enable-libaom --enable-libaribb24 --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libdavs2 --enable-libdc1394 --enable-libdrm --enable-libfdk-aac --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libkvazaar --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librsvg --enable-librubberband --enable-libshine --enable-libsmbclient --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-nonfree --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-openssl --enable-postproc --enable-pthreads --enable-shared --enable-version3 --enable-vulkan --incdir=/usr/include/x86_64-linux-gnu --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --toolchain=hardened --enable-vaapi --enable-libmfx --enable-libvmaf --enable-libilbc --disable-altivec --shlibdir=/usr/lib/x86_64-linux-gnu
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Input #0, png_pipe, from '/dev/shm/mediaforge/kvrxkvPB.png':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: png, rgba(pc), 498x149 [SAR 2835:2835 DAR 498:149], 25 fps, 25 tbr, 25 tbn
Input #1, gif, from '/dev/shm/mediaforge/VPGxzZhy.gif':
  Duration: 00:00:06.00, start: 0.000000, bitrate: 15150 kb/s
  Stream #1:0: Video: gif, bgra, 498x409, 20 fps, 20 tbr, 100 tbn
Stream mapping:
  Stream #0:0 (png) -> format:default
  Stream #1:0 (gif) -> format:default
  vstack:default -> Stream #0:0 (png)
Press [q] to stop, [?] for help
malloc_consolidate(): invalid chunk size

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/mediaforge-HXFskkj--py3.11/lib/python3.11/site-packages/discord/app_commands/commands.py", line 861, in _do_call
    return await self._callback(self.binding, interaction, **params)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mediaforge/src/commands/caption.py", line 175, in esmcaption
    await process(ctx, processing.vips.vipsutils.generic_caption_stack, [["VIDEO", "GIF", "IMAGE"]],
  File "/mediaforge/src/core/process.py", line 157, in process
    raise e
  File "/mediaforge/src/core/process.py", line 125, in process
    result = await run()
             ^^^^^^^^^^^
  File "/mediaforge/src/core/process.py", line 108, in run
    command_result = await func(*args, **kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mediaforge/src/processing/vips/vipsutils.py", line 23, in generic_caption_stack
    return await processing.ffmpeg.naive_vstack(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mediaforge/src/processing/ffmpeg.py", line 560, in naive_vstack
    await run_command("ffmpeg", "-i", file0, "-i", file1, "-filter_complex",
  File "/mediaforge/src/processing/common.py", line 75, in run_command
    raise CMDError(f"Command {args} failed.") from CMDError(result)
processing.common.CMDError: Command ('ffmpeg', '-i', '/dev/shm/mediaforge/kvrxkvPB.png', '-i', '/dev/shm/mediaforge/VPGxzZhy.gif', '-filter_complex', '[0]format=pix_fmts=yuva420p[0f];[1]format=pix_fmts=yuva420p[1f];[0f][1f]vstack=inputs=2', '-c:v', 'png', '-fs', '1G', '-fps_mode', 'vfr', '/dev/shm/mediaforge/oUqIsHCQ.mp4') failed.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/mediaforge-HXFskkj--py3.11/lib/python3.11/site-packages/discord/ext/commands/hybrid.py", line 438, in _invoke_with_namespace
    value = await self._do_call(ctx, ctx.kwargs)  # type: ignore
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/mediaforge-HXFskkj--py3.11/lib/python3.11/site-packages/discord/app_commands/commands.py", line 880, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'esmcaption' raised an exception: CMDError: Command ('ffmpeg', '-i', '/dev/shm/mediaforge/kvrxkvPB.png', '-i', '/dev/shm/mediaforge/VPGxzZhy.gif', '-filter_complex', '[0]format=pix_fmts=yuva420p[0f];[1]format=pix_fmts=yuva420p[1f];[0f][1f]vstack=inputs=2', '-c:v', 'png', '-fs', '1G', '-fps_mode', 'vfr', '/dev/shm/mediaforge/oUqIsHCQ.mp4') failed.

Trying it again resulted in the same error. /caption caption: bind p "say сука блять", however, worked just fine. I could also shrink the image (/resize width: 249 height: -1) and then /esmcaption the shrunk image (/esmcaption caption: bind p "say сука блять") (which resulted in an ugly caption but that's probably an unrelated font problem).

What gives?

reticivis-net commented 1 year ago

See #147