Am 19.01.22 um 12:59 schrieb Bo Berglund:
On Wed, 19 Jan 2022 17:10:26 +0530, Gyan Doshi <ffm...@gyani.pro> wrote:
What do I need to just get that output I want?
The closest you can get is
ffprobe -v 0 -of compact=p=0:nk=1 -sexagesimal -show_entries
format=duration INPUT
Thanks, this returns the following output:
0:43:26.384000
Can the duration be limited to only seconds resolution (no decimals)?
function music_get_length(string $path): int
{
ob_start();
passthru("/usr/bin/ffmpeg -hide_banner -i " . escapeshellarg($path) .
' 2>&1');
$ffmpeg_buffer = ob_get_clean();
$duration = '';
$search='/Duration: (.*?),/';
$ffmpeg_buffer = preg_match($search, $ffmpeg_buffer, $matches,
PREG_OFFSET_CAPTURE, 3);
if(isset($matches[1][0]))
{
$duration_str = $matches[1][0];
if($duration_str === 'N/A')
{
return 0;
}
list($duration_hours, $duration_mins, $duration_secs) = explode(':',
$duration_str);
$duration = sprintf('%02d', (int)$duration_hours) . ':' .
sprintf('%02d', (int)$duration_mins) . ':' . sprintf('%02d',
round($duration_secs));
if($duration === '00:00:00')
{
return 0;
}
return (int)(round($duration_secs)) + ((int)$duration_mins * 60) +
((int)$duration_hours*3600);
}
return 0;
}
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".