m6web / timecode
Lib allowing to deal with timecode manipulation
Installs: 113 289
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 45
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
Requires (Dev)
- atoum/atoum: 4.0.*
- atoum/stubs: *
- m6web/coke: 2.1.*
- m6web/php-cs-fixer-config: 2.0.*
README
Tiny PHP library to deal with (SMPTE) timecode through Timecode object representation.
Installation
composer require m6web/timecode
Usage
<?php require __DIR__.'/vendor/autoload.php'; use M6Web\Component\Timecode\Timecode; // Let's say we want to create a timecode corresponding to 9hours, 2minutes, 0seconds and 3frames with a framerate of 25 (which is the default framerate btw) // We could either create it like any other PHP objects $timecode = new Timecode(9, 2, 0, 3, 25); // hours, minutes, seconds, frames, framerate // Or simply using its string representation $timecode = Timecode::createFromString('09:02:00:03', 25); // Or even using its total number of frames $timecode = Timecode::createFromNumberOfFrames(813003, 25); // Now let's say we want to subtract 5hours from our timecode $resultTimecode = $timecode->sub(new Timecode(5, 0, 0, 0)); $resultTimecode->getHours(); // 4 $resultTimecode->getMinutes(); // 2 $resultTimecode->getSeconds(); // 0 $resultTimecode->getFrames(); // 3 echo $resultTimecode; // '04:02:00:03'