| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
$path = $0; |
|---|
| 20 |
$path =~ s/digitalradiorecording.pl$//i; |
|---|
| 21 |
if ($path ne "./"){ |
|---|
| 22 |
push( @INC, "$path"); |
|---|
| 23 |
} |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
$extendrecendsec = 10; |
|---|
| 27 |
|
|---|
| 28 |
$startupsleeptime = 57; |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
require 'foltialib.pl'; |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
&prepare; |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
&calldigitalrecorder; |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
sub prepare{ |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
$stationname = $ARGV[0] ; |
|---|
| 51 |
$lengthsec = $ARGV[1] ; |
|---|
| 52 |
$filename = $ARGV[2] ; |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
if (($stationname eq "" ) || ($lengthsec eq "") || ($filename eq "")){ |
|---|
| 56 |
print "usage digitalradiorecording.pl stationname length(sec) filename\n"; |
|---|
| 57 |
exit; |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
my $intval = 0; |
|---|
| 62 |
my $startupsleep = $startupsleeptime - $intval; |
|---|
| 63 |
$reclengthsec = $lengthsec + (60 - $startupsleep) + 10; |
|---|
| 64 |
|
|---|
| 65 |
if ( $sleeptype ne "N"){ |
|---|
| 66 |
&writelog("digitalradiorecording: DEBUG SLEEP $startupsleeptime:$intval:$startupsleep:$reclengthsec"); |
|---|
| 67 |
sleep ( $startupsleep); |
|---|
| 68 |
|
|---|
| 69 |
}else{ |
|---|
| 70 |
&writelog("digitalradiorecording: DEBUG RAPID START"); |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
$outputpath = "$recfolderpath"."/"; |
|---|
| 74 |
|
|---|
| 75 |
if ($countno eq "0"){ |
|---|
| 76 |
$outputfile = $outputpath.$tid."--"; |
|---|
| 77 |
}else{ |
|---|
| 78 |
$outputfile = $outputpath.$tid."-".$countno."-"; |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
if ($filename ne ""){ |
|---|
| 82 |
|
|---|
| 83 |
$outputfile = $filename ; |
|---|
| 84 |
$outputfile = &filenameinjectioncheck($outputfile); |
|---|
| 85 |
$outputfilewithoutpath = $outputfile ; |
|---|
| 86 |
$outputfile = $outputpath.$outputfile ; |
|---|
| 87 |
&writelog("digitalradiorecording: DEBUG FILENAME ne null \$outputfile $outputfile "); |
|---|
| 88 |
}else{ |
|---|
| 89 |
$outputfile .= strftime("%Y%m%d-%H%M", localtime(time + 60)); |
|---|
| 90 |
chomp($outputfile); |
|---|
| 91 |
$outputfile .= ".aac"; |
|---|
| 92 |
$outputfilewithoutpath = $outputfile ; |
|---|
| 93 |
&writelog("digitalradiorecording: DEBUG FILENAME is null \$outputfile $outputfile "); |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
@wday_name = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); |
|---|
| 98 |
$sleepcounter = 0; |
|---|
| 99 |
$cmd=""; |
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
if ( -e "$outputfile" ){ |
|---|
| 103 |
if ( -s "$outputfile" ){ |
|---|
| 104 |
&writelog("digitalradiorecording :ABORT :recfile $outputfile exist."); |
|---|
| 105 |
exit 1; |
|---|
| 106 |
} |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
} |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
sub calldigitalrecorder{ |
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
if (-e "$toolpath/perl/tool/rtmpdump"){ |
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
&writelog("digitalradiorecording :DEBUG :$toolpath/perl/tool/rtmpdump -r \"rtmpe://radiko.smartstream.ne.jp:1935/$stationname/_defInst_/simul-stream\" -s \"http://radiko.jp/player/player.html#${stationname}\" -f \"WIN 10,0,45,2\" -v -B $reclengthsec -o ${outputfile}.flv"); |
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
system("$toolpath/perl/tool/rtmpdump -r \"rtmpe://radiko.smartstream.ne.jp:1935/$stationname/_defInst_/simul-stream\" -s \"http://radiko.jp/player/player.html#${stationname}\" -f \"WIN 10,0,45,2\" -v -B $reclengthsec -o ${outputfile}.flv"); |
|---|
| 128 |
|
|---|
| 129 |
&writelog("digitalradiorecording :DEBUG :ffmpeg -y -i ${outputfile}.flv -vn -acodec copy $outputfile"); |
|---|
| 130 |
|
|---|
| 131 |
system("ffmpeg -y -i ${outputfile}.flv -vn -acodec copy $outputfile"); |
|---|
| 132 |
|
|---|
| 133 |
unlink("${outputfile}.flv"); |
|---|
| 134 |
}else{ |
|---|
| 135 |
&writelog("digitalradiorecording :ABORT :File not found,recordable ffmpeg on $toolpath/perl/tool/ffmpeg. Show http://d.hatena.ne.jp/nazodane/20100315/1268646192 "); |
|---|
| 136 |
exit 1; |
|---|
| 137 |
} |
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
} |
|---|
| 142 |
|
|---|
| 143 |
|
|---|