<p>I came up with the following solution.
Find the durations using your favorite player.
Then, use the following python script that employs ffmpeg:</p>

<pre><code># Cut out clips from a video given a text file with times, e.g.:
# 0.0-12.20
# 14.28-15.58
# 53.25-53.31
# 54.47-55.05

import sys, re, os
import datetime

fin = "8-01.mp4"
flist = "8-01_cut_out.txt"

def main():
    with open(flist) as f: 
        lines = f.readlines()
    #print(lines)

    print("Durations to remove:")
    times = ["00:00:00.000"]
    #for line in sys.stdin:
    for line in lines:
        line = line.rstrip()

        reg = re.compile('(\d+)\.(\d+)-(\d+)\.(\d+)')
        m = reg.match(line)
        if not m:
            print("Couldn't find pattern:", line)
            return

        m0, s0, m1, s1 = [int(m.group(i+1)) for i in range(4)]
        t0 = "00:%02d:%02d.000" % (m0, s0)
        t1 = "00:%02d:%02d.000" % (m1, s1)
        print(t0, "...", t1)
        times.extend([t0, t1])
    # append last
    times.append("10:00:00.000")

    print("&gt;&gt; \nDurations:")
    fclip = open("clip_list.txt", "w")
    for i in range( len(times)//2 ):
        t0 = times[2*i]
        t1 = times[2*i+1]
        fout = "clip%02d.mp4" % i
        dur = datetime.datetime.strptime(t1[:8], "%H:%M:%S") - datetime.datetime.strptime(t0[:8], "%H:%M:%S")
        dur = dur.total_seconds()
        print("&gt;&gt;", fout, t0, "...", t1, "%dsec" % dur)
        if dur == 0:
            continue
        fclip.write( "file " + fout + "\n" )

        cmd = "ffmpeg -y -ss %s -i %s -t %d -c copy %s" % (t0, fin, dur, fout)
        print("&gt;&gt;", cmd)
        os.system( cmd )
    fclip.close()

    print("\n&gt;&gt; Concatenate:")
    cmd = "ffmpeg -y -f concat -i clip_list.txt -c copy out.mp4"
    print("&gt;&gt;", cmd)
    os.system( cmd )

if __name__ == "__main__":
    main()
</code></pre>

CC BY-SA 4.0
2020-09-23T03:32:44.693Z
I'm a beginner, so apologies if this is obvious in your code, but does datetime handle SMPTE timecode?  If not, does your code account for different frame rates?  Curious, because I know I've seen python timecode modules on github.  Here's one:  https://github.com/eoyilmaz/timecode
Jason Conrad
CC BY-SA 4.0
2020-09-23T21:26:52.600Z
The script is given as a suggestion. Feel free to change and use it as you like.
Zohar Levi
CC BY-SA 4.0
2020-04-24T23:31:34.283Z
2020-04-24T23:31:34.283Z
Zohar Levi
<p>I'm looking for an open source video editor for windows</p>

<p><a href="https://en.wikipedia.org/wiki/List_of_video_editing_software" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/List_of_video_editing_software</a></p>

<p>in order to cut out some parts of a video.
A necessary feature that I'm looking for is to be able to jump forward a few seconds while playing the video (to find where I need to cut it next). </p>

<p>So far, I checked:</p>

<ul>
<li><p>OpenShot: doesn't have the ability. </p></li>
<li><p>Shotcut, Avidemux, Kdenlive: it can jump forward, but it stops playing the movie, and I need to press play again, which makes in clunky.</p></li>
</ul>

<video-editor>
Video editing with playable jump forward
Zohar Levi
# Video editing with playable jump forward

(Asked by: username_0 on 2020-04-24)

I'm looking for an open source video editor for windows

<https://en.wikipedia.org/wiki/List_of_video_editing_software>

in order to cut out some parts of a video.
A necessary feature that I'm looking for is to be able to jump forward a few seconds while playing the video (to find where I need to cut it next).

So far, I checked:

* OpenShot: doesn't have the ability.
* Shotcut, Avidemux, Kdenlive: it can jump forward, but it stops playing the movie, and I need to press play again, which makes in clunky.

**Tags:** video-editor


---

## 1 answers

### Answer by username_0 on 2020-04-24. Score: 0

I came up with the following solution.
Find the durations using your favorite player.
Then, use the following python script that employs ffmpeg:
# Cut out clips from a video given a text file with times, e.g.:
# 0.0-12.20
# 14.28-15.58
# 53.25-53.31
# 54.47-55.05

import sys, re, os
import datetime

fin = "8-01.mp4"
flist = "8-01_cut_out.txt"

def main():
    with open(flist) as f: 
        lines = f.readlines()
    #print(lines)

    print("Durations to remove:")
    times = ["00:00:00.000"]
    #for line in sys.stdin:
    for line in lines:
        line = line.rstrip()

        reg = re.compile('(\d+)\.(\d+)-(\d+)\.(\d+)')
        m = reg.match(line)
        if not m:
            print("Couldn't find pattern:", line)
            return

        m0, s0, m1, s1 = [int(m.group(i+1)) for i in range(4)]
        t0 = "00:%02d:%02d.000" % (m0, s0)
        t1 = "00:%02d:%02d.000" % (m1, s1)
        print(t0, "...", t1)
        times.extend([t0, t1])
    # append last
    times.append("10:00:00.000")

    print(">> \nDurations:")
    fclip = open("clip_list.txt", "w")
    for i in range( len(times)//2 ):
        t0 = times[2*i]
        t1 = times[2*i+1]
        fout = "clip%02d.mp4" % i
        dur = datetime.datetime.strptime(t1[:8], "%H:%M:%S") - datetime.datetime.strptime(t0[:8], "%H:%M:%S")
        dur = dur.total_seconds()
        print(">>", fout, t0, "...", t1, "%dsec" % dur)
        if dur == 0:
            continue
        fclip.write( "file " + fout + "\n" )

        cmd = "ffmpeg -y -ss %s -i %s -t %d -c copy %s" % (t0, fin, dur, fout)
        print(">>", cmd)
        os.system( cmd )
    fclip.close()

    print("\n>> Concatenate:")
    cmd = "ffmpeg -y -f concat -i clip_list.txt -c copy out.mp4"
    print(">>", cmd)
    os.system( cmd )

if __name__ == "__main__":
    main()

> **Comments:**
> **username_1**: I'm a beginner, so apologies if this is obvious in your code, but does datetime handle SMPTE timecode?  If not, does your code account for different frame rates?  Curious, because I know I've seen python timecode modules on github.  Here's one:  https://github.com/eoyilmaz/timecode  
> **username_0**: The script is given as a suggestion. Feel free to change and use it as you like.  

---

