From f6fc2bb124886bc238ee04786b249d5749093e39 Mon Sep 17 00:00:00 2001 From: gpoirier Date: Mon, 27 Jun 2005 13:33:40 +0000 Subject: [PATCH] =?UTF-8?q?vobsub=20time-adjust=20tool=20by=20G=C3=83?= =?UTF-8?q?=C2=A1bor=20Farkas=20<=20gabor=20AH=20nekomancer=20POUM=20net?= =?UTF-8?q?=20>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15830 b3059339-0415-0410-9bf9-f77b7e298cf2 --- ChangeLog | 4 +++- TOOLS/README | 10 ++++++++ TOOLS/vobshift.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100755 TOOLS/vobshift.py diff --git a/ChangeLog b/ChangeLog index 05cd0a703e..57f94a2eee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,7 +6,7 @@ MPlayer (1.0) * improved encoding guide * new technical encoding guide in DOCS/tech/encoding-guide.txt which is to be merged into the existing guide - * encoding tips for x264 + * encoding tips for x264 and XviD * how to set up MEncoder for x264 support * misc improvements all over the place @@ -65,6 +65,8 @@ MPlayer (1.0) * support for file:// syntax * -fb option removed, use the device suboption of -vo fbdev/fbdev2 instead * massive stream layer cleanup, all streams ported to the new API + * full gcc 4 support for IA-32 and AMD-64 ports + * TOOLS/vobshift.py: vobsub time-adjust tool pre7: "PatentCounter" April 16, 2005 diff --git a/TOOLS/README b/TOOLS/README index 671074dbf9..e89be12496 100644 --- a/TOOLS/README +++ b/TOOLS/README @@ -401,6 +401,16 @@ Usage: install-w32codecs.sh install install-w32codecs.sh uninstall +vobshift.py + +Author: Gábor Farkas + +Description: Adjust the time-info in vobsub files + +Usage: vobshift.py in.idx out.idx +8.3 + Will shift the time by 8.3 seconds + + subrip.c Author: Kim Minh Kaplan diff --git a/TOOLS/vobshift.py b/TOOLS/vobshift.py new file mode 100755 index 0000000000..180b5c486f --- /dev/null +++ b/TOOLS/vobshift.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +#usage: +# +# vobshift.py in.idx out.idx -8.45 +# +# this will read in in.idx,shift it by 8.45 seconds back, +# and save it as out.idx +# +# license: i don't care ;) +# + +import datetime +import sys + +def tripletize(line): + begin = line[:11] + middle = line[11:23] + end = line[23:] + return (begin,middle,end) + +def text2delta(t): + h = int( t[0:2] ) + m = int( t[3:5] ) + s = int( t[6:8] ) + milli = int( t[9:12] ) + return datetime.timedelta(hours=h,minutes=m,seconds=s,milliseconds=milli) + +def delta2text(d): + t = str(d) + milli = t[8:11] + if len(milli) == 0: #fix for .000 seconds + milli = '000' + return '0'+t[:7]+':'+milli + +def shift(line,seconds): + triplet = tripletize(line) + + base = text2delta(triplet[1]) + base = base + datetime.timedelta(seconds=seconds) + base = delta2text(base) + + return triplet[0]+base+triplet[2] + +INFILE =sys.argv[1] +OUTFILE =sys.argv[2] +DIFF =float(sys.argv[3]) + +o = open(OUTFILE,'wt') + + +for line in open(INFILE): + if line.startswith('timestamp'): + line = shift(line,DIFF) + + o.write(line) + +o.close()