{"record":{"id":"39b9ec25bf25051e","repo":"AlistGo/alist","slug":"ffmpeg-go-produced-empty-buffer-for-s","errorCode":null,"errorMessage":"ffmpeg-go produced empty buffer for %s","messagePattern":"ffmpeg-go produced empty buffer for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"drivers/local/util.go","lineNumber":111,"sourceCode":"\t\toutputArgs[\"vcodec\"] = vcodec\n\t}\n\tif outputFormat == \"mjpeg\" {\n\t\toutputArgs[\"q:v\"] = \"3\"\n\t}\n\n\terr = ffmpeg.Input(inputFile).\n\t\tOutput(\"pipe:\", outputArgs). // Output to pipe (stdout)\n\t\tGlobalArgs(\"-loglevel\", \"error\").\n\t\tSilent(true).                     // Suppress ffmpeg's own console output\n\t\tWithOutput(outBuffer, os.Stderr). // Capture stdout to outBuffer, stderr to os.Stderr\n\t\t// ErrorToStdOut(). // Alternative: send ffmpeg's stderr to Go's stdout\n\t\tRun()\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ffmpeg-go failed to resize image %s to buffer: %w\", inputFile, err)\n\t}\n\tif outBuffer == nil || outBuffer.Len() == 0 {\n\t\treturn nil, fmt.Errorf(\"ffmpeg-go produced empty buffer for %s\", inputFile)\n\t}\n\n\treturn outBuffer, nil\n}\n\nfunc generateThumbnailWithImagingOptimized(imagePath string, targetWidth int, quality int) (*bytes.Buffer, error) {\n\n\tfile, err := os.Open(imagePath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open image: %w\", err)\n\t}\n\tdefer file.Close()\n\n\timg, err := imaging.Decode(file, imaging.AutoOrientation(true))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode image: %w\", err)\n\t}\n","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/local/util.go#L93-L129","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// reject obviously non-media inputs before invoking ffmpeg\nif info, err := os.Stat(path); err != nil || info.Size() < 100 {\n    // not a plausible image; skip thumbnail\n    return nil, nil, nil\n}","typeGuard":null,"tryCatchPattern":"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.","preventionTips":["Skip zero-byte and tiny files before thumbnailing","Cache failures per-file so bad files don't repeatedly spawn ffmpeg processes"],"tags":["ffmpeg","thumbnail","corrupt-file","local-driver"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}