Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python -tt
- # -*- coding: UTF-8 -*-
- # vim: ts=4 sw=4 et ai si
- import sys
- import os
- """Run 'this_script.py video.mp4'."""
- def to_seconds(timestamp):
- seconds = 0
- for item in timestamp.strip().split(':'):
- seconds = seconds * 60 + int(item)
- return seconds
- media = sys.argv[1]
- tracklist = os.path.splitext(media)[0] + "-tracklist" + os.path.extsep + "txt"
- # <время начала трека>РАЗДЕЛИТЕЛЬ<время окончания трека>РАЗДЕЛИТЕЛЬ<исполнитель>РАЗДЕЛИТЕЛЬ<название>
- # РАЗДЕЛИТЕЛЬ - единичный символ (что в голову взбредет, опробовано "%" и "=")
- # <время...> - в виде HH:MM:SS
- for line in open(tracklist, 'r').read().splitlines():
- start, end, author, title = line.split('=')
- sec_end = to_seconds(end)
- cmd = "ffmpeg -ss %s -i %s -c:a copy -c:v copy -t %d '%s - %s'" % (start, media, sec_end, author, title)
- print cmd
- #os.system(cmd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement