$fileInfo['video']['dataformat'] === 'quicktime'
for the dataformat of quicktime, the video duration here:
$duration = $fileInfo['playtime_seconds'];
is 10 times the real value in seconds. for example if the video is 3.34 seconds, the result is 33.4.
I wrote this ugly way around, but I wonder why this happens?
private function isIOSVideo($fileInfo): bool
{
// Check for iOS-specific data-type
if ($fileInfo['video']['dataformat'] === 'quicktime') {
return true; // Video is likely recorded on an iOS device
}
return false;
}
private function getVideoDuration($file)
{
// Initialize getID3 engine
$getID3 = new getID3();
$fileInfo = $getID3->analyze($file->getPathname());
if (isset($fileInfo['playtime_seconds'])) {
$duration = $fileInfo['playtime_seconds'];
// Apply correction factor for iOS videos if detected
if ($this->isIOSVideo($fileInfo)) {
$duration = $duration / 10;
}
return $duration; // Duration in seconds
}
return null; // Return null if duration cannot be extracted
}
$fileInfo['video']['dataformat'] === 'quicktime'
for the dataformat of quicktime, the video duration here: $duration = $fileInfo['playtime_seconds']; is 10 times the real value in seconds. for example if the video is 3.34 seconds, the result is 33.4. I wrote this ugly way around, but I wonder why this happens?