please check , if you can do it in javascript
document.getElementByTagName("video") or get the video object and try .duration
var duration = document.getElementByTagName("video").duration;
and then covert to Time format.
or you can read the Video Resource Properties like below :
Retrieve the xmpDM:value and xmpDM:scale properties from the video asset's metadata and the calculate the duration
public static String calculateVideoDuration(Resource videoResource) {
ValueMap properties = videoResource.getValueMap();
double value = properties.get("xmpDM:value", Double.class);
double scale = properties.get("xmpDM:scale", Double.class);
double durationInSeconds = value / scale;
int hours = (int) (durationInSeconds / 3600);
int minutes = (int) ((durationInSeconds % 3600) / 60);
int seconds = (int) (durationInSeconds % 60);
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
}