PHPackages                             fireworkweb/smpte - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fireworkweb/smpte

ActiveProject[Utility &amp; Helpers](/categories/utility)

fireworkweb/smpte
=================

Easily deal with Timecode SMPTE format in PHP

1.6.0(1y ago)732.5k↑19.4%8[3 issues](https://github.com/fireworkweb/smpte.php/issues)MITPHPPHP ^7.1|^8.0CI failing

Since Nov 6Pushed 1y ago2 watchersCompare

[ Source](https://github.com/fireworkweb/smpte.php)[ Packagist](https://packagist.org/packages/fireworkweb/smpte)[ RSS](/packages/fireworkweb-smpte/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (1)Versions (8)Used By (0)

smpte.php
=========

[](#smptephp)

[![Build Status](https://camo.githubusercontent.com/bf43e638062182573867f00bc30d8aa18134dcfd3e90ff72a9b41c5eefce6812/68747470733a2f2f7472617669732d63692e636f6d2f66697265776f726b7765622f736d7074652e7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/fireworkweb/smpte.php)[![codecov](https://camo.githubusercontent.com/9b0ade602f76c701b8a67ed57977c1f9976ca7432dbf664d441ea942176646aa/68747470733a2f2f636f6465636f762e696f2f67682f66697265776f726b7765622f736d7074652e7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/fireworkweb/smpte.php)

Easily deal with SMPTE Timecode format in PHP. If you need a Javascript lib, check out [fireworkweb/smpte.js](https://github.com/fireworkweb/smpte.js).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require fireworkweb/smpte
```

Usage
-----

[](#usage)

Include the Timecode or Validations classes:

```
use FireworkWeb\SMPTE\Timecode;
use FireworkWeb\SMPTE\Validations;
```

You can instantiate it directly using new:

```
// passing frame count
$timecode = new Timecode(360);

// passing a timecode string
$timecode = new Timecode('00:00:01:10');

// passing a Datetime object
$timecode = new Timecode(new \DateTime('01:34:12'));
```

Or you can use the static helper:

```
$timecode = Timecode::fromSeconds(10);
```

### Properties

[](#properties)

PropertyTypeDescription`getFrameCount()``int`Total number of frames`getHours()``int`Hours number`getMinutes()``int`Minutes number`getSeconds()``int`Seconds number`getFrames()``int`Frames number`durationInSeconds()``int`Timecode duration in seconds### Object Methods

[](#object-methods)

#### `__construct($time = 0, $frameRate = null, $dropFrame = null)`

[](#__constructtime--0-framerate--null-dropframe--null)

- `$time`: `int|String|Timecode` time to start with.
- `$frameRate`: `float` frame rate to calculate the timecode.
- `$dropFrame`: `bool` indicates if is drop frame. **ONLY WITH 29.97 FPS**

`$time` as int is the frame count to be setted with. To deal with seconds, use `fromSeconds`.

**Note:** if `$frameRate` or `$dropFrame` are null, it will use the default.

#### `toString()` / `__toString()`

[](#tostring--__tostring)

Returns a timecode string representation.

```
(new Timecode(360))->toString();
// "00:00:15:00"
```

#### `add($time, $operation = 1)`

[](#addtime-operation--1)

Adds a timecode or a frame count to the current Timecode object.

- `$time`: `int|String|Timecode` indicating the value to be added.
- `$operation`: `int` used to get the sign of `time`.
- `return`: `Timecode` Reference to the `Timecode` object.

```
$tc = new Timecode('00:01:00:00');

// Adding from string
$tc->add('00:00:30:00')->toString();
// 00:01:30:00

// Adding frame count
$tc->add(1)->toString();
// 00:01:30:01

// Adding from another object
$tc2 = new Timecode('00:01:00:00');
$tc->add($tc2)->toString();
// 00:02:30:01
```

#### `subtract($time)`

[](#subtracttime)

Substracts a timecode or a frame count to the current Timecode object.

- `$time`: `int|String|Timecode` indicating the value to be added.
- `return`: `Timecode` Reference to the `Timecode` object.

```
$tc = new Timecode('00:03:00:00');

// Subtracting from string
$tc->subtract('00:00:30:00')->toString();
// 00:02:30:00

// Subtracting frame count
$tc->subtract(1)->toString();
// 00:02:29:23

// Subtracting from another object
$tc2 = new Timecode('00:01:00:00');
$tc->subtract($tc2)->toString();
// 00:01:29:23
```

#### `setHours($hours)`

[](#sethourshours)

Directly set object hours.

- `$hours`: `int` indicating the value to be setted.

```
$tc = new Timecode('00:03:00:00');
$tc->setHours(1)->toString();
// 01:03:00:00
```

#### `setMinutes($minutes)`

[](#setminutesminutes)

Directly set object minutes.

- `$minutes`: `int` indicating the value to be setted.

```
$tc = new Timecode('00:03:00:00');
$tc->setMinutes(1)->toString();
// 00:01:00:00
```

#### `setSeconds($seconds)`

[](#setsecondsseconds)

Directly set object seconds.

- `$seconds`: `int` indicating the value to be setted.

```
$tc = new Timecode('00:03:00:00');
$tc->setSeconds(1)->toString();
// 00:03:01:00
```

#### `setFrames($frames)`

[](#setframesframes)

Directly set object frames.

- `$frames`: `int` indicating the value to be setted.

```
$tc = new Timecode('00:03:00:00');
$tc->setFrames(1)->toString();
// 00:03:00:01
```

#### `setFrameCount($frameCount)`

[](#setframecountframecount)

Directly set object frame count. This will recalculate all other attributes, so use it with care.

- `$frameCount`: `int` indicating the value to be setted.

```
$tc = new Timecode('00:03:00:00');
$tc->setFrameCount(360)->toString();
// 00:00:15:00
```

### Static Methods

[](#static-methods)

#### `frameCountFromTimecode($time, $frameRate = null, $dropFrame = null)`

[](#framecountfromtimecodetime-framerate--null-dropframe--null)

Returns the frame count from a time.

- `$time`: `String` time as string to calculate.
- `$frameRate`: `float` frame rate to calculate the timecode.
- `$dropFrame`: `bool` indicates if is drop frame.
- `return`: `int` returns the frame count

#### `fromSeconds($seconds, $frameRate = null, $dropFrame = null)`

[](#fromsecondsseconds-framerate--null-dropframe--null)

Instantiate a new object from seconds instead of timecode/framecount.

- `$seconds`: `int` seconds to convert
- `$frameRate`: `float` frame rate to calculate the timecode.
- `$dropFrame`: `bool` indicates if is drop frame.
- `return`: `Timecode` Returns the newly created object

```
$tc = Timecode::fromSeconds(15);
$tc->toString();
// 00:00:15:00
```

#### `setDefaultFrameRate($frameRate)`

[](#setdefaultframerateframerate)

Change default frame rate to instantiate objects with.

- `$frameRate`: `float` New default frame rate.

```
$tc = new Timecode();
$tc->getFrameRate();
// 24

Timecode::setDefaultFrameRate(25);

$tc2 = new Timecode();
$tc2->getFrameRate();
// 25
```

#### `setDefaultDropFrame($dropFrame)`

[](#setdefaultdropframedropframe)

Change default drop frame to instantiate objects with.

- `$dropFrame`: `float` New default drop frame.

```
$tc = new Timecode();
$tc->getDropFrame();
// false

Timecode::setDefaultDropFrame(true);

$tc2 = new Timecode();
$tc2->getDropFrame();
// true
```

Contributing
------------

[](#contributing)

All contribution is welcome, please feel free to open tickets and pull requests.

License
-------

[](#license)

[MIT.](LICENSE)

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 57.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~365 days

Recently: every ~482 days

Total

7

Last Release

559d ago

PHP version history (3 changes)1.0.0PHP ^7.0

1.2.0PHP ^7.1

1.3.0PHP ^7.1|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/347400?v=4)[Daniel Polito](/maintainers/dbpolito)[@dbpolito](https://github.com/dbpolito)

![](https://www.gravatar.com/avatar/63a1273e47a05f473dbbc6a066ffe0f2f6e3ba9d7721f572c8d879f131a5036f?d=identicon)[gabrielboliveira](/maintainers/gabrielboliveira)

---

Top Contributors

[![gabrielboliveira](https://avatars.githubusercontent.com/u/11093090?v=4)](https://github.com/gabrielboliveira "gabrielboliveira (22 commits)")[![dbpolito](https://avatars.githubusercontent.com/u/347400?v=4)](https://github.com/dbpolito "dbpolito (5 commits)")[![matheuswsantos](https://avatars.githubusercontent.com/u/13200878?v=4)](https://github.com/matheuswsantos "matheuswsantos (5 commits)")[![seabasss](https://avatars.githubusercontent.com/u/5251896?v=4)](https://github.com/seabasss "seabasss (3 commits)")[![eckelarsson](https://avatars.githubusercontent.com/u/2752093?v=4)](https://github.com/eckelarsson "eckelarsson (2 commits)")[![cristianpana86](https://avatars.githubusercontent.com/u/13106810?v=4)](https://github.com/cristianpana86 "cristianpana86 (1 commits)")

---

Tags

composerlaravelphpsmptetimecodesubtitletimecodesmpte

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fireworkweb-smpte/health.svg)

```
[![Health](https://phpackages.com/badges/fireworkweb-smpte/health.svg)](https://phpackages.com/packages/fireworkweb-smpte)
```

###  Alternatives

[captioning/captioning

A collection of tools to manipulate subtitles

2261.3M7](/packages/captioning-captioning)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
