Skip to content

Instantly share code, notes, and snippets.

@jeff47
Created October 2, 2024 21:36
Show Gist options
  • Select an option

  • Save jeff47/7b3357ee090c01480c5ddbf521fb8b5a to your computer and use it in GitHub Desktop.

Select an option

Save jeff47/7b3357ee090c01480c5ddbf521fb8b5a to your computer and use it in GitHub Desktop.
Split audiofiles from Sony ICD-UX570 using timestamp (TMK) file
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)
@jeff47
Copy link
Author

jeff47 commented Oct 2, 2024

Usage: python3 split_mp3.py 241002_1647.mp3
where 241002_1647.mp3 is 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment