I need to know the duration of a video that I have uploaded to a page. I have written a PHP script for doing this:
<?php
$command = "ffmpeg -i video.mp4 2>&1 | grep Duration | awk '{print $2}' | tr -d ,; ";
$cm = shell_exec($command) ;
echo "$cm";
?>
When I execute this program via terminal it shows duration, but on calling it in a PHP page it does not give an output. Please provide me a solution....
Thanks in advance.
Function shell_exec returns all the output in a string. exec just returns the last line.
Try with this
<?php
$command = "ffmpeg -i video.mp4 2>&1 | grep Duration | awk '{print $2}' | tr -d ,; ";
echo exec($command) ;
?>