Concurrent media previews time out in FFmpeg slot acquisition

Author: toddeTVCreated Sep 23, 2026Updated Sep 26, 2026
Labelsbug

Description

I am running FileBrowser Quantum v2.0.8-beta in Docker with HEIC preview conversion enabled.

Opening a directory with many HEIC files causes concurrent preview requests to stall and eventually time out. A single HEIC file converts with the bundled FFmpeg in about 0.2–0.3s, so the source files and FFmpeg decoding itself do not appear to be the bottleneck.

A goroutine dump taken while the server was stuck shows HEIC preview and media metadata goroutines blocked in github.com/gtsteffaniak/go-ffmpeg.(*Service).Acquire.

This is related to #1470 because the visible symptom is again parallel HEIC preview failures, but #1470 had a different cause: collisions in the temporary HEIC directory. That issue was fixed in v1.0.1.

Expected behaviour

Concurrent HEIC previews should complete without blocking the preview pipeline. Opening an HEIC file should not return HTTP 408, and media metadata/video preview requests should continue to work while thumbnails are generated.

What is happening instead?

HEIC preview requests can remain pending until the 30-second request timeout:

Request approaching timeout (24.0s/30s): GET /resources/preview

[ERROR] Preview timeout for file 'IMG_0001.HEIC' after 15 seconds

GET | 408 | ... | 30000ms |
"/api/resources/preview?path=%2Fphotos%2FIMG_0001.HEIC&source=Files&inline=true&size=original"

Media metadata can stall at the same time:

Request approaching timeout (48.0s/60s): GET /media/metadata

The goroutine dump shows the blocked HEIC preview here:

github.com/gtsteffaniak/go-ffmpeg.(*Service).Acquire
github.com/gtsteffaniak/filebrowser/backend/internal/ffmpeg.(*Service).Acquire
github.com/gtsteffaniak/filebrowser/backend/internal/preview.(*Service).convertHEICToJPEGWithFFmpeg
github.com/gtsteffaniak/filebrowser/backend/internal/preview.(*Service).generateHEICPreview

It also shows media metadata blocked in nested slot acquisition:

github.com/gtsteffaniak/go-ffmpeg.(*Service).Acquire
github.com/gtsteffaniak/go-ffmpeg.(*Service).acquireSlot
github.com/gtsteffaniak/go-ffmpeg.(*Service).runWithSlot
github.com/gtsteffaniak/go-ffmpeg.(*Service).ProbeStream
github.com/gtsteffaniak/filebrowser/backend/internal/ffmpeg.(*Service).ProbeFile

I think the cause may be nested FFmpeg slot acquisition in the FileBrowser wrapper.

For example, ProbeFile() currently acquires a slot before calling s.inner.ProbeStream(...):

go
if err = s.Acquire(ctx); err != nil {
    return nil, err
}
defer s.Release()

info, err := s.inner.ProbeStream(...)

The HEIC path uses the same pattern before calling the underlying conversion service:

go
if err := s.ffmpegService.Acquire(ctx); err != nil {
    return nil, err
}
defer s.ffmpegService.Release()

return s.ffmpegService.ConvertHEICToJPEG(...)

go-ffmpeg v1.0.0 documents that its service methods acquire slots automatically:

Service methods acquire slots automatically — do not call Acquire before them.

The manual HEIC Acquire() is also still present on the current main branch.

I have not tested a patched build, so this is only my current diagnosis. Making one layer responsible for FFmpeg concurrency may fix the issue.

Additional context

Environment:

FileBrowser Quantum: v2.0.8-beta
Deployment: Docker
Image: gtstef/filebrowser:2.0.8-beta
HEIC conversion: enabled

Relevant configuration:

yaml
integrations:
  media:
    convert:
      imagePreview:
        heic: true

Direct FFmpeg tests on the same HEIC file are fast:

single-frame HEIC -> JPEG:
real    0m 0.26s

FFmpeg pass used for display-matrix/orientation detection:
real    0m 0.20s

Changing server.numImageProcessors did not resolve the issue.

Related: #1470 — “Generating multiple HEIC previews in parallel fails”. That issue appears to have had a different root cause.

How to reproduce?

  1. Run FileBrowser Quantum v2.0.8-beta in Docker.
  2. Enable HEIC preview conversion.
  3. Open a directory containing many uncached HEIC files. My setup reproduces this with about 126 HEIC files.
  4. While thumbnails are being generated, open one of the HEIC files.
  5. Observe /api/resources/preview requests eventually returning HTTP 408. /api/media/metadata may also remain blocked.
  6. While it is stuck, generate a goroutine dump:
bash
docker kill --signal=QUIT filebrowser
docker logs filebrowser > filebrowser-goroutines.log 2>&1
  1. Inspect the dump for goroutines blocked in:
github.com/gtsteffaniak/go-ffmpeg.(*Service).Acquire

Files

Attached: filebrowser-goroutines-sanitized.log

The file contains the timeout window and the relevant goroutine stacks showing media preview and metadata operations blocked in FFmpeg slot acquisition. Client IPs, usernames, request paths, tokens, hashes, keys, and media filenames have been removed.

Relevant source files:

backend/internal/preview/heic_ffmpeg.go
backend/internal/ffmpeg/metadata.go
backend/internal/ffmpeg/service.go

Source: gtsteffaniak/filebrowser