kaltura / nginx-vod-module

NGINX-based MP4 Repackager
GNU Affero General Public License v3.0
2k stars 439 forks source link

clipFrom / duration parameter clarification #1277

Open jakew009 opened 3 years ago

jakew009 commented 3 years ago

In the below example should the durations be the original video clip duration, or the duration after it has been clipped?

{
   "playlistType":"vod",
   "discontinuity":true,
   "durations":[
      302994,
      300001,
      300002
   ],
   "sequences":[
      {
         "clips":[
            {
               "type":"source",
               "path":"/mnt/sda1/onvp/recordings/camera_459_2/2021/05/24/videos/camera_459_2-04-59-09.146895.mp4",
               "clipFrom":50854
            },
            {
               "type":"source",
               "path":"/mnt/sda1/onvp/recordings/camera_459_2/2021/05/24/videos/camera_459_2-05-04-12.141005.mp4"
            },
            {
               "type":"source",
               "path":"/mnt/sda1/onvp/recordings/camera_459_2/2021/05/24/videos/camera_459_2-06-59-24.172927.mp4",
               "clipTo":300002
            }
         ]
      }
   ]
}
jakew009 commented 3 years ago

Somewhat answering my own question I am now fairly confident that the duration provided needs to be the resulting duration after the clip has been 'clipped' as otherwise the results are all over the place.

My interesting problem is now that if I try and generate a JPEG thumbnail from a video with very short duration, it fails, I assume because there were no keyframes in the little bit available to it.

I guess the browser won't be able to play it anyway though if such a little 'piece' becomes part of a HLS manifest.

francoism90 commented 2 years ago

@jakew009 Did you ever solved this? I think I'm having the same issue with calculating durations.

spinitron commented 2 years ago

The README distinguishes between "Source Clip" and "Clip". (I think of the Source Clip as the source file.) "durations" is of the Clips, not the Source Clips/source files.

For example, say you have a source file that is 60 seconds long and the mapper says "clipFrom":40000 then you probably want a clip duration of not more than 20000. If its clip duration is 60000 then the module will produce segments with 40-seconds worth of nothing in them.

Or think of it another way. Imagine you have one big source file and you want to make a sequence that includes multiple different clips taken from it. "durations" is of the clips.