From 136b88180b78f6894b996d3cad2a9d8f18fa3ad1 Mon Sep 17 00:00:00 2001 From: Andrey Dyakov Date: Fri, 5 Jun 2026 00:03:11 +0400 Subject: [PATCH] fix(previews): ffprobe hangs Signed-off-by: Andrey Dyakov --- AUTHORS | 1 + lib/private/Preview/Movie.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index fe478401fddb4..fa5776e3ef575 100644 --- a/AUTHORS +++ b/AUTHORS @@ -32,6 +32,7 @@ - Andreas Pflug - Andrew Brown - Andrey Borysenko + - Andrey Dyakov - André Gaul - Andy Xheli - Anna Larch diff --git a/lib/private/Preview/Movie.php b/lib/private/Preview/Movie.php index f34bf60c14773..334de993deaa9 100644 --- a/lib/private/Preview/Movie.php +++ b/lib/private/Preview/Movie.php @@ -289,8 +289,10 @@ private function useHdr(string $absPath): bool { if ($test_hdr_proc === false) { return false; } - $test_hdr_stdout = trim(stream_get_contents($test_hdr_pipes[1])); + // Read stderr before stdout: ffprobe's stderr can exceed 64KB (OS pipe buffer) for certain + // files, causing a deadlock if stdout is read first. stdout is always a short string. $test_hdr_stderr = trim(stream_get_contents($test_hdr_pipes[2])); + $test_hdr_stdout = trim(stream_get_contents($test_hdr_pipes[1])); proc_close($test_hdr_proc); // search build options for libzimg (provides zscale filter) $ffmpeg_libzimg_installed = strpos($test_hdr_stderr, '--enable-libzimg'); @@ -341,6 +343,8 @@ private function generateThumbNail(int $maxX, int $maxY, string $absPath, int $s $returnCode = -1; $output = ''; if (is_resource($proc)) { + // Read stderr before stdout: ffmpeg's stderr can exceed 64KB (OS pipe buffer) for certain + // files, causing a deadlock if stdout is read first. stdout is always empty. $stderr = trim(stream_get_contents($pipes[2])); $stdout = trim(stream_get_contents($pipes[1])); $returnCode = proc_close($proc);