Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
just converts framenumbers to split parts for now
#!/usr/bin/env python3
Just very basic for now. It only prints an mkvmerge command.
- properly get input file (or get it at all, lul)
- do the splitting for the user
- actually parse vs scripts
- get delay from source file (and --sync the output)
- add pluses automatically so you only get one file
- generally not be a lazy fuck
import sys
def frame_to_timestamp(f, fps=24000/1001):
s = f / fps
h = s // 3600
s -= h * 3600
m = s // 60
s -= m * 60
return f'{int(h):02d}:{int(m):02d}:{s:0>6.3f}'
def split_range(r):
return [int(x) for x in r.split('-', 1)]
if len(sys.argv) == 1:
print('Usage: $ python frame1-frame2 frame3-frame4 ...')
if __name__ == '__main__':
ranges = []
for r in sys.argv[1:]:
print(f'mkvmerge <input> --split parts:{",".join([f"{frame_to_timestamp(x)}-{frame_to_timestamp(y)}" for x, y in ranges])}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment