Completed
Push — master ( 7619f7...567a98 )
by
unknown
29:04 queued 10s
created
lib/private/Preview/Movie.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 			}
89 89
 			if ($absPath === false) {
90 90
 				Server::get(LoggerInterface::class)->error(
91
-					'Failed to get local file to generate thumbnail for: ' . $file->getPath(),
91
+					'Failed to get local file to generate thumbnail for: '.$file->getPath(),
92 92
 					['app' => 'core']
93 93
 				);
94 94
 				return null;
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 				}
103 103
 				Server::get(LoggerInterface::class)->debug(
104 104
 					'Movie preview generation attempt failed'
105
-						. ', file=' . $file->getPath()
106
-						. ', time=' . $timeStamp
107
-						. ', size=' . ($size ?? 'entire file'),
105
+						. ', file='.$file->getPath()
106
+						. ', time='.$timeStamp
107
+						. ', size='.($size ?? 'entire file'),
108 108
 					['app' => 'core']
109 109
 				);
110 110
 			}
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 			if ($result !== null) {
115 115
 				Server::get(LoggerInterface::class)->debug(
116 116
 					'Movie preview generation attempt success'
117
-						. ', file=' . $file->getPath()
118
-						. ', time=' . $timeStamp
119
-						. ', size=' . ($size ?? 'entire file'),
117
+						. ', file='.$file->getPath()
118
+						. ', time='.$timeStamp
119
+						. ', size='.($size ?? 'entire file'),
120 120
 					['app' => 'core']
121 121
 				);
122 122
 				break;
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
 		if ($result === null) {
127 127
 			Server::get(LoggerInterface::class)->error(
128 128
 				'Movie preview generation process failed'
129
-					. ', file=' . $file->getPath(),
129
+					. ', file='.$file->getPath(),
130 130
 				['app' => 'core']
131 131
 			);
132 132
 		}
133 133
 		return $result;
134 134
 	}
135 135
 
136
-	private function getSparseFile(File $file, int $size): string|false {
136
+	private function getSparseFile(File $file, int $size): string | false {
137 137
 		// File is smaller than $size or file is larger than max int size
138 138
 		// of the host so return false so getLocalFile method is used
139 139
 		if (($size >= $file->getSize()) || ($file->getSize() > PHP_INT_MAX)) {
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		$absPath = Server::get(ITempManager::class)->getTemporaryFile();
151 151
 		if ($absPath === false) {
152 152
 			Server::get(LoggerInterface::class)->error(
153
-				'Failed to get temp file to create sparse file to generate thumbnail: ' . $file->getPath(),
153
+				'Failed to get temp file to create sparse file to generate thumbnail: '.$file->getPath(),
154 154
 				['app' => 'core']
155 155
 			);
156 156
 			fclose($content);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		$sparseFile = fopen($absPath, 'w');
160 160
 
161 161
 		// Firsts 4 bytes indicate length of 1st atom.
162
-		$ftypSize = (int)hexdec(bin2hex(stream_get_contents($content, 4, 0)));
162
+		$ftypSize = (int) hexdec(bin2hex(stream_get_contents($content, 4, 0)));
163 163
 		// Download next 4 bytes to find name of 1st atom.
164 164
 		$ftypLabel = stream_get_contents($content, 4, 4);
165 165
 
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
 			// EOF is reached
175 175
 			while (($offset + 8 < $file->getSize()) && ($moovSize === 0)) {
176 176
 				// First 4 bytes of atom header indicates size of the atom.
177
-				$atomSize = (int)hexdec(bin2hex(stream_get_contents($content, 4, (int)$offset)));
177
+				$atomSize = (int) hexdec(bin2hex(stream_get_contents($content, 4, (int) $offset)));
178 178
 				// Next 4 bytes of atom header is the name/label of the atom
179
-				$atomLabel = stream_get_contents($content, 4, (int)($offset + 4));
179
+				$atomLabel = stream_get_contents($content, 4, (int) ($offset + 4));
180 180
 				// Size value has two special values that don't directly indicate size
181 181
 				// 0 = atom size equals the rest of the file
182 182
 				if ($atomSize === 0) {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 					// 1 = read an additional 8 bytes after the label to get the 64 bit
186 186
 					// size of the atom. Needed for large atoms like 'mdat' (the video data)
187 187
 					if ($atomSize === 1) {
188
-						$atomSize = (int)hexdec(bin2hex(stream_get_contents($content, 8, (int)($offset + 8))));
188
+						$atomSize = (int) hexdec(bin2hex(stream_get_contents($content, 8, (int) ($offset + 8))));
189 189
 						// 0 in the 64 bit field should not occur in a valid file, stop processing
190 190
 						if ($atomSize === 0) {
191 191
 							return false;
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 				return false;
215 215
 			}
216 216
 			// Generate new file of same size
217
-			ftruncate($sparseFile, (int)($file->getSize()));
217
+			ftruncate($sparseFile, (int) ($file->getSize()));
218 218
 			fseek($sparseFile, 0);
219 219
 			fseek($content, 0);
220 220
 			// Copy first $size bytes of video into new file
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 			// so no need to download it again.
225 225
 			if ($moovOffset + $moovSize >= $size) {
226 226
 				// Seek to where 'moov' atom needs to be placed
227
-				fseek($content, (int)$moovOffset);
228
-				fseek($sparseFile, (int)$moovOffset);
229
-				stream_copy_to_stream($content, $sparseFile, (int)$moovSize, 0);
227
+				fseek($content, (int) $moovOffset);
228
+				fseek($sparseFile, (int) $moovOffset);
229
+				stream_copy_to_stream($content, $sparseFile, (int) $moovSize, 0);
230 230
 			}
231 231
 		} else {
232 232
 			// 'ftyp' atom not found, not a valid MP4/MOV
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		fclose($content);
238 238
 		fclose($sparseFile);
239 239
 		Server::get(LoggerInterface::class)->debug(
240
-			'Sparse file being utilized for preview generation for ' . $file->getPath(),
240
+			'Sparse file being utilized for preview generation for '.$file->getPath(),
241 241
 			['app' => 'core']
242 242
 		);
243 243
 		return $absPath;
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
 
246 246
 	private function useHdr(string $absPath): bool {
247 247
 		// load ffprobe path from configuration, otherwise generate binary path using ffmpeg binary path
248
-		$ffprobe_binary = $this->config->getSystemValue('preview_ffprobe_path', null) ?? (pathinfo($this->binary, PATHINFO_DIRNAME) . '/ffprobe');
248
+		$ffprobe_binary = $this->config->getSystemValue('preview_ffprobe_path', null) ?? (pathinfo($this->binary, PATHINFO_DIRNAME).'/ffprobe');
249 249
 		// run ffprobe on the video file to get value of "color_transfer"
250
-		$test_hdr_cmd = [$ffprobe_binary,'-select_streams', 'v:0',
250
+		$test_hdr_cmd = [$ffprobe_binary, '-select_streams', 'v:0',
251 251
 			'-show_entries', 'stream=color_transfer',
252 252
 			'-of', 'default=noprint_wrappers=1:nokey=1',
253 253
 			$absPath];
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 		$tmpPath = Server::get(ITempManager::class)->getTemporaryFile();
274 274
 		if ($tmpPath === false) {
275 275
 			Server::get(LoggerInterface::class)->error(
276
-				'Failed to get local file to generate thumbnail for: ' . $absPath,
276
+				'Failed to get local file to generate thumbnail for: '.$absPath,
277 277
 				['app' => 'core']
278 278
 			);
279 279
 			return null;
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
 			if ($this->useHdr($absPath)) {
286 286
 				// Force colorspace to '2020_ncl' because some videos are
287 287
 				// tagged incorrectly as 'reserved' resulting in fail if not forced.
288
-				$cmd = [$this->binary, '-y', '-ss', (string)$second,
288
+				$cmd = [$this->binary, '-y', '-ss', (string) $second,
289 289
 					'-i', $absPath,
290 290
 					'-f', 'mjpeg', '-vframes', '1',
291 291
 					'-vf', 'zscale=min=2020_ncl:t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p',
292 292
 					$tmpPath];
293 293
 			} else {
294 294
 				// always default to generating preview using non-HDR command
295
-				$cmd = [$this->binary, '-y', '-ss', (string)$second,
295
+				$cmd = [$this->binary, '-y', '-ss', (string) $second,
296 296
 					'-i', $absPath,
297 297
 					'-f', 'mjpeg', '-vframes', '1',
298 298
 					$tmpPath];
@@ -310,12 +310,12 @@  discard block
 block discarded – undo
310 310
 			$stderr = trim(stream_get_contents($pipes[2]));
311 311
 			$stdout = trim(stream_get_contents($pipes[1]));
312 312
 			$returnCode = proc_close($proc);
313
-			$output = $stdout . $stderr;
313
+			$output = $stdout.$stderr;
314 314
 		}
315 315
 
316 316
 		Server::get(LoggerInterface::class)->debug(
317 317
 			'Movie preview generation output'
318
-				. ', file=' . $absPath
318
+				. ', file='.$absPath
319 319
 				. ', output=',
320 320
 			['app' => 'core', 'output' => $output]
321 321
 		);
Please login to merge, or discard this patch.