diff --git a/config/services.yaml b/config/services.yaml index eb8adb7f1..b3d858b38 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -1,5 +1,5 @@ parameters: - pumukit.inspection.command: ffprobe -v quiet -print_format json -show_format -show_streams -show_frames {{file}} + pumukit.inspection.command: ffprobe -v quiet -print_format json -show_format -show_streams {{file}} pumukit.picextractor.command: ffmpeg -ss {{ss}} -y -i {{input}} -r 1 -vframes 1 -s {{size}} -f image2 {{output}} pumukit.dynamicpicextractor.command: ffmpeg -i {{input}} -ss 00:00:05 -t 3 -quality 80 -r 10 -s {{width}}x{{height}} {{output}} pumukit.warning_on_unpublished: false diff --git a/src/Pumukit/InspectionBundle/Services/InspectionFfprobeService.php b/src/Pumukit/InspectionBundle/Services/InspectionFfprobeService.php index 9cb092740..1b0b16db1 100644 --- a/src/Pumukit/InspectionBundle/Services/InspectionFfprobeService.php +++ b/src/Pumukit/InspectionBundle/Services/InspectionFfprobeService.php @@ -33,25 +33,12 @@ public function getDuration(string $file): int throw new \InvalidArgumentException('This file has no accessible video '."nor audio tracks\n".$file); } + $duration = 0; if (isset($json->format->duration)) { - return (int) ceil((float) $json->format->duration); + $duration = (int) ceil((float) $json->format->duration); } - if (empty($json->frames)) { - throw new \RuntimeException('Cannot calculate duration: no frames available.'); - } - - $firstFrame = reset($json->frames); - if (!isset($firstFrame->pts_time)) { - throw new \RuntimeException('Cannot calculate duration: first frame timestamp not available.'); - } - - $lastFrame = end($json->frames); - if (!isset($lastFrame->pts_time)) { - throw new \RuntimeException('Cannot calculate duration: last frame timestamp not available.'); - } - - return (int) round((float) $lastFrame->pts_time - (float) $firstFrame->pts_time); + return $duration; } public function getFileMetadata(?Path $path)