I am writing a program to split a video into a specified number of subclips, so I need a list of tuples [(0,t1),(t1,t2),(t2,t3),...,(tn,T)]
where T
is the length of the video (in this case the number of subclips is n+1
, which should be an input from user).
Assume that I have a list of lists of floating point numbers, like the following:
time_pt_nested_list =
[[0.0, 6.131, 32.892, 43.424, 46.969, 108.493, 142.69, 197.025, 205.793, 244.582, 248.913, 251.518, 258.798, 264.021, 330.02, 428.965],
[11.066, 35.73, 64.784, 151.31, 289.03, 306.285, 328.7, 408.274, 413.64],
[48.447, 229.74, 293.19, 333.343, 404.194, 418.575],
[66.37, 242.16, 356.96, 424.967],
[78.711, 358.789, 403.346],
[84.454, 373.593, 422.384],
[102.734, 394.58],
[158.534],
[210.112],
[247.61],
[340.02],
[365.146],
[372.153]]
All the returned tuples should only contain the floating point numbers inside the nested list above. The first list in the nested list indicates that I want to assign the highest probability to them to be sampled and appear in the returned tuples, the second list a slightly lower probability, etc. In other words, the probabilities for the elements of time_pt_nested_list[idx]
to appear in the returned tuples should decrease when idx
increases. The exact details of these probabilities are not important, but it would be nice if the user can input a parameter that controls how fast the probability decays when idx
increases.
The returned tuples are timeframes that should exactly cover the entire video and should not overlap. 0
and T
may not necessarily appear in time_pt_nested_list
(but they may). Are there nice ways to implement this? I would be grateful for any insightful suggestions.
For example if the user inputs 6 as the number of subclips, then this will be an example output:
[(0.0, 32.892), (32.892, 64.784), (64.784, 229.74), (229.74, 306.285), (306.285, 418.575), (418.575, 437.47)]
All numbers appearing in the tuples appeared in time_pt_nested_list
, except 0.0
and 437.47
. (Well 0.0
does appear here but may not in other cases) Here 437.47
is the length of video which is also given and may not appear in the list.