チェンジセット 125: trunk/install/perl/ipodtranscode.pl
- コミット日時:
- 2010/10/19 19:07:34 (15 年前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
- trunk/install/perl/ipodtranscode.pl- r111 - r125 - 71 - 71 - $mp4filenamestring = &mp4filenamestringbuild($pid); - 72 - 72 - 73 - if (-e $inputmpeg2){#MPEG2ファイルが存在していれば - 74 - 73 - 75 - &writelog("ipodtranscode DEBUG mp4filenamestring $mp4filenamestring"); - 74 - 76 - #展開ディレクトリ作成 - … - … - 145 - 147 - } - 146 - 148 - if ($filestatus <= $FILESTATUSTRANSCODEFFMPEG){ - 147 - 149 - unlink("$filenamebody.264"); - 148 - 150 - # H.264出力 - 149 - 151 - $trcnmpegfile = $inputmpeg2 ; - … - … - 158 - 160 - # クオリティごとに - 159 - 161 - if (($trconqty eq "")||($trconqty == 1)){ - 160 - $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";- 162 - $ffmpegencopt = " -threads 0 -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"; - 161 - 163 - }elsif($trconqty == 2){ - 162 - 164 - # $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"; - 163 - 165 - # for ffmpeg 0.5 or later - 164 - $ffmpegencopt = " - - s 480x272 -deinterlace -r 29.97 -vcodec libx264 -vpre default -g 300 -b 400000 -level 13 -sc_threshold 60 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264";- 166 - $ffmpegencopt = " -threads 0 -s 480x272 -deinterlace -r 29.97 -vcodec libx264 -vpre default -g 300 -b 400000 -level 13 -sc_threshold 60 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; - 165 - 167 - }elsif($trconqty == 3){#640x352 - 166 - 168 - # $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"; - 167 - 169 - # for ffmpeg 0.5 or later - 168 - $ffmpegencopt = " - - s 640x352 -deinterlace -r 29.97 -vcodec libx264 -vpre default -g 100 -b 600000 -level 13 -sc_threshold 60 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264";- 170 - $ffmpegencopt = " -threads 0 -s 640x352 -deinterlace -r 29.97 -vcodec libx264 -vpre default -g 100 -b 600000 -level 13 -sc_threshold 60 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; - 169 - 171 - } - 170 - 172 - &changefilestatus($pid,$FILESTATUSTRANSCODEFFMPEG); - 171 - &writelog("ipodtranscode ffmpeg $filenamebody.264"); - 172 - system ("ffmpeg -y -i $trcnmpegfile $cropopt $ffmpegencopt"); - 173 - 174 - #もしエラーになったらTsSplitする - 173 - # &writelog("ipodtranscode ffmpeg $filenamebody.264"); - 174 - # system ("ffmpeg -y -i $trcnmpegfile $cropopt $ffmpegencopt"); - 175 - #まずTsSplitする →ワンセグをソースにしてしまわないように - 175 - 176 - if (! -e "$filenamebody.264"){ - 176 - 177 - &changefilestatus($pid,$FILESTATUSTRANSCODETSSPLITTING); - … - … - 180 - 181 - &writelog("ipodtranscode tss $inputmpeg2"); - 181 - 182 - system("$toolpath/perl/tool/tss.py $inputmpeg2"); - 182 - 183 - 183 - }else{ - 184 - 184 - # TsSplit - 185 - &writelog("ipodtranscode TsSplitter $inputmpeg2");- 186 - system("wine $toolpath/perl/tool/TsSplitter.exe -EIT -ECM -EMM -SD -1SEG -WAIT2 $inputmpeg2");- 185 - # &writelog("ipodtranscode TsSplitter $inputmpeg2"); - 186 - # system("wine $toolpath/perl/tool/TsSplitter.exe -EIT -ECM -EMM -SD -1SEG -WAIT2 $inputmpeg2"); - 187 - 187 - } - 188 - 188 - if(-e "${filenamebody}_tss.m2t"){ - … - … - 192 - 192 - }else{ - 193 - 193 - &writelog("ipodtranscode ERR NOT Exist ${filenamebody}_HD.m2t"); - 194 - $trcnmpegfile = inputmpeg2 ; - 195 - } - 194 - $trcnmpegfile = $inputmpeg2 ; - 195 - } - 196 - #Splitファイルの確認 - 197 - $trcnmpegfile = &validationsplitfile($inputmpeg2,$trcnmpegfile); - 198 - #tss.pyに失敗してたなら強制的にWINEでTsSplit.exe - 199 - if($trcnmpegfile eq $inputmpeg2){ - 200 - 201 - # TsSplit - 202 - &writelog("ipodtranscode WINE TsSplitter.exe $inputmpeg2"); - 203 - system("wine $toolpath/perl/tool/TsSplitter.exe -EIT -ECM -EMM -SD -1SEG -WAIT2 $inputmpeg2"); - 204 - if (-e "${filenamebody}_HD.m2t"){ - 205 - $trcnmpegfile = "${filenamebody}_HD.m2t"; - 206 - #Splitファイルの確認 - 207 - $trcnmpegfile = &validationsplitfile($inputmpeg2,$trcnmpegfile); - 208 - # if($trcnmpegfile ne $inputmpeg2){ - 209 - # &changefilestatus($pid,$FILESTATUSTRANSCODEFFMPEG); - 210 - # &writelog("ipodtranscode ffmpeg retry ; WINE TsSplitter.exe $trcnmpegfile"); - 211 - # system ("ffmpeg -y -i $trcnmpegfile $cropopt $ffmpegencopt"); - 212 - # }else{ - 213 - # &writelog("ipodtranscode WINE TsSplit.exe fail"); - 214 - # } - 215 - }else{ - 216 - &writelog("ipodtranscode WINE TsSplitter.exe ;Not exist ${filenamebody}_HD.m2t"); - 217 - }#endif -e ${filenamebody}_HD.m2t - 218 - 219 - }#endif $trcnmpegfile eq $inputmpeg2 - 220 - 221 - 196 - 222 - #再ffmpeg - 197 - 223 - &changefilestatus($pid,$FILESTATUSTRANSCODEFFMPEG); - … - … - 205 - 231 - &writelog("ipodtranscode ffmpeg retry no crop $filenamebody.264"); - 206 - 232 - system ("ffmpeg -y -i $trcnmpegfile $ffmpegencopt"); - 233 - } - 234 - #強制的にWINEでTsSplit.exe - 235 - if (! -e "$filenamebody.264"){ - 236 - } - 237 - #それでもエラーならsplitしてないファイルをターゲットに - 238 - if (! -e "$filenamebody.264"){ - 239 - #再ffmpeg - 240 - &changefilestatus($pid,$FILESTATUSTRANSCODEFFMPEG); - 241 - &writelog("ipodtranscode ffmpeg retry No splited originalTS file $filenamebody.264"); - 242 - system ("ffmpeg -y -i $inputmpeg2 $ffmpegencopt"); - 207 - 243 - } - 208 - 244 - } - … - … - 312 - 348 - } - 313 - 349 - unlink("${filenamebody}_HD.m2t"); - 350 - # ConfigによってTSファイルは常にsplitした状態にするかどうか選択 - 351 - # B25失敗したときにここが走るとファイルぶっ壊れるので検証を入れる - 352 - # - 353 - # if (-e "${filenamebody}_tss.m2t"){ - 354 - # unlink("${filenamebody}.m2t"); - 355 - # unless (rename "${filenamebody}_tss.m2t", "${filenamebody}.m2t") { - 356 - # &writelog("ipodtranscode WARNING RENAME FAILED ${filenamebody}_tss.m2t ${filenamebody}.m2t"); - 357 - # }else{ - 358 - # - 359 - # } - 360 - # } - 314 - 361 - unlink("${filenamebody}_tss.m2t"); - 315 - 362 - unlink("$filenamebody.264"); - … - … - 386 - 433 - #一回で終らせるように - 387 - 434 - #exit; - 435 - 436 - 437 - }else{#ファイルがなければ - 438 - &writelog("ipodtranscode NO $inputmpeg2 file.Skip."); - 439 - }#end if - 440 - 388 - 441 - }# end while - 389 - 442 - #残りファイルがゼロなら - 390 - 443 - &writelog("ipodtranscode ALL COMPLETE"); - 391 - 444 - exit; - 445 - 392 - 446 - 393 - 447 - #----------------------------------------------------------------------- - … - … - 464 - 518 - 465 - 519 - 466 - } - 520 - }#end sub counttranscodefiles - 521 - 522 - 523 - sub validationsplitfile{ - 524 - my $inputmpeg2 = $_[0]; - 525 - my $trcnmpegfile = $_[1]; - 526 - 527 - #Split結果確認 - 528 - my $filesizeoriginal = -s $inputmpeg2 ; - 529 - my $filesizesplit = -s $trcnmpegfile; - 530 - my $validation = 0; - 531 - if ($filesizesplit > 0){ - 532 - $validation = $filesizeoriginal / $filesizesplit ; - 533 - if ($validation > 2 ){ - 534 - #print "Fail split may be fail.\n"; - 535 - &writelog("ipodtranscode ERR File split may be fail: $filesizeoriginal:$filesizesplit"); - 536 - $trcnmpegfile = $inputmpeg2 ; - 537 - unlink("${filenamebody}_tss.m2t"); - 538 - unlink("${filenamebody}_HD.m2tt"); - 539 - return ($trcnmpegfile); - 540 - }else{ - 541 - #print "Fail split may be good.\n"; - 542 - return ($trcnmpegfile); - 543 - } - 544 - }else{ - 545 - #Fail - 546 - &writelog("ipodtranscode ERR File split may be fail: $filesizeoriginal:$filesizesplit"); - 547 - $trcnmpegfile = $inputmpeg2 ; - 548 - unlink("${filenamebody}_tss.m2t"); - 549 - unlink("${filenamebody}_HD.m2tt"); - 550 - return ($trcnmpegfile); - 551 - } - 552 - }#end sub validationsplitfile - 553 


