Moviepy - Create multiple subclips using times from CSV file
<p>I am creating a Python script which uses the MoviePy module, to take clips from a larger video and concatenate them together.</p>

<p>The times for the clips are detailed in a CSV file like so;</p>

<p>0,10</p>

<p>11,19</p>

<p>15,20</p>

<p>34,42
etc</p>

<p>What I have done is read the CSV file row by row and then using the subclip method from Moviepy created a clip which is stored in a list of clips, however I get a IndexError - list index out of range.</p>

<p>What could be the issue (the code works fine if I don't use the subclip method with the values from the CSV file)?</p>

<p>This is my code:</p>

<pre><code>video= VideoFileClip('file')

clipsArray = [] 

import csv
with open('csv file', 'r') as file:
    reader = csv.reader(file)
    for row in reader:
        startTime = row[0]
        endTime = row[1]
        clip = fullVideo.subclip(startTime, endTime)
        clipsArray.append(clip)
</code></pre>

<p>The error message is:</p>

<p>File "C:\Anaconda3\envs\py35\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
    execfile(filename, namespace)</p>

<p>File "C:\Anaconda3\envs\py35\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 85, in execfile
    exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)</p>

<p>File "C:/spyder2-py3/program.py", line 32, in 
    clip = fullVideo.subclip(start, end) # Create clips for each of the timestamps</p>

<p>File "", line 2, in subclip</p>

<p>File "C:\Anaconda3\envs\py35\lib\site-packages\moviepy\decorators.py", line 86, in wrapper
    for (arg, name) in zip(a, names)]</p>

<p>File "C:\Anaconda3\envs\py35\lib\site-packages\moviepy\decorators.py", line 86, in 
    for (arg, name) in zip(a, names)]</p>

<p>File "C:\Anaconda3\envs\py35\lib\site-packages\moviepy\tools.py", line 78, in cvsecs
    finds = re.findall(expr, time)[0]</p>

<p>IndexError: list index out of range</p>

<p>CSV file:</p>

<p><code>0,12
16,21
22,29
34,59
89,130
140,160
162,171</code></p>