diff --git a/AUTHORS b/AUTHORS index 8881c9ba26a75..951496aa6a907 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 7b9c7a26f77b1..7a22551d5dafb 100644 --- a/lib/private/Preview/Movie.php +++ b/lib/private/Preview/Movie.php @@ -108,8 +108,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'); @@ -161,6 +163,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);