Skip to content

Instantly share code, notes, and snippets.

@robozavri
Created December 20, 2018 12:47
Show Gist options
  • Select an option

  • Save robozavri/0d2b58498321b866a7260acff836f334 to your computer and use it in GitHub Desktop.

Select an option

Save robozavri/0d2b58498321b866a7260acff836f334 to your computer and use it in GitHub Desktop.
php audio duration ffmpeg laravel laraadmin
// Line 180 ზე laraadmin ის UplaodController
$filepath = $file_date_folder.'/'.$filename;
$result = shell_exec("ffmpeg -i ".$filepath.' 2>&1 | grep -o \'Duration: [0-9:.]*\'');
$duration = str_replace('Duration: ', '', $result); // 00:05:03.25
//get the duration in seconds
$timeArr = preg_split('/:/', str_replace('s', '', $duration[0]));
$t = (($timeArr[3])? $timeArr[3]*1 + $timeArr[2] * 60 + $timeArr[1] * 60 * 60 : $timeArr[2] + $timeArr[1] * 60)*1000;
Log::info( $duration );
Log::info( $result );
Log::info($t);
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment