File tree Expand file tree Collapse file tree 1 file changed +46
-1
lines changed Expand file tree Collapse file tree 1 file changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -233,15 +233,60 @@ public function calculateFrameCountWithDropFrame() : float
233
233
}
234
234
235
235
/**
236
- * Get total of seconds based on frame count
236
+ * Get total duration in seconds based on frame count, rounded down to the nearest second
237
237
*
238
238
* @return int
239
239
*/
240
240
public function durationInSeconds () : int
241
+ {
242
+ return (int ) ($ this ->frameCount / $ this ->frameRate );
243
+ }
244
+
245
+ /**
246
+ * Get total duration in seconds based on frame count, rounded to the nearest second
247
+ *
248
+ * @return int
249
+ */
250
+ public function durationInSecondsRounded () : int
241
251
{
242
252
return (int ) round ($ this ->frameCount / $ this ->frameRate );
243
253
}
244
254
255
+ /**
256
+ * Get total duration in seconds based on frame count, rounded to the nearest second
257
+ * Ensures a minimum of 1 second if frames are present
258
+ *
259
+ * @return int
260
+ */
261
+ public function durationInSecondsRoundedMinOne () : int
262
+ {
263
+ if ($ this ->frameCount === 0 ) {
264
+ return 0 ;
265
+ }
266
+
267
+ return max (1 , (int ) round ($ this ->frameCount / $ this ->frameRate ));
268
+ }
269
+
270
+ /**
271
+ * Get total duration in seconds based on frame count, rounded up to the nearest second
272
+ *
273
+ * @return int
274
+ */
275
+ public function durationInSecondsRoundedUp () : int
276
+ {
277
+ return (int ) ceil ($ this ->frameCount / $ this ->frameRate );
278
+ }
279
+
280
+ /**
281
+ * Get total duration in seconds with fractional precision based on frame count
282
+ *
283
+ * @return float
284
+ */
285
+ public function durationInSecondsWithFractions () : float
286
+ {
287
+ return $ this ->frameCount / $ this ->frameRate ;
288
+ }
289
+
245
290
/**
246
291
* Adds a timecode or a frame count to the current SMPTE object
247
292
*
You can’t perform that action at this time.
0 commit comments