Created
June 5, 2016 06:49
-
-
Save iSplasher/301c3ace3a022922e8504e179541752d to your computer and use it in GitHub Desktop.
RipSubsFromMKV
This file contains 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
#!/usr/local/bin/python | |
# | |
# Script to rip srt/ssa subtitles out of .mkv files | |
# Usage: scriptname.py [filename.mkv] | |
# If the filename isn't specified all .mkv files in the current directory will be processed | |
# Developed with ffmpeg 2.1.1, you probably want that or higher if this doesn't work | |
# | |
import glob, re, argparse | |
from subprocess import call | |
ffmpeg = '/usr/local/bin/ffmpeg' | |
parser = argparse.ArgumentParser(description='Extract subtitles from mkv files.') | |
parser.add_argument('-f', '--file', help="source filename (mkv) to extract subtitle from") | |
args = parser.parse_args() | |
def process(i): | |
return [ffmpeg, '-i', i, re.sub(r".mkv", ".srt", i)] | |
if args.file is None: | |
mkvs = glob.glob("*.mkv") | |
if (len(mkvs) == 0): | |
print "No .mkv files in current directory" | |
for i in mkvs: | |
call(process(i)) | |
else: | |
call(process(args.file)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment