AlistGo/alist · warning
ffmpeg-go produced empty buffer for
Error message
ffmpeg-go produced empty buffer for %s
What it means
ffmpeg exited with status 0 but wrote zero bytes to the stdout pipe while resizing an image. This means ffmpeg considered the run successful yet produced no output frames — typically because the demuxer opened the file but the decoder yielded no video stream, or output arguments (e.g. an image2pipe muxer with no frames flushed) silently produced nothing.
Solutions
- Verify the file is a real, complete image: 'file <path>' and open it locally
- Re-run ffmpeg manually with '-loglevel debug' to see why no frames are emitted
- Return this error to the caller so the driver can skip thumbnail caching for this file instead of retrying
Defensive patterns
Strategy: validation
Validate before calling
// reject obviously non-media inputs before invoking ffmpeg
if info, err := os.Stat(path); err != nil || info.Size() < 100 {
// not a plausible image; skip thumbnail
return nil, nil, nil
} Try / catch
Wrap the call; on 'empty buffer' treat the file as un-thumbnail-able and record a negative cache entry so it is skipped on subsequent listings instead of retrying every time.
Prevention
- Skip zero-byte and tiny files before thumbnailing
- Cache failures per-file so bad files don't repeatedly spawn ffmpeg processes
When it happens
Trigger: Passing a file that is not actually a still image or video (e.g. a .png extension on a text file, an audio file), a zero-byte image, or a format where ffmpeg's decoder fails lazily without setting a non-zero exit code.
Common situations: Misnamed media files, files still being written (upload in progress) when the thumbnail request arrives, or encrypted/truncated downloads that keep a valid container header but no frames.
Related errors
- ffmpeg-go failed to resize image
- invalid input file path
- failed to decode image
- failed to encode thumbnail
- failed to open image
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/39b9ec25bf25051e.
Report an issue: GitHub.
Appendix: source
Thrown at drivers/local/util.go:111
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 {
return nil, fmt.Errorf("failed to decode image: %w", err)
}
View on GitHub (pinned to 843d9dc814)