[FFmpeg-trac] #10797(avfilter:new): showspectrumpic is unreasonably RAM hungry

FFmpeg trac at avcodec.org
Sun Jan 14 03:12:40 EET 2024


#10797: showspectrumpic is unreasonably RAM hungry
-------------------------------------+------------------------------------
             Reporter:  ed           |                    Owner:  (none)
                 Type:  enhancement  |                   Status:  new
             Priority:  normal       |                Component:  avfilter
              Version:  git-master   |               Resolution:
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+------------------------------------
Comment (by ed):

 Just noticed something funkier -- attached is a song, 404 seconds long,
 which FFmpeg will probably play using libopenmpt once uncompressed.
 Curiously, this makes FFmpeg allocate 775 MiB on my systems (alpine3.19,
 fedora39 with FFmpeg from rpmfusion, fedora39 with one of BtbN's master
 builds, and a BtbN build on Windows10).

 {{{
 gzip -d megatune.xm.gz
 /bin/time ffmpeg -i megatune.xm -filter_complex showspectrumpic=s=640x512
 -frames:v 1 a.jpg
 # "776228 KiB max resident memory"
 }}}

 Another song, https://a.ocv.me/pub/demo/music/chiptunes/jt_versi.xm (839
 seconds) ends up allocating 1.5 GiB.

 The curious part is, if you use FFmpeg to transcode these files (for
 example to opus), it won't go anywhere near that, instead peaking at 63
 MiB.

 So I tried the following workaround, but that still allocates the same
 excessive 770 MiB in the 2nd instance:
 {{{
 /bin/time ffmpeg -i megatune.xm -c:a pcm_s16le -f nut - | /bin/time ffmpeg
 -y -f nut -i - -filter_complex showspectrumpic=s=640x512 -frames:v 1 a.jpg
 }}}

 ...but converting to a flac-file first, and then creating a spectrogram of
 that, keeps it to a more manageable 225 MiB.

 Perhaps showspectrumpic isn't getting the estimated duration and it makes
 some unwise decisions?

 Also tried using showwavespic instead of showspectrumpic; it climbs to 400
 MiB with jt_versi.xm, far off from 1.5 GiB but still more than I would've
 expected.
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/10797#comment:1>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list