get_video_duration()

Description

Get video duration

Parameters

ColumnTypeDefaultDescription
$file_path string Path to video file

Return

float

Location

include/resource_functions.php lines 8409 to 8421

Definition

 
function get_video_duration(string $file_path)
{
    
$exiftool_fullpath get_utility_path("exiftool");

    
$duration_tag run_command($exiftool_fullpath "-n -duration %filepath"false, ["%filepath" => $file_path]);

    if (!empty(
$duration_tag)) {
        
$duration str_replace(" s"""substr($duration_tagstrpos($duration_tag":") + 2));
        return 
floatval($duration);
    } else {
        return 
0;
    }
}

This article was last updated 15th July 2025 15:35 Europe/London time based on the source file dated 10th July 2025 10:00 Europe/London time.