OSDN Git Service

implement encode tester.
[rec10/rec10-git.git] / rec10 / trunk / src / tv2ts.py
1 #!/usr/bin/python
2 # coding: UTF-8
3 #import sys # モジュール属性 argv を取得するため
4 import commands
5 import os
6 import os.path
7 import time
8
9 import configreader
10 import status
11 import recdblist
12 mypath = str(os.path.dirname(os.path.abspath(__file__))) + "/"
13 def tv2tsmix(pout, ch, time):
14     tv2b25ts(pout + ".b25", ch, time)
15     b252tsmix(pout + ".b25", pout)
16     #if os.access(pout, os.F_OK):
17     #    try:
18     #        os.remove(pout + ".b25")
19     #    except:
20     #        ""
21 def tv2ts(pout, ch, csch, time):
22     ext = os.path.splitext(pout)[1]#ext=".なんたら"
23     tempt = os.path.split(pout)
24     path = tempt[0]
25     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
26         status.changeBSCSRecording(1)
27     else:
28         status.changeTERecording(1)
29     try:
30         tv2b25ts(pout + ".b25", ch, time)
31     except Exception, inst:
32         recdblist.Commonlogex(u"Error",u"tv2ts(tv2ts.py)", str(type(inst)),str(inst))
33     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
34         status.changeBSCSRecording(-1)
35     else:
36         status.changeTERecording(-1)
37     b252tsmix(pout + ".b25", pout + ".tsmix")
38     tch="0"
39     if csch!=u"0":
40         tch=csch
41     elif ch==u"101":
42         tch="101"
43     elif ch==u"102":
44         tch="102"
45     #else:
46     #    tch=ch
47     tsmix2ts(pout + ".tsmix", pout, tch)
48     if os.access(pout, os.F_OK):
49         try:
50             #os.remove(path + "/" + t + ext)
51             ""
52         except:
53             ""
54 def b252ts(pout, ch, csch):
55     ext = os.path.splitext(pout)[1]#ext=".なんたら"
56     tempt = os.path.split(pout)
57     path = tempt[0]
58     b252tsmix(pout + ".b25", pout + ".tsmix")
59     tch=u"0"
60     if csch!=u"0":
61         tch=csch
62     elif ch==u"101":
63         tch=u"101"
64     elif ch==u"102":
65         tch=u"102"
66     #else:
67     #    tch=ch
68     tsmix2ts(pout + ".tsmix", pout, tch)
69     if os.access(pout, os.F_OK):
70         try:
71             #os.remove(path + "/" + t + ext)
72             ""
73         except:
74             ""
75 def tv2b25ts(pout, ch, time):
76     exe = configreader.getpath('recpt1')
77     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
78         status.changeBSCSRecording(1)
79     else:
80         status.changeTERecording(1)
81     try:
82         doexe = exe + ' ' + ch + ' ' + time + ' \'' + pout + '\''
83         recdblist.printutf8(doexe)
84         recdblist.addlog(pout, doexe, u"recpt1ログ-コマンド")
85         recdblist.addlog(pout, unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8'), u"recpt1ログ-詳細")
86     except Exception, inst:
87         recdblist.Commonlogex(u"Error",u"tv2b25ts(tv2ts.py)", str(type(inst)),str(inst))
88     if len(ch) > 2:#BS/CSは100とかCS??とかなので3文字以上
89         status.changeBSCSRecording(-1)
90     else:
91         status.changeTERecording(-1)
92 def tv2b25ts_b25(pout, ch, time):
93     exe = configreader.getpath('recpt1')
94     doexe = exe + ' --b25 ' + ch + ' ' + time + ' \'' + pout + '\''
95     os.system(doexe)
96 def b252tsmix(pin, pout):
97     if not (os.path.exists(pout) and os.path.getsize(pin)>os.path.getsize(pout)*0.95 and os.path.getsize(pin)<os.path.getsize(pout)*1.05):
98         exe=""
99         if configreader.getpath('b25_remote')=="1":
100             try:
101                 exe = configreader.getpath('b25_env')+" && "
102             except:
103                 inst=u"b25_remoteがオンになっていますが、b25_envが設定されていないかコメントアウトされています。"
104                 recdblist.Commonlogex(u"Error",u"b252tsmix(tv2ts.py)", "",inst)
105         exe = exe + "nice -n 17 " + configreader.getpath('b25')
106         doexe = exe + u' \"' + pin + u'\" \"' + pout + u'\"'
107         recdblist.printutf8(doexe)
108         txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8')
109         recdblist.addlog(pin, doexe, u"b25ログ-コマンド")
110         recdblist.addlog(pin, txt, u"b25ログ-詳細")
111 def tsmix2ts(pin, pout, csch):#csch=0ならcsの処理をしない
112     doexe = configreader.getpath("tssplitter") + " \""+ pin + "\" \""+ pout + "\" " + str(csch)
113     doexe = "nice -n 18 " + doexe
114     os.environ['LANG']="ja_JP.UTF-8"
115     txt = unicode(commands.getoutput(doexe.encode('utf-8')),'utf-8')
116     recdblist.addlog(pin, doexe, u"TsSplitログ-コマンド")
117     recdblist.addlog(pin, txt, u"TsSplitログ-詳細")
118     time.sleep(1)
119     if os.access(pout, os.F_OK) and os.path.getsize(pout)>10*1000*1000:
120         os.remove(pin)
121