Skip to content

Commit db0a739

Browse files
authored
Merge pull request #61184 from nextcloud/backport/60916/stable32
[stable32] fix(previews): ffprobe hangs
2 parents 5e8006e + 2de8465 commit db0a739

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- Andreas Pflug <dev@admin4.org>
3333
- Andrew Brown <andrew@casabrown.com>
3434
- Andrey Borysenko <andrey.borysenko@nextcloud.com>
35+
- Andrey Dyakov <adduxa@gmail.com>
3536
- André Gaul <gaul@web-yard.de>
3637
- Andy Xheli <axheli@axtsolutions.com>
3738
- Anna Larch <anna@nextcloud.com>

lib/private/Preview/Movie.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ private function useHdr(string $absPath): bool {
108108
if ($test_hdr_proc === false) {
109109
return false;
110110
}
111-
$test_hdr_stdout = trim(stream_get_contents($test_hdr_pipes[1]));
111+
// Read stderr before stdout: ffprobe's stderr can exceed 64KB (OS pipe buffer) for certain
112+
// files, causing a deadlock if stdout is read first. stdout is always a short string.
112113
$test_hdr_stderr = trim(stream_get_contents($test_hdr_pipes[2]));
114+
$test_hdr_stdout = trim(stream_get_contents($test_hdr_pipes[1]));
113115
proc_close($test_hdr_proc);
114116
// search build options for libzimg (provides zscale filter)
115117
$ffmpeg_libzimg_installed = strpos($test_hdr_stderr, '--enable-libzimg');
@@ -161,6 +163,8 @@ private function generateThumbNail(int $maxX, int $maxY, string $absPath, int $s
161163
$returnCode = -1;
162164
$output = '';
163165
if (is_resource($proc)) {
166+
// Read stderr before stdout: ffmpeg's stderr can exceed 64KB (OS pipe buffer) for certain
167+
// files, causing a deadlock if stdout is read first. stdout is always empty.
164168
$stderr = trim(stream_get_contents($pipes[2]));
165169
$stdout = trim(stream_get_contents($pipes[1]));
166170
$returnCode = proc_close($proc);

0 commit comments

Comments
 (0)