Am using the following code to detect video duration before uploading using ffmpeg, but it doesn’t seem to work:
JavaScript
x
<?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.
Advertisement
Answer
i used https://github.com/wseemann/FFmpegMediaMetadataRetriever
with following code to retrive video duration
JavaScript
FFmpegMediaMetadataRetriever mmr = new FFmpegMediaMetadataRetriever();
mmr.setDataSource(mUri);
String time = mmr.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_DURATION);
int VideoDuration = Integer.parseInt(time);
mmr.release();