头像
vempx
管理猿
帖子: 146
注册时间: 2010-09-19 20:45

[置顶] Chapters file time Editor v1.2

这是一个是用来处理OGG Chapter文件的工具
最初版本由vempx编写
1.0由Leiming重写
下载地址
欢迎反馈

注意: 输入文件必须是OGG Chapters文件

代码: 全选

Chapters file time Editor v1.2 – Leiming


参数:
-?   --help               显示本帮助
-i   --file               指定要处理的文件
-n   --chapternames       指定要套用的章节名模板,模板为txt文件,一行一个章节名
-t   --adjustbase         将第一个章节的开始时间前移至0并同时移动所有章节的开始时间
-d   --decimate           所有章节的开始时间 x 1.001 (用于DVD Decrypter提取的Chapter)
-b   --backward           向后平移所有时间,如 00:23:23.233
-f   --forward            向前平移所有时间
-B   --cpnumbwd           向后平移所有章节号
-F   --cpnumfwd           向前平移所有章节号

举例:
timec    -t -i chapters.txt
timec    -i chapters.txt -n name.txt
timec    -i chapters.txt -b 00:00:10.123
timec    -i chapters.txt -F 5 
合法文件如下:

代码: 全选

CHAPTER01=00:23:45.424
CHAPTER01NAME= Chapter 1
CHAPTER02=00:25:16.515
CHAPTER02NAME= Chapter 2
CHAPTER03=00:26:47.606
CHAPTER03NAME= Chapter 3
CHAPTER04=00:36:32.190
CHAPTER04NAME= Chapter 4
Changelog:
1.2:
加入Unicode支持(详细内容

1.1:
功能不局限于时间计算,因此更名为Chapters file time Editor
输入选项由-f变更为-i
添加整体前后平移时间功能
添加整体前后平移章节号功能
解决chapter文件尾空行问题
修复整体前移至0后,第一个chapter时间缺少小数点后000的问题

1.0:
由Leiming使用C++重写
添加了套用模板功能

0.2.1:
调整输出编号从00开始(其实无所谓……)
修正计算后第一个章节时间可能为负数的问题 =_=

0.2:
支持章节标题保留
添加可选参数
针对DVD Decrypter抓取的章节时间不准确添加-d参数用以修正

0.1.1:
增加处理章节数量到30,应该够用了
调整输出章节文件编号从01开始
在提问前还请仔细查阅公告帖以及各版置顶帖
相信置顶中也许会有您需要的内容


~My Blog~
头像
yntang66
帖子: 10
注册时间: 2010-10-13 23:41

Re: Chapters file time Calculator v0.2.1

很好用的小工具~ 多谢~!

不知是否能加入整体后移计算的功能呢?~
sunyata
帖子: 29
注册时间: 2010-09-23 22:10

Re: Chapters file time Calculator v0.2.1

瞄了眼eva老剧场版的章节有34chapters,超过处理能力了- -
能不能把最大处理数提高到50?(拖
顺便mast->must...


--------
呃,算了自己EP了个...

代码: 全选

## save to pytimec.py
## pytimec.py input.txt [-h/--help] [-d] [-n]
## 

import sys
import os
from datetime import timedelta
from optparse import OptionParser

def main():
    optParser=OptionParser(usage="pytimec.py <input> [options]")
    optParser.add_option("-d",action="store_true",dest="dvdde",default=False,help="for DVD Decrypter")
    optParser.add_option("-n",action="store_true",dest="offset",default=False,help="no offset")
    (opts,args)=optParser.parse_args(sys.argv)

    if len(args)<2:
        print "no input file\n"
        exit(1)
    outfile=args[1][:-4]+"_set.txt"
        
    try:
        fi=open(args[1],'r')
    except:
        print "input file open error\n"
        exit(1)
    lines=fi.readlines()
    fi.close()
    
    counter=1
    chapno=-1
    t0=timedelta()

    try:
        fo=open(outfile,'w')
    except:
        print "output file open error\n"
        exit(1)

    try:
        for line in lines:
            if counter==1:
                chapno=chapno+1
                (chap,time)=line.split('=')
                (h,m,s)=time.split(':')
                h=int(h);m=int(m)
                (s,ms)=s.split('.')
                s=int(s);ms=int(ms)
                if opts.dvdde==True:
                    h=h*1.001;m=m*1.001;s=s*1.001;ms=ms*1.001
                if chapno==0:
                    if opts.offset==False:
                        t0=timedelta(hours=h,minutes=m,seconds=s,milliseconds=ms)
                t=str(timedelta(hours=h,minutes=m,seconds=s,milliseconds=ms)-t0).split(':')
                ot=t[0].zfill(2)+":"+t[1].zfill(2)+":"+t[2].split('.')[0].zfill(2)+"."
                if len(t[2].split('.'))==1:
                    ot=ot+"000"
                else:
                    ot=ot+str(int(round(int(t[2].split('.')[1])/1000.0))).zfill(3)
                fo.write("CHAPTER"+str(chapno).zfill(2)+"="+ot+"\n")
            else:
                fo.write("CHAPTER"+str(chapno).zfill(2)+"NAME="+line.split('=')[1])
            counter=1-counter
    except:
        print "something happened...\n"
        exit(1)

    fo.close()
    print "output as "+outfile+"\n"


if __name__=='__main__':
    main()
    
头像
vempx
管理猿
帖子: 146
注册时间: 2010-09-19 20:45

Re: Chapters file time Calculator v0.2.1

好久没管这个东西了,自己写的代码自己都看不懂了……囧
在提问前还请仔细查阅公告帖以及各版置顶帖
相信置顶中也许会有您需要的内容


~My Blog~
头像
vempx
管理猿
帖子: 146
注册时间: 2010-09-19 20:45

Re: Chapters file time Calculator v1.0

更新1.0版本,感谢雷萌子 XD
在提问前还请仔细查阅公告帖以及各版置顶帖
相信置顶中也许会有您需要的内容


~My Blog~
头像
leiming
帖子: 30
注册时间: 2012-01-31 11:51

Re: [置顶] Chapters file time Calculator v1.0

空行的问题好像已经解决了?昨天测试的时候没有发现问题就是了……
http://nmm.me/wt
名言生成工具。系统需求:Windows操作系统,.net framework 2.0运行环境,avisynth 2.5或兼容版本,vsfilter插件,方正大标宋_GBK字体。有无法修复的bug:保存的文件一定是png格式
头像
leiming
帖子: 30
注册时间: 2012-01-31 11:51

Re: [置顶] Chapters file time Editor v1.1

1.2版。
加入Unicode支持:
输入的chapters file可以为utf8(带bom)、utf8(不带bom)、ansi(gbk,big5,shiftjis等)、Unicode(带bom)、Unicode big endian(带bom),
不支持Unicode(不带bom)、Unicode big endian(不带bom)、utf32(带不带bom均不支持)。

输出文件在输入文件为utf8(不带bom)和ansi时保持和源文件相同
在其他时候输出utf8(不带bom)。

输入文件和chapter name文件混合使用ansi和utf8(不带bom)的时候输出文件可能会有问题。

下载:
http://nmm.me/w6
http://nmm.me/wt
名言生成工具。系统需求:Windows操作系统,.net framework 2.0运行环境,avisynth 2.5或兼容版本,vsfilter插件,方正大标宋_GBK字体。有无法修复的bug:保存的文件一定是png格式
keroro123
帖子: 71
注册时间: 2011-01-11 23:58

Re: [置顶] Chapters file time Editor v1.2

请问这个软件需要如何使用,双击闪一下就关闭了,系统是WIN7 X64的。
希望可以回答下,同样遇到章节不准确的问题,谢谢!~

回到 “封装容器 / Container muxer and demuxer”