Last active
August 29, 2015 13:57
-
-
Save voyeg3r/9375602 to your computer and use it in GitHub Desktop.
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/bin/env python | |
# # -*- coding: UTF-8 -*-" | |
# ---------------------------------------------------------- | |
# CREATED: Qua 05/Mar/2014 hs 10:24 | |
# LAST CHANGE: 2014 Mar 05 17:08:13 | |
# THIS SCRIPT AIM: fix subtitle files | |
# AUTHOR: Sergio Luiz Araujo Silva | |
# SITE: http://vivaotux.blogspot.com | |
# TWITTER: @voyeg3r | |
# Download: https://gist.github.com/voyeg3r/9375602 | |
# ---------------------------------------------------------- | |
# Install needed libs !!!!! | |
# sudo easy_install pysrt3 pysrt argparse | |
# Reference: http://tuxbalaji.wordpress.com/2013/10/05/how-to-fix-subtitles-delay-or-ealier-with-your-movies-by-python-code/ | |
# >>> subs.shift(seconds=-2) # Move all subs 2 seconds earlier | |
# >>> subs.shift(minutes=1) # Move all subs 1 minutes later | |
import pysrt, argparse | |
parser = argparse.ArgumentParser(description='This is a script to change your subtitles') | |
parser.add_argument('-i','--input', help='Input file name', required=True) | |
parser.add_argument('-o','--output', help='Output file name', required=True) | |
parser.add_argument('-t','--time', help='time shift in seconds', required=True, type=int) | |
args=parser.parse_args() | |
subs = pysrt.open(args.input) | |
subs.shift(seconds=args.time) | |
subs.save(args.output, encoding='utf-8') | |
## show values ## | |
#print ("Input file: %s" % args.input ) | |
#print ("Output file: %s" % args.output ) | |
#print ("Time shift: %s" % args.time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment