AlistGo/alist · error

ffmpeg-go failed to resize image %s to buffer: %w

Error message

ffmpeg-go failed to resize image %s to buffer: %w

What it means

The ffmpeg-go library (github.com/u2takey/ffmpeg-go) failed to run the ffmpeg child process that resizes an image and pipes it to stdout. The %s is the input file, %w carries the exec error: process not found (exec: 'ffmpeg': executable file not found in $PATH), non-zero ffmpeg exit code (corrupt/unsupported input, bad filter arguments), or context cancellation. ffmpeg's own stderr is forwarded to os.Stderr via WithOutput, so the real reason is visible on the server console, not in the error string.

Source

Thrown at drivers/local/util.go:108

		"f":       outputFormat, // Format for piping (e.g., image2pipe, png_pipe)
	}
	if vcodec != "" {
		outputArgs["vcodec"] = vcodec
	}
	if outputFormat == "mjpeg" {
		outputArgs["q:v"] = "3"
	}

	err = ffmpeg.Input(inputFile).
		Output("pipe:", outputArgs). // Output to pipe (stdout)
		GlobalArgs("-loglevel", "error").
		Silent(true).                     // Suppress ffmpeg's own console output
		WithOutput(outBuffer, os.Stderr). // Capture stdout to outBuffer, stderr to os.Stderr
		// ErrorToStdOut(). // Alternative: send ffmpeg's stderr to Go's stdout
		Run()

	if err != nil {
		return nil, fmt.Errorf("ffmpeg-go failed to resize image %s to buffer: %w", inputFile, err)
	}
	if outBuffer == nil || outBuffer.Len() == 0 {
		return nil, fmt.Errorf("ffmpeg-go produced empty buffer for %s", inputFile)
	}

	return outBuffer, nil
}

func generateThumbnailWithImagingOptimized(imagePath string, targetWidth int, quality int) (*bytes.Buffer, error) {

	file, err := os.Open(imagePath)
	if err != nil {
		return nil, fmt.Errorf("failed to open image: %w", err)
	}
	defer file.Close()

	img, err := imaging.Decode(file, imaging.AutoOrientation(true))
	if err != nil {

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Confirm ffmpeg is installed and visible to the process: run 'ffmpeg -version' in the same environment (inside the container if containerized)
  2. Look at the process stderr (forwarded to os.Stderr) for ffmpeg's actual diagnostic line
  3. Test the exact operation manually: ffmpeg -i <input> -vf scale=<width>:-1 -f image2pipe -loglevel error -
  4. If ffmpeg is fine but the input is unsupported, disable useFFmpeg and fall back to the pure-Go imaging path, or install a full ffmpeg build (libwebp/libheif)
Defensive patterns

Strategy: fallback

Validate before calling

// fail fast at startup if ffmpeg is required
if d.useFFmpeg {
    if _, err := exec.LookPath("ffmpeg"); err != nil {
        return fmt.Errorf("useFFmpeg enabled but ffmpeg not found in PATH: %w", err)
    }
}

Try / catch

if err != nil { // ffmpeg path failed
    log.Printf("ffmpeg resize failed for %s: %v, falling back to imaging", inputFile, err)
    return generateThumbnailWithImagingOptimized(inputFile, width, 85)
}

Prevention

When it happens

Trigger: getThumb with useFFmpeg=true on a host without the ffmpeg binary installed; ffmpeg built without the requested codec (e.g. mjpeg/png encoder missing in a minimal build); an input image ffmpeg cannot demux (WebP in old builds, HEIC, truncated download); invalid scale filter arguments when width <= 0.

Common situations: Docker images deployed without ffmpeg (alpine-based images especially), ffmpeg present at build time but not in the runtime container PATH, or enabling the 'use ffmpeg for thumbnails' option as a workaround for WebP only to hit a build without libwebp.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/2f2cafd44fbc1e31. Report an issue: GitHub.