Does cloudinary trim videos exactly according to start offset and duration parameter?

Options
Neha_Sharma
Neha_Sharma Member Posts: 14
edited March 28 in Developer APIs

We generated this reel https://res.cloudinary.com/ddyewklhk/video/upload/c_fill,du_9.0,h_1080,so_8.0,w_1920/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_12.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_20.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_23.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_33.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_39.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_46.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_52.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_62.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_69.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_78.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_86.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_91.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_98.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_104.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_110.0,w_1920/fl_layer_apply/fl_splice,l_video:ballerappCloudinary:2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4:1711522420100/c_fill,du_9.0,h_1080,so_116.0,w_1920/fl_layer_apply/v1/ballerappCloudinary/2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4/1711522420100


In this we have merged 17 clips each of exact duration 9.0. We expected video duration to be sum of clips that is 17 multiplied by 9,  153 seconds. Although cloudinary is generating video of seconds 153.8333 seconds. Some browsers like chrome is showing 153 seconds but some browsers like safari are showing duration as 154 seconds.  We need to know how to trim videos exactly? Is there a way we can get exact duration of cloudinary url?

Answers

  • DannyFromCloudinary
    DannyFromCloudinary Member, Cloudinary Staff Posts: 119
    Options

    Hi Neha.

    Thanks for getting in touch. When we trim a clip using du_, there are often a few additional miliseconds included. If we take a look at https://res.cloudinary.com/ddyewklhk/video/upload/c_fill,du_9.0,h_1080,so_8.0,w_1920/ballerappCloudinary/2056FC30-19B7-4E3B-9F87-91A8C6861D25-NL-merged.mp4/1711522420100 for instance and run mediainfo on it, I see the duration is 9.067s. Because the requested start and end offsets differ between each of the clips you're using, the number of additional milliseconds also differs, so when we add them all together, we get a duration that differs from what you may expect.

    In terms of having different browsers have a consistent number of seconds, I'm afraid this is down to the browser developers, rather than us. Some may choose to round up, others may choose to round down - it's all about how they choose to interpret the video metadata.

    I hope this helps.

    Kind regards,

    -Danny