Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For apple videos, the duration is off by 10 times! #456

Open
vhdmoradi opened this issue Oct 6, 2024 · 1 comment
Open

For apple videos, the duration is off by 10 times! #456

vhdmoradi opened this issue Oct 6, 2024 · 1 comment

Comments

@vhdmoradi
Copy link

vhdmoradi commented Oct 6, 2024

$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
    }
@JamesHeinrich
Copy link
Owner

I'd need a sample file that shows this behaviour to even guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants