Am using the following code to detect video duration before uploading using ffmpeg, but it doesn't seem to work:
<?php
$file=sample.avi;
$time = exec("$ffmpeg -i /path/".$file." 2>&1 |
grep Duration | cut -d ' ' -f 4 | sed s/,//");
echo $time;
?>
I need to echo video duration as text input to sql before uploading file to server.
i used https://github.com/wseemann/FFmpegMediaMetadataRetriever
with following code to retrive video duration
FFmpegMediaMetadataRetriever mmr = new FFmpegMediaMetadataRetriever();
mmr.setDataSource(mUri);
String time = mmr.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_DURATION);
int VideoDuration = Integer.parseInt(time);
mmr.release();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.