root/trunk/install/perl/digitaltvrecording.pl

リビジョン 131, 12.8 kB (コミッタ: sorshi, コミット時期: 13 年 前)

デジタル録画時に重複録画数がエンコーダ数を超えたときの対策を強化

  • svn:executable 属性の設定値: *
Line 
1 #!/usr/bin/perl
2 #
3 # Anime recording system foltia
4 # http://www.dcc-jpl.com/soft/foltia/
5 #
6 #digitaltvrecording.pl
7 # PT1,PT2,friioをはじめとするデジタル録画プログラムを呼びだす録画モジュール。
8 #
9 #usage digitaltvrecording.pl bandtype ch length(sec) [stationid] [sleeptype] [filename] [TID] [NO] [unittype]
10 #引数
11 #bandtype : 0:地デジ 1:BSデジタル 2:CSデジタル
12 #ch :録画チャンネル (地デジはそのまま渡す、BS/CSデジタルは基本的にチャンネル BS1/BS2など同じ数時に)
13 #length(sec) :録画秒数 [必須項目]
14 #[stationid] :foltia stationid
15 #[sleeptype] :0かN Nならスリープなしで録画
16 #[filename] :出力ファイル名
17 #[TID] :しょぼかるタイトルID
18 #[NO] :その番組の放送話数
19 #[unittype] :friioかfriioBSかユニデンチューナかHDUSかなど(未使用)
20 #
21 # DCC-JPL Japan/foltia project
22 #
23 #
24
25 $path = $0;
26 $path =~ s/digitaltvrecording.pl$//i;
27 if ($path ne "./"){
28 push( @INC, "$path");
29 }
30
31 #tvConfig.pl -------------------------------
32 $extendrecendsec = 10;                                                  #recording end second.
33 #$startupsleeptime = 52;                                        #process wait(MAX60sec)
34 $startupsleeptime = 32;                                 #process wait(MAX60sec)
35 #-------------------------------
36
37 require 'foltialib.pl';
38
39  &writelog("digitaltvrecording: DEBUG $ARGV[0] $ARGV[1] $ARGV[2] $ARGV[3] $ARGV[4] $ARGV[5] $ARGV[6] $ARGV[7] $ARGV[8]");
40
41
42 #準備
43 &prepare;
44 #もし録画が走ってたら、止める
45 #$reclengthsec = &chkrecprocess();
46 #&setbitrate;
47 #&chkextinput;
48 #$reclengthsec = $reclengthsec + $extendrecendsec ;
49
50 &calldigitalrecorder;
51
52 &writelog("digitaldigitaltvrecording:RECEND:$bandtype $recch $lengthsec $stationid $sleeptype $filename $tid $countno $unittype
53 ");
54
55 # -- これ以下サブルーチン ----------------------------
56
57
58 sub prepare{
59
60 #引数エラー処理
61 $bandtype = $ARGV[0] ;
62 $recch = $ARGV[1] ;
63 $lengthsec = $ARGV[2] ;
64 $stationid = $ARGV[3] ;
65 $sleeptype = $ARGV[4] ;
66 $filename = $ARGV[5] ;
67 $tid = $ARGV[6] ;
68 $countno = $ARGV[7] ;
69 $unittype = $ARGV[8] ;
70
71 if (($bandtype eq "" )|| ($recch eq "")|| ($lengthsec eq "")){
72         print "usage digitaltvrecording.pl bandtype ch length(sec) [stationid] [sleeptype] [filename] [TID] [NO] [unittype]\n";
73         exit;
74 }
75
76 my $intval = $recch % 10; # 0〜9 sec
77 my $startupsleep = $startupsleeptime - $intval; #  18〜27 sec
78 $reclengthsec = $lengthsec + (60 - $startupsleep) + 1; #
79
80 if ( $sleeptype ne "N"){
81         &writelog("digitaltvrecording: DEBUG SLEEP $startupsleeptime:$intval:$startupsleep:$reclengthsec");
82         sleep ( $startupsleep);
83         #2008/08/12_06:39:00 digitaltvrecording: DEBUG SLEEP 17:23:-6:367
84 }else{
85         &writelog("digitaltvrecording: DEBUG RAPID START");
86 }
87 ## recfriio このへんどうなってるの?
88 #if ($recunits > 1){
89 #my $deviceno = $recunits - 1;#3枚差しのとき/dev/video2から使う
90 #       $recdevice = "/dev/video$deviceno";
91 #       $recch = $ARGV[0] ;
92 #}else{
93 ##1枚差し
94 #       $recdevice = "/dev/video0";
95 #       $recch = $ARGV[0] ;
96 #}
97
98 $outputpath = "$recfolderpath"."/";
99
100 if ($countno eq "0"){
101         $outputfile = $outputpath.$tid."--";
102 }else{
103         $outputfile = $outputpath.$tid."-".$countno."-";
104 }
105 #2番目以降のクリップでファイル名指定があったら
106         if ($filename  ne ""){
107
108                 $outputfile = $filename ;
109                 $outputfile = &filenameinjectioncheck($outputfile);
110                 $outputfilewithoutpath = $outputfile ;
111                 $outputfile = $outputpath.$outputfile ;
112                 &writelog("digitaltvrecording: DEBUG FILENAME ne null \$outputfile $outputfile ");
113         }else{
114         $outputfile .= strftime("%Y%m%d-%H%M", localtime(time + 60));
115                 chomp($outputfile);
116                 $outputfile .= ".m2t";
117                 $outputfilewithoutpath = $outputfile ;
118                 &writelog("digitaltvrecording:  DEBUG FILENAME is null \$outputfile $outputfile ");
119         }
120
121
122 @wday_name = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
123 $sleepcounter = 0;
124 $cmd="";
125
126 #二重録りなど既に同名ファイルがあったら中断
127 if ( -e "$outputfile" ){
128         if ( -s "$outputfile" ){
129         &writelog("digitaltvrecording :ABORT :recfile $outputfile exist.");
130         exit 1;
131         }
132 }
133
134 }#end prepare
135
136
137 #------------------------------------------------------------------------------------
138 #
139 sub calldigitalrecorder{
140 #
141 #白friioと黒friio、PT1対応
142 #2008/10/23 recfriio4仕様に変更
143 #
144 my $oserr = 0;
145 my $originalrecch = $recch;
146 my $pt1recch =  $recch;
147 my $errorflag = 0;
148 if ($bandtype == 0){
149 # 地デジ friio
150
151 }elsif($bandtype == 1){
152 # BS/CS friio
153                 #recfriiobs用チャンネルリマップ
154                 if ($recch == 101) {
155                         $bssplitflag = $recch;
156                         $recch = "b10";#22 : NHK BS1/BS2
157                 }elsif($recch == 102){
158                         $bssplitflag = $recch;
159                         $recch = "b10";#22 : NHK BS1/BS2
160                 }elsif($recch == 103){
161                         $recch = "b11";#23 : NHK hi 
162                 }elsif($recch == 141){
163                         $recch = "b8";# 20 : BS-NTV 
164                 }elsif($recch == 151){
165                         $recch = "b1";#13 : BS-Asahi
166                 }elsif($recch == 161){
167                         $recch = "b2";#14 : BS-i 
168                 }elsif($recch == 171){
169                         $recch = "b4";#16 : BS-Japan
170                 }elsif($recch == 181){
171                         $recch = "b9";#21 : BS-Fuji
172                 }elsif($recch == 191){
173                         $recch = "b3";#15 : WOWOW
174                 }elsif($recch == 192){
175                         $recch = "b3";#15 : WOWOW
176                 }elsif($recch == 193){
177                         $recch = "b3";#15 : WOWOW
178                 }elsif($recch == 200){
179                         $recch = "b6";# b6 # Star Channel
180                 }elsif($recch == 211){
181                         $recch = "b5";#17 : BS11 
182                 }else{
183                         $recch = "b7";#19 : TwellV
184                 }
185 #PT1はそのまま通る
186
187 }elsif($bandtype == 2){
188 # recpt1でのみ動作確認
189                 if($recch == 335){
190                 $pt1recch = "CS8";#335ch:キッズステーション HD
191         }elsif($recch == 237){
192                 $pt1recch = "CS2";#237ch:スター・チャンネル プラス
193         }elsif($recch == 239){
194                 $pt1recch = "CS2";#239ch:日本映画専門チャンネルHD
195         }elsif($recch == 306){
196                 $pt1recch = "CS2";#306ch:フジテレビCSHD
197         }elsif($recch == 100){
198                 $pt1recch = "CS4";#100ch:e2プロモ
199         }elsif($recch == 256){
200                 $pt1recch = "CS4";#256ch:J sports ESPN
201         }elsif($recch == 312){
202                 $pt1recch = "CS4";#312ch:FOX
203         }elsif($recch == 322){
204                 $pt1recch = "CS4";#322ch:スペースシャワーTV
205         }elsif($recch == 331){
206                 $pt1recch = "CS4";#331ch:カートゥーンネットワーク
207         }elsif($recch == 194){
208                 $pt1recch = "CS4";#194ch:インターローカルTV
209         }elsif($recch == 334){
210                 $pt1recch = "CS4";#334ch:トゥーン・ディズニー
211         }elsif($recch == 221){
212                 $pt1recch = "CS6";#221ch:東映チャンネル
213         }elsif($recch == 222){
214                 $pt1recch = "CS6";#222ch:衛星劇場
215         }elsif($recch == 223){
216                 $pt1recch = "CS6";#223ch:チャンネルNECO
217         }elsif($recch == 224){
218                 $pt1recch = "CS6";#224ch:洋画★シネフィル・イマジカ
219         }elsif($recch == 292){
220                 $pt1recch = "CS6";#292ch:時代劇専門チャンネル
221         }elsif($recch == 238){
222                 $pt1recch = "CS6";#238ch:スター・チャンネル クラシック
223         }elsif($recch == 310){
224                 $pt1recch = "CS6";#310ch:スーパー!ドラマTV
225         }elsif($recch == 311){
226                 $pt1recch = "CS6";#311ch:AXN
227         }elsif($recch == 343){
228                 $pt1recch = "CS6";#343ch:ナショナルジオグラフィックチャンネル
229         }elsif($recch == 055){
230                 $pt1recch = "CS8";#055ch:ショップ チャンネル
231         }elsif($recch == 228){
232                 $pt1recch = "CS10";#228ch:ザ・シネマ
233         }elsif($recch == 800){
234                 $pt1recch = "CS10";#800ch:スカチャンHD800
235         }elsif($recch == 801){
236                 $pt1recch = "CS10";#801ch:スカチャン801
237         }elsif($recch == 802){
238                 $pt1recch = "CS10";#802ch:スカチャン802
239         }elsif($recch == 260){
240                 $pt1recch = "CS12";#260ch:ザ・ゴルフ・チャンネル
241         }elsif($recch == 303){
242                 $pt1recch = "CS12";#303ch:テレ朝チャンネル
243         }elsif($recch == 323){
244                 $pt1recch = "CS12";#323ch:MTV 324ch:大人の音楽専門TV◆ミュージック・エア
245         }elsif($recch == 352){
246                 $pt1recch = "CS12";#352ch:朝日ニュースター
247         }elsif($recch == 353){
248                 $pt1recch = "CS12";#353ch:BBCワールドニュース
249         }elsif($recch == 354){
250                 $pt1recch = "CS12";#354ch:CNNj
251         }elsif($recch == 361){
252                 $pt1recch = "CS12";#361ch:ジャスト・アイ インフォメーション
253         }elsif($recch == 251){
254                 $pt1recch = "CS14";#251ch:J sports 1
255         }elsif($recch == 252){
256                 $pt1recch = "CS14";#252ch:J sports 2
257         }elsif($recch == 253){
258                 $pt1recch = "CS14";#253ch:J sports Plus
259         }elsif($recch == 254){
260                 $pt1recch = "CS14";#254ch:GAORA
261         }elsif($recch == 255){
262                 $pt1recch = "CS14";#255ch:スカイ・Asports+
263         }elsif($recch == 305){
264                 $pt1recch = "CS16";#305ch:チャンネル銀河
265         }elsif($recch == 333){
266                 $pt1recch = "CS16";#333ch:アニメシアターX(AT-X)
267         }elsif($recch == 342){
268                 $pt1recch = "CS16";#342ch:ヒストリーチャンネル
269         }elsif($recch == 290){
270                 $pt1recch = "CS16";#290ch:TAKARAZUKA SKYSTAGE
271         }elsif($recch == 803){
272                 $pt1recch = "CS16";#803ch:スカチャン803
273         }elsif($recch == 804){
274                 $pt1recch = "CS16";#804ch:スカチャン804
275         }elsif($recch == 240){
276                 $pt1recch = "CS18";#240ch:ムービープラスHD
277         }elsif($recch == 262){
278                 $pt1recch = "CS18";#262ch:ゴルフネットワーク
279         }elsif($recch == 314){
280                 $pt1recch = "CS18";#314ch:LaLa HDHV
281         }elsif($recch == 258){
282                 $pt1recch = "CS20";#258ch:フジテレビ739
283         }elsif($recch == 302){
284                 $pt1recch = "CS20";#302ch:フジテレビ721
285         }elsif($recch == 332){
286                 $pt1recch = "CS20";#332ch:アニマックス
287         }elsif($recch == 340){
288                 $pt1recch = "CS20";#340ch:ディスカバリーチャンネル
289         }elsif($recch == 341){
290                 $pt1recch = "CS20";#341ch:アニマルプラネット
291         }elsif($recch == 160){
292                 $pt1recch = "CS22";#160ch:C-TBSウェルカムチャンネル
293         }elsif($recch == 161){
294                 $pt1recch = "CS22";#161ch:QVC
295         }elsif($recch == 185){
296                 $pt1recch = "CS22";#185ch:プライム365.TV
297         }elsif($recch == 293){
298                 $pt1recch = "CS22";#293ch:ファミリー劇場
299         }elsif($recch == 301){
300                 $pt1recch = "CS22";#301ch:TBSチャンネル
301         }elsif($recch == 304){
302                 $pt1recch = "CS22";#304ch:ディズニー・チャンネル
303         }elsif($recch == 325){
304                 $pt1recch = "CS22";#325ch:MUSIC ON! TV
305         #}elsif($recch == 330){
306         #       $pt1recch = "CS22";#330ch:キッズステーション  #HD化により2010/4変更
307         }elsif($recch == 351){
308                 $pt1recch = "CS22";#351ch:TBSニュースバード
309         }elsif($recch == 257){
310                 $pt1recch = "CS24";#ch:日テレG+
311         }elsif($recch == 291){
312                 $pt1recch = "CS24";#ch:fashiontv
313         }elsif($recch == 300){
314                 $pt1recch = "CS24";#ch:日テレプラス
315         }elsif($recch == 320){
316                 $pt1recch = "CS24";#ch:安らぎの音楽と風景/エコミュージックTV
317         }elsif($recch == 321){
318                 $pt1recch = "CS24";#ch:MusicJapan TV
319         }elsif($recch == 350){
320                 $pt1recch = "CS24";#ch:日テレNEWS24
321         }# end if CSリマップ
322
323 }else{
324         &writelog("digitaltvrecording :ERROR :Unsupported and type (digital CS).");
325         exit 3;
326 }
327
328 # PT1
329 # b25,recpt1があるか確認
330         if  (-e "$toolpath/perl/tool/recpt1"){
331                 if ($bandtype >= 1){ #BS/CSなら
332                 &writelog("digitaltvrecording DEBUG recpt1 --b25 --sid $originalrecch  $pt1recch $reclengthsec $outputfile   ");
333                 $oserr = system("$toolpath/perl/tool/recpt1 --b25 --sid $originalrecch $pt1recch $reclengthsec $outputfile  ");
334                 }else{ #地デジ
335                 &writelog("digitaltvrecording DEBUG recpt1 --b25  $originalrecch $reclengthsec $outputfile  ");
336                 $oserr = system("$toolpath/perl/tool/recpt1 --b25  $originalrecch $reclengthsec $outputfile  ");
337                 }
338                 $oserr = $oserr >> 8;
339                         if ($oserr > 0){
340                         &writelog("digitaltvrecording :ERROR :PT1 is BUSY.$oserr");
341                         $errorflag = 2;
342                         }
343         }else{ # エラー recpt1がありません
344                 &writelog("digitaltvrecording :ERROR :recpt1  not found. You must install $toolpath/tool/b25 and $toolpath/tool/recpt1.");
345         $errorflag = 1;
346         }
347 # friio
348 if ($errorflag >= 1 ){
349 # b25,recfriioがあるか確認
350         if  (-e "$toolpath/perl/tool/recfriio"){
351        
352         if (! -e "$toolpath/perl/tool/friiodetect"){
353                 system("touch $toolpath/perl/tool/friiodetect");
354                 system("chown foltia:foltia $toolpath/perl/tool/friiodetect");
355                 system("chmod 775 $toolpath/perl/tool/friiodetect");
356                 &writelog("digitaltvrecording :DEBUG make lock file.$toolpath/perl/tool/friiodetect");
357         }
358                 &writelog("digitaltvrecording DEBUG recfriio --b25 --lockfile $toolpath/perl/tool/friiodetect $recch $reclengthsec $outputfile  ");
359                 $oserr = system("$toolpath/perl/tool/recfriio --b25 --lockfile $toolpath/perl/tool/friiodetect $recch $reclengthsec $outputfile  ");
360                 $oserr = $oserr >> 8;
361                         if ($oserr > 0){
362                         &writelog("digitaltvrecording :ERROR :friio is BUSY.$oserr");
363                         exit 2;
364                         }
365
366 #BS1/BS2などのスプリットを
367 if ($bssplitflag == 101){
368         if (-e "$toolpath/perl/tool/TsSplitter.exe"){
369         # BS1           
370         system("wine $toolpath/perl/tool/TsSplitter.exe  -EIT -ECM  -EMM  -OUT \"$outputpath\" -HD  -SD2 -SD3 -1SEG  -LOGFILE -WAIT2 $outputfile");
371         $splitfile = $outputfile;
372         $splitfile =~ s/\.m2t$/_SD1.m2t/;
373                 if (-e "$splitfile"){
374                 system("rm -rf $outputfile ; mv $splitfile $outputfile");
375                 &writelog("digitaltvrecording DEBUG rm -rf $outputfile ; mv $splitfile $outputfile: $?.");
376                 }else{
377                 &writelog("digitaltvrecording ERROR File not found:$splitfile.");
378                 }
379         }else{
380         &writelog("digitaltvrecording ERROR $toolpath/perl/tool/TsSplitter.exe not found.");
381         }
382 }elsif($bssplitflag == 102){
383         if (-e "$toolpath/perl/tool/TsSplitter.exe"){
384         # BS2           
385         system("wine $toolpath/perl/tool/TsSplitter.exe  -EIT -ECM  -EMM  -OUT \"$outputpath\" -HD  -SD1 -SD3 -1SEG  -LOGFILE -WAIT2 $outputfile");
386         $splitfile = $outputfile;
387         $splitfile =~ s/\.m2t$/_SD2.m2t/;
388                 if (-e "$splitfile"){
389                 system("rm -rf $outputfile ; mv $splitfile $outputfile");
390                 &writelog("digitaltvrecording DEBUG rm -rf $outputfile ; mv $splitfile $outputfile: $?.");
391                 }else{
392                 &writelog("digitaltvrecording ERROR File not found:$splitfile.");
393                 }
394         }else{
395         &writelog("digitaltvrecording ERROR $toolpath/perl/tool/TsSplitter.exe not found.");
396         }
397 }else{
398         &writelog("digitaltvrecording DEBUG not split TS.$bssplitflag");
399 }# endif #BS1/BS2などのスプリットを
400
401         }else{ # エラー recfriioがありません
402                 &writelog("digitaltvrecording :ERROR :recfriio  not found. You must install $toolpath/perl/tool/b25 and $toolpath/perl/tool/recfriio:$errorflag");
403         #exit 1;
404         exit $errorflag;
405         }
406 }#end if errorflag
407 }#end calldigitalrecorder
408
409
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed