Categories
Uncategorized

FFMPEG – Get Video Duration

<?php
$error      = '';
$duration   = 0;

try {
	$ffmpeg = FFMpeg\FFMpeg::create();
} catch ( Exception $ffmpeg ) {
	$error = $ffmpeg->getMessage();
}

if ( empty( trim( $error ) ) ) {
    $ff_probe = FFMpeg\FFProbe::create();
	$duration = $ff_probe->streams( get_attached_file( $video['id'] ) )->videos()->first()->get( 'duration' );
	
}

Leave a Reply

Your email address will not be published. Required fields are marked *