root/trunk/install/perl/ipodtranscode.pl

リビジョン 83, 17.6 kB (コミッタ: sorshi, コミット時期: 16 年 前)

foltiaHD最初のリリース。
デジタル録画はFriio/Friio BS/CSのみに対応。
ivtvは1.0系使用になりました。

  • svn:executable 属性の設定値: *
Line 
1 #!/usr/bin/perl
2 #usage ipodtranscode.pl
3 #
4 # Anime recording system foltia
5 # http://www.dcc-jpl.com/soft/foltia/
6 #
7 # iPod MPEG4/H.264トラコン
8 # ffmpegを呼び出して変換
9 #
10 # DCC-JPL Japan/foltia project
11 #
12
13 use DBI;
14 use DBD::Pg;
15 use Jcode;
16
17 $path = $0;
18 $path =~ s/ipodtranscode.pl$//i;
19 if ($pwd  ne "./"){
20 push( @INC, "$path");
21 }
22 require "foltialib.pl";
23
24
25 # 二重起動の確認!
26 $processes =  &processfind("ipodtranscode.pl");
27 #$processes = $processes +  &processfind("ffmpeg");
28
29 if ($processes > 1 ){
30 &writelog("ipodtranscode processes exist. exit:");
31 exit;
32 }else{
33 #&writelog("ipodtranscode.pl  Normal launch.");
34 }
35
36 #DB初期化
37         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d",
38                 $DBDriv,$DBName,$DBHost,$DBPort);
39          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;;
40
41 # タイトル取得
42 #トラコンフラグがたっていてステータス50以上150未満のファイルを古い順にひとつ探す
43 # 数数える
44 #$DBQuery =  "SELECT count(*) FROM foltia_subtitle, foltia_program, foltia_m2pfiles
45 #WHERE filestatus >= $FILESTATUSRECEND AND filestatus < $FILESTATUSTRANSCODECOMPLETE  AND foltia_program.tid = foltia_subtitle.TID AND foltia_program.PSP = 1  AND foltia_m2pfiles.m2pfilename = foltia_subtitle.m2pfilename  ";
46 #$sth = $dbh->prepare($DBQuery);
47 #$sth->execute();
48 #@titlecount= $sth->fetchrow_array;
49 &writelog("ipodtranscode starting up.");
50
51 $counttranscodefiles = &counttranscodefiles();
52 if ($counttranscodefiles == 0){
53         &writelog("ipodtranscode No MPEG2 files to transcode.");
54         exit;
55 }
56 sleep 30;
57
58 while ($counttranscodefiles >= 1){
59
60 $DBQuery =  "SELECT foltia_subtitle.pid,foltia_subtitle.tid,foltia_subtitle.m2pfilename,filestatus,foltia_program.aspect ,foltia_subtitle.countno
61 FROM foltia_subtitle, foltia_program, foltia_m2pfiles
62 WHERE filestatus >= $FILESTATUSRECEND AND filestatus < $FILESTATUSTRANSCODECOMPLETE  AND foltia_program.tid = foltia_subtitle.TID AND foltia_program.PSP = 1  AND foltia_m2pfiles.m2pfilename = foltia_subtitle.m2pfilename
63 ORDER BY enddatetime ASC
64 LIMIT 1  ";
65
66 $sth = $dbh->prepare($DBQuery);
67 $sth->execute();
68 @dbparam = $sth->fetchrow_array;
69 #print "$dbparam[0],$dbparam[1],$dbparam[2],$dbparam[3],$dbparam[4],$dbparam[5]\n";
70 &writelog("ipodtranscode DEBUG $DBQuery");
71 &writelog("ipodtranscode DEBUG $dbparam[0],$dbparam[1],$dbparam[2],$dbparam[3],$dbparam[4],$dbparam[5]");
72 $pid = $dbparam[0];
73 $tid = $dbparam[1];
74 $inputmpeg2 = $recfolderpath."/".$dbparam[2]; # path付き
75 $mpeg2filename = $dbparam[2]; # pathなし
76 $filestatus = $dbparam[3];
77 $aspect = $dbparam[4];# 16,1 (超額縁),4,3
78 $countno = $dbparam[5];
79 $mp4filenamestring = &mp4filenamestringbuild($pid);
80
81 &writelog("ipodtranscode DEBUG mp4filenamestring $mp4filenamestring");
82 #展開ディレクトリ作成
83 $pspdirname = &makemp4dir($tid);
84 $mp4outdir = $pspdirname ;
85 # 実際のトラコン
86 # タイトル取得
87 if ($pid ne ""){
88
89 $DBQuery =  "SELECT title , countno , subtitle 
90 FROM  foltia_program, foltia_subtitle
91 WHERE foltia_program.tid = foltia_subtitle.tid
92 AND foltia_subtitle.pid = $pid ";
93 $sth = $dbh->prepare($DBQuery);
94 $sth->execute();
95 @programtitle = $sth->fetchrow_array;
96 $programtitle[0] =~ s/\"/\\"/gi;
97 $programtitle[2] =~ s/\"/\\"/gi;
98
99         if ($pid > 0){
100                 if ($programtitle[1] ne ""){
101                         $movietitle = " -title \"$programtitle[0] 第$programtitle[1]話 $programtitle[2]\" ";
102                         $movietitleeuc = " -t \"$programtitle[0] 第$programtitle[1]話 $programtitle[2]\" ";
103                 }else{
104                         $movietitle = " -title \"$programtitle[0] $programtitle[2]\" ";
105                         $movietitleeuc = " -t \"$programtitle[0] $programtitle[2]\" ";
106                 }
107         }elsif($pid < 0){
108         #EPG
109                 $movietitle = " -title \"$programtitle[2]\" ";
110                 $movietitleeuc = " -t \"$programtitle[2]\" ";
111         }else{# 0
112         #空白
113         $movietitle = "";
114         $movietitleeuc = "";
115         }
116 #Jcode::convert(\$movietitle,'utf8');# Title入れるとiTunes7.0.2がクラッシュする
117         $movietitle = "";
118         $movietitleeuc = "";
119
120 }
121
122 if ($filestatus <= $FILESTATUSRECEND){
123 }
124
125 if ($filestatus <= $FILESTATUSWAITINGCAPTURE){
126 #なにもしない
127 }
128
129 if ($filestatus <= $FILESTATUSCAPTURE){
130 #unlink
131 # Starlight breaker向けキャプチャ画像作成
132 if (-e "$toolpath/perl/captureimagemaker.pl"){
133         &writelog("ipodtranscode Call captureimagemaker $mpeg2filename");
134 &changefilestatus($pid,$FILESTATUSCAPTURE);
135         system ("$toolpath/perl/captureimagemaker.pl $mpeg2filename");
136 &changefilestatus($pid,$FILESTATUSCAPEND);
137 }
138 }
139
140 if ($filestatus <= $FILESTATUSCAPEND){
141 # サムネイル作る
142 &makethumbnail();
143 &changefilestatus($pid,$FILESTATUSTHMCREATE);
144 }
145
146 if ($filestatus <= $FILESTATUSWAITINGTRANSCODE){
147 }
148
149 $filenamebody = $inputmpeg2 ;
150 $filenamebody =~ s/.m2t$|.ts$|.m2p$|.mpg$//gi;
151 #デジタルかアナログか
152 if ($inputmpeg2 =~ /m2t$|ts$/i){
153         #print "MPEG2-TS\n";
154
155
156 if ($filestatus <= $FILESTATUSTRANSCODETSSPLITTING){
157                 unlink("${filenamebody}_tss.m2t");
158                 unlink("${filenamebody}_HD.m2t");
159 }
160 if ($filestatus <= $FILESTATUSTRANSCODEFFMPEG){
161
162         # H.264出力
163         $trcnmpegfile = $inputmpeg2 ;
164         # アスペクト比
165         if ($aspect == 1){#超額縁
166         $cropopt = " -croptop 150 -cropbottom 150 -cropleft 200 -cropright 200 ";
167         }elsif($aspect == 4){#SD
168         $cropopt = " -croptop 6 -cropbottom 6 -cropleft 8 -cropright 8 ";
169         }else{#16:9
170         $cropopt = " -croptop 6 -cropbottom 6 -cropleft 8 -cropright 8 ";
171         }
172         # クオリティごとに
173         if (($trconqty eq "")||($trconqty == 1)){
174         $ffmpegencopt = " -s 360x202 -deinterlace -r 24.00 -vcodec libx264 -g 300 -b 330000 -level 13 -loop 1 -sc_threshold 60 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264";
175         }elsif($trconqty == 2){
176         $ffmpegencopt = " -s 480x272 -deinterlace -r 29.97 -vcodec libx264 -g 300 -b 400000 -level 13 -loop 1 -sc_threshold 60 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264";
177         }elsif($trconqty == 3){#640x352
178         $ffmpegencopt = " -s 640x352 -deinterlace -r 29.97 -vcodec libx264 -g 100 -b 600000 -level 13 -loop 1 -sc_threshold 60 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264";
179         }
180         &changefilestatus($pid,$FILESTATUSTRANSCODEFFMPEG);
181         &writelog("ipodtranscode ffmpeg $filenamebody.264");
182         system ("ffmpeg -y -i $trcnmpegfile $cropopt $ffmpegencopt");
183        
184         #もしエラーになったらTsSplitする
185         if (! -e "$filenamebody.264"){
186                 &changefilestatus($pid,$FILESTATUSTRANSCODETSSPLITTING);
187                 unlink("${filenamebody}_tss.m2t");
188                 unlink("${filenamebody}_HD.m2t");
189                 if (-e "$toolpath/perl/tool/tss.py"){
190                 &writelog("ipodtranscode tss $inputmpeg2");
191                 system("$toolpath/perl/tool/tss.py $inputmpeg2");
192                
193                 }else{
194                 # TsSplit
195                 &writelog("ipodtranscode TsSplitter $inputmpeg2");
196                 system("wine $toolpath/perl/tool/TsSplitter.exe  -EIT -ECM  -EMM -SD -1SEG -WAIT2 $inputmpeg2");
197                 }
198                 if(-e "${filenamebody}_tss.m2t"){
199                 $trcnmpegfile = "${filenamebody}_tss.m2t";
200                 }elsif (-e "${filenamebody}_HD.m2t"){
201                 $trcnmpegfile = "${filenamebody}_HD.m2t";
202                 }else{
203                 &writelog("ipodtranscode ERR NOT Exist ${filenamebody}_HD.m2t");
204                 $trcnmpegfile = inputmpeg2 ;
205                 }
206                 #再ffmpeg
207                 &changefilestatus($pid,$FILESTATUSTRANSCODEFFMPEG);
208                 &writelog("ipodtranscode ffmpeg retry $filenamebody.264");
209                 system ("ffmpeg -y -i $trcnmpegfile $cropopt $ffmpegencopt");
210         }
211         #もしエラーになったらcropやめる
212         if (! -e "$filenamebody.264"){
213                 #再ffmpeg
214                 &changefilestatus($pid,$FILESTATUSTRANSCODEFFMPEG);
215                 &writelog("ipodtranscode ffmpeg retry no crop $filenamebody.264");
216                 system ("ffmpeg -y -i $trcnmpegfile $ffmpegencopt");
217         }
218 }
219 if ($filestatus <= $FILESTATUSTRANSCODEWAVE){
220         # WAVE出力
221         unlink("${filenamebody}.wav");
222         &changefilestatus($pid,$FILESTATUSTRANSCODEWAVE);
223         &writelog("ipodtranscode mplayer $filenamebody.wav");
224         system ("mplayer $trcnmpegfile -vc null -vo null -ao pcm:file=$filenamebody.wav:fast");
225
226 }
227 if ($filestatus <= $FILESTATUSTRANSCODEAAC){
228         # AAC変換
229         unlink("${filenamebody}.aac");
230         &changefilestatus($pid,$FILESTATUSTRANSCODEAAC);
231         if (-e "$toolpath/perl/tool/neroAacEnc"){
232                 if (-e "$filenamebody.wav"){
233         &writelog("ipodtranscode neroAacEnc $filenamebody.wav");
234         system ("$toolpath/perl/tool/neroAacEnc -br 128000  -if $filenamebody.wav  -of $filenamebody.aac");
235                 }else{
236                 &writelog("ipodtranscode ERR Not Found $filenamebody.wav");
237                 }
238         }else{
239         #print "DEBUG $toolpath/perl/tool/neroAacEnc\n\n";
240         &writelog("ipodtranscode faac $filenamebody.wav");
241         system ("faac -b 128  -o $filenamebody.aac $filenamebody.wav ");
242         }
243
244 }
245 if ($filestatus <= $FILESTATUSTRANSCODEMP4BOX){
246         # MP4ビルド
247         unlink("${filenamebody}.base.mp4");
248         &changefilestatus($pid,$FILESTATUSTRANSCODEMP4BOX);
249         &writelog("ipodtranscode MP4Box $filenamebody");
250                 system ("cd $recfolderpath ; MP4Box -fps 29.97 -add $filenamebody.264 -new $filenamebody.base.mp4");
251 #$exit_value = $? >> 8;
252 #$signal_num = $? & 127;
253 #$dumped_core = $? & 128;
254 #&writelog("ipodtranscode DEBUG MP4Box -fps 29.97 -add:$exit_value:$signal_num:$dumped_core");
255
256         if (-e "$filenamebody.base.mp4"){
257         system ("cd $recfolderpath ; MP4Box -add $filenamebody.aac $filenamebody.base.mp4");
258 #$exit_value = $? >> 8;
259 #$signal_num = $? & 127;
260 #$dumped_core = $? & 128;
261 #&writelog("ipodtranscode DEBUG MP4Box -add $filenamebody.aac:$exit_value:$signal_num:$dumped_core");
262         }else{
263         &writelog("ipodtranscode ERR File not exist.$filenamebody.base.mp4");
264         }
265
266 }
267
268 if ($filestatus <= $FILESTATUSTRANSCODEATOM){
269         unlink("${mp4outdir}MAQ${mp4filenamestring}.MP4");
270         # iPodヘッダ付加
271         &changefilestatus($pid,$FILESTATUSTRANSCODEATOM);
272         &writelog("ipodtranscode ATOM $filenamebody");
273         #system ("/usr/local/bin/ffmpeg -y -i $filenamebody.base.mp4 -vcodec copy -acodec copy -f ipod ${mp4outdir}MAQ${mp4filenamestring}.MP4");
274         system ("cd $recfolderpath ; MP4Box -ipod $filenamebody.base.mp4");
275 $exit_value = $? >> 8;
276 $signal_num = $? & 127;
277 $dumped_core = $? & 128;
278 &writelog("ipodtranscode DEBUG MP4Box -ipod:$exit_value:$signal_num:$dumped_core");
279         system("mv $filenamebody.base.mp4 ${mp4outdir}MAQ${mp4filenamestring}.MP4");
280         &writelog("ipodtranscode mv $filenamebody.base.mp4 ${mp4outdir}MAQ${mp4filenamestring}.MP4");
281 # ipodtranscode mv /home/foltia/php/tv/1329-21-20080829-0017.base.mp4 /home/foltia/php/tv/1329.localized/mp4/MAQ-/home/foltia/php/tv/1329-21-20080829-0017.MP4
282
283 }
284 if ($filestatus <= $FILESTATUSTRANSCODECOMPLETE){
285         # 中間ファイル消す
286         &changefilestatus($pid,$FILESTATUSTRANSCODECOMPLETE);
287         unlink("${filenamebody}_HD.m2t");
288         unlink("${filenamebody}_tss.m2t");
289         unlink("$filenamebody.264");
290         unlink("$filenamebody.wav");
291         unlink("$filenamebody.aac");
292         unlink("$filenamebody.base.mp4");
293        
294         &updatemp4file();
295
296 }
297
298 }else{ #デジタルかアナログか
299         #print "MPEG2\n";
300         # アスペクト比
301         if ($aspect == 16){
302         $cropopt = " -croptop 70 -cropbottom 60 -cropleft  8 -cropright 14 -aspect 16:9 ";
303         }else{
304         $cropopt = " -croptop 8 -cropbottom 8 -cropleft  8 -cropright 14 ";
305         }
306 # クオリティごとに
307 if (($trconqty eq "")||($trconqty == 1)){
308 #$encodeoption = "-y -i $inputmpeg2 -vcodec xvid $cropopt -s 320x240 -b 300 -bt 128 -r 14.985 -bufsize 192 -maxrate 512 -minrate 0 -deinterlace -acodec aac -ab 128 -ar 24000 -ac 2 $movietitle ${mp4outdir}M4V${mp4filenamestring}.MP4";
309 $mp4file = "${mp4outdir}M4V${mp4filenamestring}.MP4";
310 $encodeoption = "-y -i $inputmpeg2 vcodec libxvid $cropopt -s 320x240 -b 300 -bt 128 -r 14.985 -deinterlace -acodec libfaac -f ipod  ${mp4outdir}M4V${mp4filenamestring}.MP4";
311 #time ffmpeg -y  -i /home/foltia/php/tv/trcntest/nanoha-As-op.mpg -vcodec libxvid -croptop 8 -cropbottom 8 -cropleft  8 -cropright 14 -s 320x240 -b 300 -bt 128 -r 14.985 -deinterlace -acodec libfaac -f ipod M4V-Nanoha-As-OP.MP4
312 # 32sec
313 # 2.1MB
314 }elsif($trconqty == 2){
315 #$encodeoption = "-y -i $inputmpeg2  -target ipod -profile 51 -level 30 $cropopt -s 320x240 -b 300 -r 24 -acodec aac -ar 32000 -ac 2 $movietitle ${mp4outdir}MAQ${mp4filenamestring}.MP4";
316 $mp4file = "${mp4outdir}MAQ${mp4filenamestring}.MP4";
317 $encodeoption = "-y -i $inputmpeg2 -vcodec libx264 -croptop 8 $cropopt -s 320x240 -b 300 -bt 128 -r 24 -deinterlace -acodec libfaac -f ipod  ${mp4outdir}MAQ${mp4filenamestring}.MP4";
318 #time ffmpeg -y  -i /home/foltia/php/tv/trcntest/nanoha-As-op.mpg -vcodec libx264 -croptop 8 -cropbottom 8 -cropleft  8 -cropright 14 -s 320x240 -b 300 -bt 128 -r 24 -deinterlace -acodec libfaac -f ipod MAQ-Nanoha-As-OP.MP4
319 # 2min22sec
320 # 6.4MB
321 }elsif($trconqty == 3){
322 #$encodeoption = "-y -i $inputmpeg2  -target ipod -profile 51 -level 30 $cropopt  -acodec aac -ab 96 -vcodec h264  -maxrate 700 -minrate 0 -deinterlace -b 300 -ar 32000 -mbd 2 -coder 1 -cmp 2 -subcmp 2 -s 320x240 -r 30000/1001  -flags loop -trellis 2 -partitions parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 $movietitle ${mp4outdir}MAQ${mp4filenamestring}.MP4";
323 $mp4file = "${mp4outdir}MAQ${mp4filenamestring}.MP4";
324 $encodeoption = "-y -i $inputmpeg2  -vcodec libx264 $cropopt -s 320x240 -b 380 -bt 128 -r 29.97 -deinterlace -acodec libfaac -f ipod  ${mp4outdir}MAQ${mp4filenamestring}.MP4";
325 #time ffmpeg -y  -i /home/foltia/php/tv/trcntest/nanoha-As-op.mpg -vcodec libx264 -croptop 8 -cropbottom 8 -cropleft  8 -cropright 14 -s 320x240 -b 380 -bt 128 -r 29.97 -deinterlace -acodec libfaac -f ipod MAQ-Nanoha-As-OP.MP4
326 #  2m53.912s
327 # 7MB
328 }elsif($trconqty == 4){
329 #$encodeoption = "-y -i $inputmpeg2  -target ipod -profile 51 -level 30 $cropopt -s 480x360 -b 400 -r 24 -acodec aac -ar 32000 -ac 2 $movietitle ${mp4outdir}MAQ${mp4filenamestring}.MP4";
330 $mp4file = "${mp4outdir}MAQ${mp4filenamestring}.MP4";
331 $encodeoption = "-y -i $inputmpeg2 -vcodec libx264 $cropopt -s 640x480 -b 500 -maxrate 700 -bt 128 -r 29.97 -deinterlace -acodec libfaac -f ipod ${mp4outdir}MAQ${mp4filenamestring}.MP4";
332 #time ffmpeg -y  -i /home/foltia/php/tv/trcntest/nanoha-As-op.mpg -vcodec libx264 -croptop 8 -cropbottom 8 -cropleft  8 -cropright 14 -s 640x480 -b 500  -maxrate 700 -bt 128 -r 29.97 -deinterlace -acodec libfaac -f ipod MAQ-Nanoha-As-OP.MP4
333 # 11m0.294s
334 # 20MB
335 }elsif($trconqty == 5){
336 #$encodeoption = "-y -i $inputmpeg2  -target ipod -profile 51 -level 30 $cropopt  -acodec aac -ab 96 -vcodec h264  -maxrate 700 -minrate 0 -deinterlace -b 400 -ar 32000 -mbd 2 -coder 1 -cmp 2 -subcmp 2 -s 480x360 -r 30000/1001  -flags loop -trellis 2 -partitions parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 $movietitle ${mp4outdir}MAQ${mp4filenamestring}.MP4";
337 $mp4file = "${mp4outdir}MAQ${mp4filenamestring}.MP4";
338 $encodeoption = "-y -i $inputmpeg2 -vcodec libx264 -croptop 8 $cropopt -s 640x480 -b 500  -maxrate 700 -bt 128 -r 29.97 -deinterlace -flags loop -trellis 2 -partitions parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -acodec libfaac -f ipod ${mp4outdir}MAQ${mp4filenamestring}.MP4";
339 #time ffmpeg -y  -i /home/foltia/php/tv/trcntest/nanoha-As-op.mpg -vcodec libx264 -croptop 8 -cropbottom 8 -cropleft  8 -cropright 14 -s 640x480 -b 500  -maxrate 700 -bt 128 -r 29.97 -deinterlace -flags loop -trellis 2 -partitions parti4x4+parti8x8+partp4x4+partp8x8+partb8x8  -acodec libfaac -f ipod MAQ-Nanoha-As-OP.MP4
340 #  14m14.033s
341 # 18MB
342 }
343
344 $encodeoptionlog = $encodeoption;
345 Jcode::convert(\$encodeoptionlog,'euc');
346
347 &writelog("ipodtranscode START QTY=$trconqty $encodeoptionlog");
348 #print "ffmpeg $encodeoptionlog \n";
349 &changefilestatus($pid,$FILESTATUSTRANSCODEFFMPEG);
350 system ("ffmpeg  $encodeoption ");
351 &writelog("ipodtranscode FFEND $inputmpeg2");
352 &changefilestatus($pid,$FILESTATUSTRANSCODECOMPLETE);
353 #もう要らなくなった #2008/11/14
354 #&writelog("ipodtranscode mp4psp -p $mp4file $movietitleeuc");
355 #system("/usr/local/bin/mp4psp -p $mp4file '$movietitleeuc' ");
356 #&writelog("ipodtranscode mp4psp COMPLETE  $mp4file ");
357
358 &updatemp4file();
359 }#endif #デジタルかアナログか
360
361 $counttranscodefiles = &counttranscodefiles();
362 ############################
363 #一回で終らせるように
364 #exit;
365 }# end while
366 #残りファイルがゼロなら
367 &writelog("ipodtranscode ALL COMPLETE");
368 exit;
369
370 #-----------------------------------------------------------------------
371 sub mp4filenamestringbuild(){
372 #ファイル名決定
373 #1329-19-20080814-2337.m2t
374 my @mpegfilename = split(/\./,$dbparam[2]) ;
375 my $pspfilname = "-".$mpegfilename[0] ;
376 return("$pspfilname");
377 }#end sub mp4filenamestringbuild
378
379
380 sub makethumbnail(){
381 #サムネール
382 my $outputfilename = $inputmpeg2 ;#フルパス
383 my $thmfilename = "MAQ${mp4filenamestring}.THM";
384 &writelog("ipodtranscode DEBUG thmfilename $thmfilename");
385
386 system ("mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3  -v 3 $outputfilename");
387
388 &writelog("ipodtranscode DEBUG mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3  -v 3 $outputfilename");
389
390 if (-e "$pspdirname/$thmfilename"){
391 $timestamp =`date "+%Y%m%d-%H%M%S"`;
392 chomp $timestamp;
393         system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename".$timestamp.".THM");
394 }else{
395         system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename");
396 }
397 &writelog("ipodtranscode DEBUG convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename");
398
399 system("rm -rf $pspdirname/0000000*.jpg ");
400 &writelog("ipodtranscode DEBUG rm -rf $pspdirname/0000000*.jpg");
401
402 }#endsub makethumbnail
403
404 sub updatemp4file(){
405 my $mp4filename = "MAQ${mp4filenamestring}.MP4";
406
407 if (-e "${mp4outdir}MAQ${mp4filenamestring}.MP4"){
408 # MP4ファイル名をPIDレコードに書き込み
409         $DBQuery =  "UPDATE foltia_subtitle SET PSPfilename = '$mp4filename' WHERE pid = '$pid' ";
410          $sth = $dbh->prepare($DBQuery);
411         $sth->execute();
412 &writelog("ipodtranscode UPDATEsubtitleDB $DBQuery");
413
414 # MP4ファイル名をfoltia_mp4files挿入
415         $DBQuery = "insert into foltia_mp4files values ('$tid','$mp4filename') ";
416          $sth = $dbh->prepare($DBQuery);
417         $sth->execute();
418 &writelog("ipodtranscode UPDATEmp4DB $DBQuery");
419
420 &changefilestatus($pid,$FILESTATUSALLCOMPLETE);
421 }else{
422 &writelog("ipodtranscode ERR MP4 NOT EXIST $pid/$mp4filename");
423 }
424
425
426 }#updatemp4file
427
428 sub counttranscodefiles(){
429 my $DBQuery =  "SELECT count(*) FROM foltia_subtitle, foltia_program, foltia_m2pfiles
430 WHERE filestatus >= $FILESTATUSRECEND AND filestatus < $FILESTATUSTRANSCODECOMPLETE  AND foltia_program.tid = foltia_subtitle.TID AND foltia_program.PSP = 1  AND foltia_m2pfiles.m2pfilename = foltia_subtitle.m2pfilename  ";
431 $sth = $dbh->prepare($DBQuery);
432 $sth->execute();
433 my @titlecount= $sth->fetchrow_array;
434
435 return ($titlecount[0]);
436
437
438 }
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed