Created
April 13, 2016 05:39
-
-
Save JacobHsu/bf409ae4add54e477f53e09c27e4eaaf to your computer and use it in GitHub Desktop.
#ffmpeg #PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ffmpeg_location ='"C:\Program Files\ffmpeg-20140928-git-3edb9aa-win64-static\bin\ffmpeg.exe"'; | |
$file_path = 'C:\\ed2b6a653ded.mp4'; | |
$src_cover = 'C:\src_cover.jpg'; | |
$ffm = $ffmpeg_location . ' -i '. $file_path . ' -ss 00:00:01 -f image2 -vframes 1 ' . $src_cover.' 2>&1'; | |
$xyz = shell_exec($ffm); | |
$search='/Duration: (.*?),/'; | |
preg_match($search, $xyz, $matches); | |
$duration = explode(':', $matches[1]); | |
echo 'Hour: ' . $duration[0]; | |
echo 'Minute: ' . $duration[1]; | |
echo 'Seconds: ' . $duration[2]; | |
$duration_in_seconds = $duration[0]*3600 + $duration[1]*60+ round($duration[2]); | |
echo 'Total Seconds: ' . $duration_in_seconds; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment