Created
October 2, 2024 21:36
-
-
Save jeff47/7b3357ee090c01480c5ddbf521fb8b5a to your computer and use it in GitHub Desktop.
Split audiofiles from Sony ICD-UX570 using timestamp (TMK) file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re, subprocess, sys | |
| audiofile = sys.argv[1] | |
| basename = sys.argv[1].split('.')[0] | |
| timestamp_file = basename + ".tmk" | |
| timestamps = [] | |
| with open(timestamp_file, 'r') as file: | |
| for line in file: | |
| if len(line) > 1: | |
| matches = re.search(r'\[(.*?)\]', line) | |
| parts = matches.group(1).split(':') | |
| minutes, seconds = float(parts[0]), float(parts[1]) | |
| total_seconds = minutes * 60 + seconds | |
| timestamps.append(str(total_seconds)) | |
| times=print(",".join(timestamps)) | |
| command = "ffmpeg -hide_banner -i " + audiofile + " -f segment -segment_times " + ",".join(timestamps) + " -c copy " + basename + "_%03d.mp3" | |
| subprocess.run(command, shell=True) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
python3 split_mp3.py 241002_1647.mp3where
241002_1647.mp3is the filename of the audioclip to be split. The timestamp file (ends in tmk) should be in the same directory. Split files will be output into the same directory, with _000 appended.