As Rodrigo Polo suggested using mediainfo --Inform="General;%Duration%" input.m4v , perhaps, but returns strange results.
For example, for a video with a duration of 41 s 564 ms, the output of this command will be:
41564
This is not suitable for me, and I came up with the following solution:
mediainfo --Inform="Video;%Duration/String3%" input.m4v
Return value:
00:00:41.564
In the end, you can simply format the return value with PHP to convert it to seconds, for example:
$parsed = date_parse( '00:00:41.564' ); echo $parsed['hour'] * 3600 + $parsed['minute'] * 60 + $parsed['second'];
Final conclusion:
41
Example
Learn more about MediaInfo CLI
source share