We improve the way we pass the number of digits in the filename

This commit is contained in:
Romain Biard 2017-01-11 11:17:47 -03:00
commit 4d76b26d1d

View file

@ -105,11 +105,13 @@ class ExtractMultipleFramesFilter implements VideoFilterInterface
// Set the number of digits to use in the exported filenames // Set the number of digits to use in the exported filenames
$nbDigitsInFileNames = ceil( $duration * $nbFramesPerSecond ); $nbDigitsInFileNames = ceil( $duration * $nbFramesPerSecond );
if($nbDigitsInFileNames < 10)
$nbDigitsInFileNames = '0' . (string)$nbDigitsInFileNames;
// Set the parameters // Set the parameters
$commands[] = '-vf'; $commands[] = '-vf';
$commands[] = 'fps=' . $this->frameRate; $commands[] = 'fps=' . $this->frameRate;
$commands[] = $this->destinationFolder . 'frame-%0'.$nbDigitsInFileNames.'d.jpg'; $commands[] = $this->destinationFolder . 'frame-%'.$nbDigitsInFileNames.'d.jpg';
} }
catch (RuntimeException $e) { catch (RuntimeException $e) {
throw new RuntimeException('An error occured while extracting the frames: ' . $e->getMessage() . '. The code: ' . $e->getCode()); throw new RuntimeException('An error occured while extracting the frames: ' . $e->getMessage() . '. The code: ' . $e->getCode());