Skip to content

Commit 6e9bccd

Browse files
committed
fix: unbloc ffmpeg on some broken videos
Co-authored-by: Joas Schilling <[email protected]> Signed-off-by: Arthur Schiwon <[email protected]>
1 parent 5cddf5a commit 6e9bccd

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

.reuse/dep5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Files: tests/data/integritycheck/htaccessWithValidModifiedContent/.htaccess
107107
Copyright: 2016 ownCloud, Inc., 2019 Nextcloud GmbH and Nextcloud contributors
108108
License: AGPL-3.0-only
109109

110-
Files: core/img/favicon*.* core/img/logo/logo*.* tests/data/testimage.webp apps/testing/img/logo.png core/img/apps/spreed.svg
110+
Files: core/img/favicon*.* core/img/logo/logo*.* tests/data/testimage.webp tests/data/broken-video.webm apps/testing/img/logo.png core/img/apps/spreed.svg
111111
Copyright: 2016-2024 Nextcloud GmbH
112112
License: LicenseRef-NextcloudTrademarks
113113

lib/private/Preview/Movie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ private function generateThumbNail(int $maxX, int $maxY, string $absPath, int $s
135135
$returnCode = -1;
136136
$output = '';
137137
if (is_resource($proc)) {
138-
$stdout = trim(stream_get_contents($pipes[1]));
139138
$stderr = trim(stream_get_contents($pipes[2]));
139+
$stdout = trim(stream_get_contents($pipes[1]));
140140
$returnCode = proc_close($proc);
141141
$output = $stdout . $stderr;
142142
}

tests/data/broken-video.webm

1.63 MB
Binary file not shown.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
6+
* SPDX-License-Identifier: AGPL-3.0-or-later
7+
*/
8+
9+
namespace Test\Preview;
10+
11+
/**
12+
* Class MovieTest
13+
*
14+
* @group DB
15+
*
16+
* @package Test\Preview
17+
*/
18+
class MovieBrokenStuckFfmpegTest extends MovieTest {
19+
protected string $fileName = 'broken-video.webm';
20+
}

tests/lib/Preview/MovieTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
* @package Test\Preview
1616
*/
1717
class MovieTest extends Provider {
18+
protected string $fileName = 'testimage.mp4';
19+
protected int $width = 560;
20+
protected int $height = 320;
21+
1822
protected function setUp(): void {
1923
$avconvBinary = \OC_Helper::findBinaryPath('avconv');
2024
$ffmpegBinary = ($avconvBinary) ? null : \OC_Helper::findBinaryPath('ffmpeg');
@@ -25,10 +29,7 @@ protected function setUp(): void {
2529
\OC\Preview\Movie::$avconvBinary = $avconvBinary;
2630
\OC\Preview\Movie::$ffmpegBinary = $ffmpegBinary;
2731

28-
$fileName = 'testimage.mp4';
29-
$this->imgPath = $this->prepareTestFile($fileName, \OC::$SERVERROOT . '/tests/data/' . $fileName);
30-
$this->width = 560;
31-
$this->height = 320;
32+
$this->imgPath = $this->prepareTestFile($this->fileName, \OC::$SERVERROOT . '/tests/data/' . $this->fileName);
3233
$this->provider = new \OC\Preview\Movie;
3334
} else {
3435
$this->markTestSkipped('No Movie provider present');

0 commit comments

Comments
 (0)