m6web/timecode

Lib allowing to deal with timecode manipulation

v1.0.0 2022-02-25 10:52 UTC

This package is auto-updated.

Last update: 2024-11-29 05:32:33 UTC


README

Build Status Latest Stable Version Total Downloads License PHP Version Require

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'