Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- Andreas Pflug <dev@admin4.org>
- Andrew Brown <andrew@casabrown.com>
- Andrey Borysenko <andrey.borysenko@nextcloud.com>
- Andrey Dyakov <adduxa@gmail.com>
- André Gaul <gaul@web-yard.de>
- Andy Xheli <axheli@axtsolutions.com>
- Anna Larch <anna@nextcloud.com>
Expand Down
34 changes: 32 additions & 2 deletions lib/private/Preview/Movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,39 @@ private function useHdr(string $absPath): bool {
if ($test_hdr_proc === false) {
return false;
}
$test_hdr_stdout = trim(stream_get_contents($test_hdr_pipes[1]));
$test_hdr_stderr = trim(stream_get_contents($test_hdr_pipes[2]));

stream_set_blocking($test_hdr_pipes[1], false);
stream_set_blocking($test_hdr_pipes[2], false);

$test_hdr_stdout = '';
$test_hdr_stderr = '';

while (!feof($test_hdr_pipes[1]) || !feof($test_hdr_pipes[2])) {
$read = array_filter([
!feof($test_hdr_pipes[1]) ? $test_hdr_pipes[1] : null,
!feof($test_hdr_pipes[2]) ? $test_hdr_pipes[2] : null,
]);
$write = $except = [];
if (stream_select($read, $write, $except, 5) === false) {
Copy link
Copy Markdown
Member

@solracsf solracsf Jun 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This 5 is a per-iteration timeout. Only the false (error) return is handled; the 0 (timeout) return falls through, $read becomes empty, the foreach does nothing, and the while loops again. So if ffprobe truly hangs (produces no output and never closes its pipes), this spins every 5s forever: the same "hangs indefinitely" symptom the PR title targets, just via a different path.

break;
}
foreach ($read as $pipe) {
$chunk = fread($pipe, 8192);
if ($chunk === false) continue;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fail CI lint.

if ($pipe === $test_hdr_pipes[1]) {
$test_hdr_stdout .= $chunk;
} else {
$test_hdr_stderr .= $chunk;
}
}
}

fclose($test_hdr_pipes[1]);
fclose($test_hdr_pipes[2]);
proc_close($test_hdr_proc);

$test_hdr_stdout = trim($test_hdr_stdout);
$test_hdr_stderr = trim($test_hdr_stderr);
// search build options for libzimg (provides zscale filter)
$ffmpeg_libzimg_installed = strpos($test_hdr_stderr, '--enable-libzimg');
// Only values of "smpte2084" and "arib-std-b67" indicate an HDR video.
Expand Down