Skip to content

Commit

Permalink
Revert "TTK-27336: Add check duration to PR files (#671)"
Browse files Browse the repository at this point in the history
This reverts commit ab65592.
  • Loading branch information
albacodina committed Dec 17, 2024
1 parent bad9060 commit 35bc328
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion config/services.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 3 additions & 16 deletions src/Pumukit/InspectionBundle/Services/InspectionFfprobeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 35bc328

Please sign in to comment.