Hi, I’m looking for a freelance Strapi developer who has experience with custom plugins/plugin extension.
I need to extend the Strapi Media Library plugin so that when I upload a video to the library, the duration of the video is stored. Some more info…
When uploading a video to the (standard) Media Library in Strapi V4 running on Strapi Cloud, I need to capture the duration/length of the video so that I can retrieve the video duration through the API.
I understand that calculating the duration is normally done via the front-end when a video file is loaded into a video player (for example, I can see each video duration when inspecting the files in Strapi Admin > Media Library) but in my case, I need to store the duration so that it appears as a field in the API response when populating ‘Media’.
For example:
{
"id": 3,
"attributes": {
"createdAt": "2023-05-23T09:19:52.076Z",
...
"media": {
"data": {
"id": 7,
"attributes": {
"name": "pexels-julia-m-cameron-4498849-3840x2160-50fps.mp4",
"alternativeText": null,
"caption": null,
"width": null,
"height": null,
"formats": null,
"hash": "pexels_julia_m_cameron_4498849_3840x2160_50fps_f186b411f6",
"ext": ".mp4",
"mime": "video/mp4",
"size": 13290.27,
"duration": 120, <--- WOW! Duration in seconds 🙂
...
}
}
},
"localizations": {
"data": []
}
}
}
Please drop me a message if you can help. Thanks!