Reputation: 1713
My backend needs to check to see if a video is under 60 seconds, or else it doesn't add the link to the database. Is there any easy solution if I have the file on disk? Something simple like videofile.getDuration()
I checked out FFMEG on npm but I'm not sure if that's what I need or if that's even up to date.
Upvotes: 4
Views: 6829
Reputation: 599
I use ffprobe for the task.
If you follow the README
and you get to read the streams' info you will be able to get the duration by accessing the following tag on the video stream:
info.streams[0].tags.DURATION
There might be variants according to the kind of video file you are parsing, this example works with mkv
.
Upvotes: 1