Skip to content

Instantly share code, notes, and snippets.

@kageru
Created January 28, 2018 12:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kageru/dc8217053486cc36b7cc6f0acf37a532 to your computer and use it in GitHub Desktop.
Save kageru/dc8217053486cc36b7cc6f0acf37a532 to your computer and use it in GitHub Desktop.
just converts framenumbers to split parts for now
#!/usr/bin/env python3
"""
Just very basic for now. It only prints an mkvmerge command.
TODOs:
- 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 audiocut.py frame1-frame2 frame3-frame4 ...')
if __name__ == '__main__':
ranges = []
for r in sys.argv[1:]:
ranges.append(split_range(r))
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