Skip to content

Instantly share code, notes, and snippets.

@bokunodev
Created May 6, 2021 21:54
Show Gist options
  • Save bokunodev/bb48ad6ce65081e938eb73efa68a676c to your computer and use it in GitHub Desktop.
Save bokunodev/bb48ad6ce65081e938eb73efa68a676c to your computer and use it in GitHub Desktop.

Revisions

  1. bokunodev created this gist May 6, 2021.
    35 changes: 35 additions & 0 deletions split-chapter.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/usr/bin/python

    import json, os

    tracklist = [
    "bird funeral [Introduction]",
    "This is the happiness peace committee. [Introduction]",
    "Unhappy Refrain [two of the switching]",
    "Sugar Bits [switching of two]",
    "Gakuen × ∀ssassinatioИ [two of the switching]",
    "Immorality of flower [two of the switching]",
    "Mad Lovers [two of the switching]",
    "Secret police [switching of two]",
    "Cantarella [Michiyuki]",
    "Monday, shadow My Hana [Michiyuki]",
    "Chaining Intention [four of the switching]",
    "deep sea girl [switching of four]",
    "Halo _ Hawayu [four of the switching]",
    "1_6 ~out of gravity~ [four of the switching]",
    "Crescent rider [switching of four]",
    "Tell Your World [Switching of four]",
    "One Night Girl [finale]",
    "Thousand Sakura [finale]",
    "SWEET MEMORIES [finale]",
    "Orange intersection [finale]"]

    # to generate the json file, use ffprobe.
    # ffprobe -v error -show_chapters -print_format json > chapters.json
    with open("chapters.json","r") as f:
    js = json.load(f)
    counter = 0
    for each in js["chapters"]:
    os.system(f"ffmpeg -v error -ss {each['start_time']} -i in.mkv -to {each['end_time']} -vn -c:a libmp3lame -q:a 3 -compression_level 0 -threads 2 -y 'chapters/{tracklist[x]}.mp3'")
    counter += 1
    print(f"{counter:02d} '{tracklist[x]}'")