0

I am trying to figure out how to process a special video for an application that I trying to build. After days of research, I cannot figure out how to achieve what I am trying to build:

The user passes in a video that is X minutes long. The video was produced was stitching together multiple videos of variable length(with a maximum length per video of K seconds, say 60). The purpose of the app is to detect when each video starts and ends within the larger video of X minutes.

For example, the user passes in a video that is 25(this is X) minutes long. We know that a single video cannot be more than 10(this is K) minutes. So the maximum number of videos that the user could have stitched together to produce the input video is 3 videos(Two ten minute videos and one 5 minute video). But this is not always case, another possible combination is(Five 5 minute videos, etc).

I've been researching this for days and cannot come up with any way mathematically to solve this(very possibly due to my limited math knowledge). Is it possible to solve this problem(where each of the stitched videos begin and end)?

Thank you for any help! It's sincerely appreciated.

user1320885
  • 135
  • 1
  • 15

1 Answers1

0

If you want to use only integer units (munutes, seconds), then calculate two values

R = X % K  - integer modulo 7 % 3 = 1, residue
M = X / K   -integer division  7 / 3 = 2

If residue R is zero, then overall number of video segments is M, else M + 1.

Start time of i-th video segment is Ts[i] = i * K

End time of i-th video segment is Te[i] = (i + 1) * K for all but the last segment Te[last] = X

I hope it is very basic math.

MBo
  • 77,366
  • 5
  • 53
  • 86
  • As I understand it, this only works if all the segments are exactly K length. However, K is only the maximum length of a segment, a segment can be much shorter. Am I missing something? Thank you for your time and answer! – user1320885 Apr 09 '16 at 08:04
  • 1
    Yes, I considered your example as base. If you are interested in another kinds of combinations, you have to elaborate clear criteria for them – MBo Apr 09 '16 at 08:34
  • What other criteria are needed? the segments can be varying lengths, with a maximum length of K. – user1320885 Apr 10 '16 at 00:57
  • I don't know. You might want generate random partition with max part size K, all possible partitions (there is usually a lot of them), the best distributed partition (with almost equal parts) and so on. For now your will is too abstract – MBo Apr 10 '16 at 02:52