Skip to content

Instantly share code, notes, and snippets.

@cerisier
Created December 10, 2015 14:50
Show Gist options
  • Save cerisier/0165f645abf7b2d00604 to your computer and use it in GitHub Desktop.
Save cerisier/0165f645abf7b2d00604 to your computer and use it in GitHub Desktop.
Split iTunes (m4a) chapters into tracks
import csv
import sys
# Reads input generated from ffprobe. Example below.
# ffprobe -v error -select_streams a:0 -show_entries stream=nb_read_frames ABGT160_847378.m4a
reader = csv.reader(sys.stdin, delimiter=',')
audio_file = sys.argv[1]
for row in reader:
start = row[4]
duration = float(row[6])-float(row[4])
title = row[7]
print "ffmpeg -ss %s -i %s -t %s -acodec copy \"%s.wav\"" % (audio_file, start, duration, title)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment