Index: trunk/install/perl/foltia_conf1.pl.template =================================================================== --- trunk/install/perl/foltia_conf1.pl.template (リビジョン 1) +++ trunk/install/perl/foltia_conf1.pl.template (リビジョン 8) @@ -20,6 +20,11 @@ $haveirdaunit = 1;#Tira-2をつないでいるときに1,なければ0 $mp4filenamestyle = 1 ;#0:PSP ファームウェアver.2.80より前と互換性を持つファイル名 1;よりわかりやすいファイル名 +$trconqty = 2; +#0:PSP/iPod XviD MPEG4(旧式):faacとMPEG4IPを使って変換 +#1:iPod Xvid MPEG4 標準画質 15fps 300kbps +#2:iPod H.264 中画質 24fps 300kbps +#3:iPod H.264 高画質 30fps 300kbps -#デフォルトでインストールしてればいじらなくてもいい +#以下はデフォルトでインストールしてればいじらなくてもいい $main::DBDriv="Pg"; $main::DBHost="localhost"; Index: trunk/install/perl/tvrecording.pl =================================================================== --- trunk/install/perl/tvrecording.pl (リビジョン 1) +++ trunk/install/perl/tvrecording.pl (リビジョン 8) @@ -24,5 +24,5 @@ -use Time::HiRes qw(usleep); +#use Time::HiRes qw(usleep); @@ -250,15 +250,20 @@ } #1分前にプロセス起動するから指定時間スリープ -srand(time ^ ($$ + ($$ << 15))); -my $useconds = int(rand(12000000)); -my $intval = int ($useconds / 1000000); -my $startupsleeptimemicro = ($startupsleeptime * 1000000) - $useconds; -$reclengthsec = $reclengthsec + $intval + 1; +#srand(time ^ ($$ + ($$ << 15))); +#my $useconds = int(rand(12000000)); +#my $intval = int ($useconds / 1000000); +#my $startupsleeptimemicro = ($startupsleeptime * 1000000) - $useconds; +#$reclengthsec = $reclengthsec + $intval + 1; +#&writelog("tvrecording: DEBUG SLEEP $startupsleeptime:$useconds:$intval:$startupsleeptimemicro"); +# usleep ( $startupsleeptimemicro ); + # $recch でウェイト調整入れましょう - - -&writelog("tvrecording: DEBUG SLEEP $startupsleeptime:$useconds:$intval:$startupsleeptimemicro"); - - usleep ( $startupsleeptimemicro ); +my $intval = $recch % 50; # 0〜49 +my $startupsleep = $startupsleeptime - $intval; # 3〜52 (VHF 40-51) +$reclengthsec = $reclengthsec + $intval + 1; # + +&writelog("tvrecording: DEBUG SLEEP $startupsleeptime:$intval:$startupsleep"); + +sleep ( $startupsleep); if ($recunits > 1){ Index: trunk/install/perl/ipodtranscode.pl =================================================================== --- trunk/install/perl/ipodtranscode.pl (リビジョン 8) +++ trunk/install/perl/ipodtranscode.pl (リビジョン 8) @@ -0,0 +1,118 @@ +#!/usr/bin/perl +#usage ipodtranscode.pl /path/to/mpeg2.m2p mp4filenamestring /path/to/mpeg2/tid.localized/mp4/ PID [aspect] +# +# Anime recording system foltia +# http://www.dcc-jpl.com/soft/foltia/ +# +# +# iPod MPEG4/H.264トラコン +# ffmpegを呼び出して変換 +# ffmpegはiPodパッチあて版を想定している +# ffmpegの作り方は +# http://www.dcc-jpl.com/diary/ddata2006/02A.html#20060215-00 +# +# DCC-JPL Japan/foltia project +# + +use DBI; +use DBD::Pg; +use Jcode; + + +$path = $0; +$path =~ s/ipodtranscode.pl$//i; +if ($pwd ne "./"){ +push( @INC, "$path"); +} + +require "foltialib.pl"; +#引き数がアルか? +$recch = $ARGV[0] ; +if ($recch eq "" ){ + #引き数なしで実行されたら、終了 + print "usage ipodtranscode.pl /path/to/mpeg2.m2p mp4filenamestring /path/to/mpeg2/tid.localized/mp4/ PID [aspect]\n"; + exit; +} + +$inputmpeg2 = $ARGV[0]; +$mp4filenamestring = $ARGV[1]; +$mp4outdir = $ARGV[2]; +$pid = $ARGV[3]; +$aspect = $ARGV[4]; + +#DB初期化 + my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", + $DBDriv,$DBName,$DBHost,$DBPort); + $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; + + +# タイトル取得 +if ($pid ne ""){ + +$DBQuery = "SELECT title , countno , subtitle +FROM foltia_program, foltia_subtitle +WHERE foltia_program.tid = foltia_subtitle.tid +AND foltia_subtitle.pid = $pid "; +$sth = $dbh->prepare($DBQuery); +$sth->execute(); +@programtitle = $sth->fetchrow_array; +$programtitle[0] =~ s/\"/\\"/gi; +$programtitle[2] =~ s/\"/\\"/gi; + + if ($pid > 0){ + if ($programtitle[1] ne ""){ + $movietitle = " -title \"$programtitle[0] 第$programtitle[1]話 $programtitle[2]\" "; + $movietitleeuc = " -t \"$programtitle[0] 第$programtitle[1]話 $programtitle[2]\" "; + }else{ + $movietitle = " -title \"$programtitle[0] $programtitle[2]\" "; + $movietitleeuc = " -t \"$programtitle[0] $programtitle[2]\" "; + } + }elsif($pid < 0){ + #EPG + $movietitle = " -title \"$programtitle[2]\" "; + $movietitleeuc = " -t \"$programtitle[2]\" "; + }else{# 0 + #空白 + $movietitle = ""; + $movietitleeuc = ""; + } +#Jcode::convert(\$movietitle,'utf8');# Title入れるとiTunes7.0.2がクラッシュする + $movietitle = ""; + $movietitleeuc = ""; + +} +# アスペクト比 +if ($aspect == 16){ +$cropopt = " -croptop 70 -cropbottom 60 -cropleft 8 -cropright 14 -aspect aspect 1.7777 "; +}else{ +$cropopt = " -croptop 8 -cropbottom 8 -cropleft 8 -cropright 14 "; +} +# クオリティごとに +if (($trconqty eq "")||($trconqty == 1)){#sample:src 106.6sec encode 82sec x0.77 382kbps @Celeron2.6GHz + +$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"; +$mp4file = "${mp4outdir}M4V${mp4filenamestring}.MP4"; + +}elsif($trconqty == 2){ #sample:src 106.6sec encode 117sec x1.1 597kbps @Celeron2.6GHz + +$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"; +$mp4file = "${mp4outdir}MAQ${mp4filenamestring}.MP4"; + +}elsif($trconqty == 3){ #sample:src 106.6sec encode 364sec x3.4 528kbps @Celeron2.6GHz + +$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"; +$mp4file = "${mp4outdir}MAQ${mp4filenamestring}.MP4"; +} + +$encodeoptionlog = $encodeoption; +Jcode::convert(\$encodeoptionlog,'euc'); + +&writelog("ipodtranscode START QTY=$trconqty $encodeoptionlog"); +#print "ffmpeg $encodeoptionlog \n"; +system ("/usr/local/bin/ffmpeg $encodeoption "); +&writelog("ipodtranscode FFEND $inputmpeg2"); + +&writelog("ipodtranscode mp4psp -p $mp4file $movietitleeuc"); +system("mp4psp -p $mp4file $movietitleeuc"); +&writelog("ipodtranscode mp4psp COMPLETE $mp4file "); + Index: trunk/install/perl/recwrap.pl =================================================================== --- trunk/install/perl/recwrap.pl (リビジョン 1) +++ trunk/install/perl/recwrap.pl (リビジョン 8) @@ -29,5 +29,5 @@ $recch = $ARGV[0] ; if ($recch eq "" ){ - #引き数なし出実行されたら、終了 + #引き数なしで実行されたら、終了 print "usage recwrap.pl ch length(sec) [bitrate(5)] [TID] [NO] [PID]\n"; exit; @@ -79,4 +79,5 @@ if ($oserr == 1){ &writelog("recwrap ABORT recfile exist. [$outputfilename] $recch $reclength 0 0 $bitrate $tid $countno $pid"); + exit; }else{ &writelog("recwrap RECEND [$outputfilename] $recch $reclength 0 0 $bitrate $tid $countno $pid"); @@ -243,27 +244,39 @@ # print "$pspfilname($pspfilnamehd/$pspfilnameft)\n"; }# endif MP4ファイル名が新styleなら - -&writelog("recwrap TRCNSTART vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]"); -#トラコン開始 -system("$toolpath/perl/transcode/vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]"); - -&writelog("recwrap TRCNEND vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]"); - -#最適化 - -$DBQuery = "SELECT subtitle FROM foltia_subtitle WHERE tid = '$tid' AND countno = '$countno' "; - $sth = $dbh->prepare($DBQuery); - $sth->execute(); - @programtitle = $sth->fetchrow_array; - -if ( $countno == "0" ){ - $pspcountno = ""; -}else{ - $pspcountno = $countno ; -} -&writelog("recwrap OPTIMIZE mp4psp -p $pspdirname/M4V$pspfilname.MP4 -t '$psptrcn[2] $pspcountno $programtitle[0]' "); -Jcode::convert(\$programtitle[0],'euc'); -system ("/usr/local/bin/mp4psp -p $pspdirname/M4V$pspfilname.MP4 -t '$psptrcn[2] $pspcountno $programtitle[0]'") ; - +#2006/12/03_10:30:24 recwrap TRCNSTART vfr4psp.sh /home/foltia/php/tv/591-87-20061203-1000.m2p -591-87-20061203-1000 /home/foltia/php/tv/591.localized/mp4/ 3 + +if (($trconqty eq "")||($trconqty == 0 )){ + &writelog("recwrap TRCNSTART vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]"); + system("$toolpath/perl/transcode/vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]"); + &writelog("recwrap TRCNEND vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]"); + #最適化 + $DBQuery = "SELECT subtitle FROM foltia_subtitle WHERE tid = '$tid' AND countno = '$countno' "; + $sth = $dbh->prepare($DBQuery); + $sth->execute(); + @programtitle = $sth->fetchrow_array; + if ( $countno == "0" ){ + $pspcountno = ""; + }else{ + $pspcountno = $countno ; + } + &writelog("recwrap OPTIMIZE mp4psp -p $pspdirname/M4V$pspfilname.MP4 -t '$psptrcn[2] $pspcountno $programtitle[0]' "); + Jcode::convert(\$programtitle[0],'euc'); + system ("/usr/local/bin/mp4psp -p $pspdirname/M4V$pspfilname.MP4 -t '$psptrcn[2] $pspcountno $programtitle[0]'") ; +$mp4filename = "M4V${pspfilname}.MP4"; +$thmfilename = "M4V${pspfilname}.THM"; +}else{# #2006/12/6 新エンコーダ + + &writelog("recwrap TRCNSTART ipodtranscode.pl $recfolderpath/$outputfilename $pspfilname $pspdirname $pid $psptrcn[1]"); + system("$toolpath/perl/ipodtranscode.pl $recfolderpath/$outputfilename $pspfilname $pspdirname $pid $psptrcn[1]"); + &writelog("recwrap TRCNEND ipodtranscode.pl $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]"); + + if($trconqty >= 2){#H.264/AVCなら + $mp4filename = "MAQ${pspfilname}.MP4"; + $thmfilename = "MAQ${pspfilname}.THM"; + }else{ + $mp4filename = "M4V${pspfilname}.MP4"; + $thmfilename = "M4V${pspfilname}.THM"; + } +} #サムネール @@ -275,11 +288,11 @@ &writelog("recwrap THAMI convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/M4V$pspdirname.THM "); -if (-e "$pspdirname/M4V".$pspfilname.".THM"){ +if (-e "$pspdirname/$thmfilename"){ $timestamp =`date "+%Y%m%d-%H%M%S"`; chomp $timestamp; - system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/M4V".$pspfilname.".THM.".$timestamp.".THM"); + system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename".$timestamp.".THM"); }else{ - system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/M4V".$pspfilname.".THM"); + system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename"); } # rm -rf 00000001.jpg @@ -293,5 +306,5 @@ # MP4ファイル名をPIDレコードに書き込み $DBQuery = "UPDATE foltia_subtitle SET - PSPfilename = 'M4V$pspfilname.MP4' + PSPfilename = '$mp4filename' WHERE pid = '$pid' "; $sth = $dbh->prepare($DBQuery); @@ -300,5 +313,5 @@ # MP4ファイル名をfoltia_mp4files挿入 - $DBQuery = "insert into foltia_mp4files values ('$tid','M4V$pspfilname.MP4') "; + $DBQuery = "insert into foltia_mp4files values ('$tid','$mp4filename') "; $sth = $dbh->prepare($DBQuery); $sth->execute();