チェンジセット 83: trunk/install
- コミット日時:
- 2008/12/30 22:12:46 (16 年前)
- ファイル:
-
- trunk/install/mktable.txt (更新) (5 diffs)
- trunk/install/perl/addpidatq.pl (更新) (2 diffs)
- trunk/install/perl/captureimagemaker.pl (更新) (2 diffs)
- trunk/install/perl/deletemovie.pl (更新) (1 diff)
- trunk/install/perl/digitaltvrecording.pl (追加)
- trunk/install/perl/foltia_conf1.pl.template (更新) (1 diff)
- trunk/install/perl/foltialib.pl (更新) (2 diffs)
- trunk/install/perl/ipodtranscode.pl (更新) (6 diffs)
- trunk/install/perl/record-v4l2.pl (追加)
- trunk/install/perl/recwrap.pl (更新) (7 diffs)
- trunk/install/perl/tool (追加)
- trunk/install/perl/tvrecording.pl (更新) (9 diffs)
- trunk/install/perl/updatem2pfiletable.pl (更新) (2 diffs)
- trunk/install/php/foltia_config2.php.template (更新) (2 diffs)
- trunk/install/php/img/icon.png (追加)
- trunk/install/php/index.php (更新) (6 diffs)
- trunk/install/php/iui (追加)
- trunk/install/php/listreserve.php (更新) (15 diffs)
- trunk/install/php/m.php (更新) (6 diffs)
- trunk/install/php/reservecomp.php (更新) (2 diffs)
- trunk/install/php/reserveepgcomp.php (更新) (3 diffs)
- trunk/install/php/reserveprogram.php (更新) (2 diffs)
- trunk/install/php/selectcaptureimage.php (更新) (2 diffs)
- trunk/install/php/showlib.php (更新) (6 diffs)
- trunk/install/php/showlibc.php (更新) (10 diffs)
- trunk/install/php/showplaylist.php (更新) (4 diffs)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
trunk/install/mktable.txt
r70 r83 1 1 2 drop table foltia_program ; 2 3 … … 33 34 m2pfilename text , 34 35 PSPfilename text , 35 epgaddedby int8 36 epgaddedby int8 , 37 lastupdate timestamp, 38 filestatus int4 36 39 ); 37 40 create unique index foltia_subtitle_pid_index on foltia_subtitle (pid); … … 46 49 drop table foltia_tvrecord; 47 50 create table foltia_tvrecord ( 48 tid int8 PRIMARY KEY,51 tid int8 , 49 52 stationid int8, 50 bitrate int8 53 bitrate int8 , 54 digital int8 51 55 ); 52 56 create index foltia_tvrecord_tid_index on foltia_tvrecord (tid); … … 99 103 tunerch text, 100 104 device text, 101 ontvcode text 105 ontvcode text, 106 digitalch bigint, 107 digitalstationband bigint 102 108 ); 103 109 REVOKE ALL on "foltia_station" from PUBLIC; … … 133 139 -- 134 140 INSERT INTO foltia_program VALUES (0, 'EPG録画', '', '', NULL, '', '', 3, 1, '', ''); 135 INSERT INTO foltia_tvrecord VALUES (0,0,5); 136 137 INSERT INTO foltia_station VALUES (1, 'NHK総合', 1, 'NHK', '', NULL, NULL, NULL, '0031.ontvjapan.com'); 138 INSERT INTO foltia_station VALUES (3, 'NHK教育', 3, 'ETV', '', NULL, NULL, NULL, '0041.ontvjapan.com'); 139 INSERT INTO foltia_station VALUES (4, '日本テレビ', 4, 'NTV', '', NULL, NULL, NULL, '0004.ontvjapan.com'); 140 INSERT INTO foltia_station VALUES (6, 'TBS', 6, 'TBS', '', NULL, NULL, NULL, '0005.ontvjapan.com'); 141 INSERT INTO foltia_station VALUES (8, 'フジテレビ', 8, 'CX', '', NULL, NULL, NULL, '0006.ontvjapan.com'); 142 INSERT INTO foltia_station VALUES (10, 'テレビ朝日', 10, 'EX', '', NULL, NULL, NULL, '0007.ontvjapan.com'); 143 INSERT INTO foltia_station VALUES (12, 'テレビ東京', 12, 'TX', '', NULL, NULL, NULL, '0008.ontvjapan.com'); 144 INSERT INTO foltia_station VALUES (422, '東海テレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL); 145 INSERT INTO foltia_station VALUES (42, 'tvk', 5, 'TVK', '', NULL, NULL, NULL, '0009.ontvjapan.com'); 146 INSERT INTO foltia_station VALUES (423, 'ShowTime', -10, NULL, NULL, NULL, NULL, NULL, NULL); 147 INSERT INTO foltia_station VALUES (424, 'メ〜テレ', -10, NULL, NULL, NULL, NULL, NULL, NULL); 148 INSERT INTO foltia_station VALUES (409, 'BS日テレ', 0, '', '', 'b', 'X141', NULL, '3004.ontvjapan.com'); 149 INSERT INTO foltia_station VALUES (384, 'BS朝日', 0, '', '', 'b', 'X151', NULL, '3005.ontvjapan.com'); 150 INSERT INTO foltia_station VALUES (425, '三重テレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL); 151 INSERT INTO foltia_station VALUES (426, '中京テレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL); 152 INSERT INTO foltia_station VALUES (293, 'AT-X', 0, '', '', NULL, NULL, NULL, NULL); 153 INSERT INTO foltia_station VALUES (161, 'BS-i', 0, '', '', 'b', 'X161', NULL, '3006.ontvjapan.com'); 154 INSERT INTO foltia_station VALUES (382, 'BSジャパン', 0, '', '', 'b', 'X171', NULL, '3007.ontvjapan.com'); 155 INSERT INTO foltia_station VALUES (295, 'フジ721', -10, '', '', NULL, NULL, NULL, NULL); 156 INSERT INTO foltia_station VALUES (380, 'スカパー180ch', -10, '', '', NULL, NULL, NULL, NULL); 157 INSERT INTO foltia_station VALUES (427, '岐阜放送', -10, NULL, NULL, NULL, NULL, NULL, NULL); 158 INSERT INTO foltia_station VALUES (428, 'テレビ新広島', -10, NULL, NULL, NULL, NULL, NULL, NULL); 159 INSERT INTO foltia_station VALUES (383, 'サンテレビ', -10, '', '', NULL, NULL, NULL, NULL); 160 INSERT INTO foltia_station VALUES (429, 'CBCテレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL); 161 INSERT INTO foltia_station VALUES (385, 'TBSチャンネル', 0, '', '', NULL, NULL, NULL, NULL); 162 INSERT INTO foltia_station VALUES (386, 'テレ朝チャンネル', 0, '', '', NULL, NULL, NULL, NULL); 163 INSERT INTO foltia_station VALUES (389, 'BS Japan', 0, '', '', 'b', 'X171', NULL, NULL); 164 INSERT INTO foltia_station VALUES (390, 'サンテレビジョン', -10, '', '', NULL, NULL, NULL, NULL); 165 INSERT INTO foltia_station VALUES (0, '[全局]', 0, NULL, NULL, NULL, NULL, NULL, NULL); 166 INSERT INTO foltia_station VALUES (392, 'スカパー183ch', 0, '', '', NULL, NULL, NULL, NULL); 167 INSERT INTO foltia_station VALUES (393, 'BSQR 489', -10, '', '', 'b', 'X489', NULL, NULL); 168 INSERT INTO foltia_station VALUES (394, 'スカパー160ch', -10, '', '', NULL, NULL, NULL, NULL); 169 INSERT INTO foltia_station VALUES (396, 'KBS京都', -10, '', '', NULL, NULL, NULL, NULL); 170 INSERT INTO foltia_station VALUES (398, 'テレビ大阪', -10, '', '', NULL, NULL, NULL, NULL); 171 INSERT INTO foltia_station VALUES (399, 'ABCテレビ', -10, '', '', NULL, NULL, NULL, NULL); 172 INSERT INTO foltia_station VALUES (400, 'なし', -10, '', '', NULL, NULL, NULL, NULL); 173 INSERT INTO foltia_station VALUES (402, '関西テレビ', -10, '', '', NULL, NULL, NULL, NULL); 174 INSERT INTO foltia_station VALUES (406, 'MBS毎日放送', -10, '', '', NULL, NULL, NULL, NULL); 175 INSERT INTO foltia_station VALUES (407, 'animate.tv', -10, '', '', NULL, NULL, NULL, NULL); 176 INSERT INTO foltia_station VALUES (410, 'テレビ愛知', -10, '', '', NULL, NULL, NULL, NULL); 177 INSERT INTO foltia_station VALUES (411, 'インターネット', -10, '', '', NULL, NULL, NULL, NULL); 178 INSERT INTO foltia_station VALUES (381, 'BSフジ', 0, '', '', 'b', 'X181', NULL, '3008.ontvjapan.com'); 179 INSERT INTO foltia_station VALUES (413, 'ytv', -10, '', '', NULL, NULL, NULL, NULL); 180 INSERT INTO foltia_station VALUES (414, 'LFX488', -10, '', '', NULL, NULL, NULL, NULL); 181 INSERT INTO foltia_station VALUES (415, 'LFX', -10, '', '', NULL, NULL, NULL, NULL); 182 INSERT INTO foltia_station VALUES (416, 'LFX BB', -10, '', '', NULL, NULL, NULL, NULL); 183 INSERT INTO foltia_station VALUES (191, 'WOWOW', 0, 'BS5', '', 'b', 'X191', NULL, '3009.ontvjapan.com'); 184 INSERT INTO foltia_station VALUES (419, 'GyaO', -10, '', '', NULL, NULL, NULL, NULL); 185 INSERT INTO foltia_station VALUES (418, '放送大学', 0, 'UAIR', '', NULL, NULL, NULL, '0013.ontvjapan.com'); 186 INSERT INTO foltia_station VALUES (420, 'WOWOW2', 0, NULL, NULL, 'b', 'X192', NULL, '3010.ontvjapan.com'); 187 INSERT INTO foltia_station VALUES (417, 'とちぎテレビ', -10, 'TTV', '', NULL, NULL, NULL, NULL); 188 INSERT INTO foltia_station VALUES (412, '群馬テレビ', -10, 'GTV', '', NULL, NULL, NULL, NULL); 189 INSERT INTO foltia_station VALUES (46, 'チバテレビ', -10, 'CTC', '', NULL, NULL, NULL, NULL); 190 INSERT INTO foltia_station VALUES (38, 'テレ玉', -10, 'TVS', '', NULL, NULL, NULL, NULL); 191 INSERT INTO foltia_station VALUES (14, 'TOKYO MX', 0, 'MX', '', NULL, NULL, NULL, NULL); 192 INSERT INTO foltia_station VALUES (421, 'WOWOW3', 0, NULL, NULL, 'b', 'X193', NULL, '3011.ontvjapan.com'); 193 INSERT INTO foltia_station VALUES (401, 'チャンネルNECO', 0, '', '', 'c', 'X242', NULL, '1008.ontvjapan.com'); 194 INSERT INTO foltia_station VALUES (395, 'カミングスーンTV', 0, '', '', 'c', 'X245', NULL, '1012.ontvjapan.com'); 195 INSERT INTO foltia_station VALUES (408, 'ファミリー劇場', 0, '', '', 'c', 'X254', NULL, '1015.ontvjapan.com'); 196 INSERT INTO foltia_station VALUES (397, 'カートゥーンネットワーク', 0, '', '', 'c', 'X262', NULL, '1046.ontvjapan.com'); 197 INSERT INTO foltia_station VALUES (103, 'NHK-BShi', 0, '', '', 'b', 'X103', '', '3003.ontvjapan.com'); 198 INSERT INTO foltia_station VALUES (101, 'NHK-BS1', 0, 'BS7', '', 'b', 'X101',NULL, '3001.ontvjapan.com'); 199 INSERT INTO foltia_station VALUES (102, 'NHK-BS2', 0, 'BS11', '', 'b', 'X102',NULL, '3002.ontvjapan.com'); 200 INSERT INTO foltia_station VALUES (261, 'キッズステーション', 0, '', '', 'c', 'X264', '', '1045.ontvjapan.com'); 201 INSERT INTO foltia_station VALUES (263, 'アニマックス', 0, '', '', 'c', 'X263', '', '1047.ontvjapan.com'); 141 INSERT INTO foltia_tvrecord VALUES (0,0,5,1); 142 143 144 145 INSERT INTO foltia_station VALUES (0, '[全局]', 0, '', '', '', '', '', '',NULL,NULL); 146 INSERT INTO foltia_station VALUES (1, 'NHK総合', 1, 'NHK', '', NULL, NULL, NULL, '0031.ontvjapan.com',27,0); 147 INSERT INTO foltia_station VALUES (3, 'NHK教育', 3, 'ETV', '', NULL, NULL, NULL, '0041.ontvjapan.com',26,0); 148 INSERT INTO foltia_station VALUES (4, '日本テレビ', 4, 'NTV', '', NULL, NULL, NULL, '0004.ontvjapan.com',25,0); 149 INSERT INTO foltia_station VALUES (6, 'TBS', 6, 'TBS', '', NULL, NULL, NULL, '0005.ontvjapan.com',22,0); 150 INSERT INTO foltia_station VALUES (8, 'フジテレビ', 8, 'CX', '', NULL, NULL, NULL, '0006.ontvjapan.com',21,0); 151 INSERT INTO foltia_station VALUES (10, 'テレビ朝日', 10, 'EX', '', NULL, NULL, NULL, '0007.ontvjapan.com',24,0); 152 INSERT INTO foltia_station VALUES (12, 'テレビ東京', 12, 'TX', '', NULL, NULL, NULL, '0008.ontvjapan.com',23,0); 153 INSERT INTO foltia_station VALUES (42, 'tvk', 42, 'TVK', '', '', '', '', '0009.ontvjapan.com',18,0); 154 INSERT INTO foltia_station VALUES (14, 'TOKYO MX', 14, 'MX', '', '', '', '', '0016.ontvjapan.com',20,0); 155 INSERT INTO foltia_station VALUES (46, 'チバテレビ', -10, 'CTC', '', NULL, NULL, NULL, NULL,30,0); 156 INSERT INTO foltia_station VALUES (38, 'テレ玉', -10, 'TVS', '', NULL, NULL, NULL, NULL,32,0); 157 INSERT INTO foltia_station VALUES (418, '放送大学', -10, 'UAIR', '', NULL, NULL, NULL, '0013.ontvjapan.com',28,0); 158 INSERT INTO foltia_station VALUES (101, 'NHK-BS1', 0, 'BS7', '', '', '101', '', '3001.ontvjapan.com',101,1); 159 INSERT INTO foltia_station VALUES (102, 'NHK-BS2', 0, 'BS11', '', '', '102', '', '3002.ontvjapan.com',102,1); 160 INSERT INTO foltia_station VALUES (103, 'NHK-BShi', 0, '', '', '', '103', '', '3003.ontvjapan.com',103,1); 161 INSERT INTO foltia_station VALUES (409, 'BS日テレ', 0, '', '', '', '141', '', '3004.ontvjapan.com',141,1); 162 INSERT INTO foltia_station VALUES (384, 'BS朝日', 0, '', '', '', '151', '', '3005.ontvjapan.com',151,1); 163 INSERT INTO foltia_station VALUES (161, 'BS-i', 0, '', '', '', '161', '', '3006.ontvjapan.com',161,1); 164 INSERT INTO foltia_station VALUES (389, 'BS Japan', 0, '', '', '', '171', '','3007.ontvjapan.com',171,1); 165 INSERT INTO foltia_station VALUES (381, 'BSフジ', 0, '', '', '', '181', '', '3008.ontvjapan.com',181,1); 166 INSERT INTO foltia_station VALUES (191, 'WOWOW', 0, 'BS5', '', '', '191', '', '3009.ontvjapan.com',191,1); 167 INSERT INTO foltia_station VALUES (420, 'WOWOW2', 0, '', '', '', '192', '', '3010.ontvjapan.com',192,1); 168 INSERT INTO foltia_station VALUES (421, 'WOWOW3', 0, '', '', '', '193', '', '3011.ontvjapan.com',193,1); 169 INSERT INTO foltia_station VALUES (468, 'BS11デジタル', 0, '', '', '', '211', '', '',211,1); 170 INSERT INTO foltia_station VALUES (408, 'ファミリー劇場', 0, '', '', '', '751', '', '1015.ontvjapan.com',NULL,NULL); 171 INSERT INTO foltia_station VALUES (397, 'カートゥーンネットワーク', 0, '', '', '', '780', '', '1046.ontvjapan.com',NULL,NULL); 172 INSERT INTO foltia_station VALUES (263, 'アニマックス', 0, '', '', '', '782', '', '1047.ontvjapan.com',NULL,NULL); 173 INSERT INTO foltia_station VALUES (261, 'キッズステーション', 0, '', '', 'c', '781', '', '1045.ontvjapan.com',NULL,NULL); 174 INSERT INTO foltia_station VALUES (449, 'ディスカバリーチャンネル', 0, '', '', '', '796', '', '1062.ontvjapan.com',NULL,NULL); 175 INSERT INTO foltia_station VALUES (448, 'MONDO21', 0, '', '', '', '722', '', '1049.ontvjapan.com',NULL,NULL); 176 INSERT INTO foltia_station VALUES (401, 'チャンネルNECO', 0, '', '', '', '750', '', '1008.ontvjapan.com',NULL,NULL); 177 INSERT INTO foltia_station VALUES (455, '330ch WOWOW', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 178 INSERT INTO foltia_station VALUES (480, 'TBSラジオ(954)', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 179 INSERT INTO foltia_station VALUES (477, '北海道文化放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 180 INSERT INTO foltia_station VALUES (463, 'gooアニメ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 181 INSERT INTO foltia_station VALUES (461, '@nifty', -10, '', '', '', '', '', '',NULL,NULL); 182 INSERT INTO foltia_station VALUES (466, 'NHKラジオ第一', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 183 INSERT INTO foltia_station VALUES (474, '日テレプラス', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 184 INSERT INTO foltia_station VALUES (476, 'ニコニコアニメチャンネル', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 185 INSERT INTO foltia_station VALUES (451, 'RKB毎日放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 186 INSERT INTO foltia_station VALUES (452, '北海道放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 187 INSERT INTO foltia_station VALUES (454, 'テレビ和歌山', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 188 INSERT INTO foltia_station VALUES (456, '静岡放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 189 INSERT INTO foltia_station VALUES (457, 'i-revo', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 190 INSERT INTO foltia_station VALUES (459, '東北放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 191 INSERT INTO foltia_station VALUES (464, 'テレビ山口', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 192 INSERT INTO foltia_station VALUES (478, '札幌テレビ放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 193 INSERT INTO foltia_station VALUES (395, 'カミングスーンTV', -10, '', '', '', '', '', '',NULL,NULL); 194 INSERT INTO foltia_station VALUES (443, 'スーパーチャンネル', -10, '', '', '', '', '', '',NULL,NULL); 195 INSERT INTO foltia_station VALUES (385, 'TBSチャンネル', 0, '', '', '', '765', '', '',NULL,NULL); 196 INSERT INTO foltia_station VALUES (462, '瀬戸内海放送', -10, '', '', '', '', '', '',NULL,NULL); 197 INSERT INTO foltia_station VALUES (473, 'フジCSHD', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 198 INSERT INTO foltia_station VALUES (475, 'スカパー181ch', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 199 INSERT INTO foltia_station VALUES (479, '北海道テレビ放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 200 INSERT INTO foltia_station VALUES (450, 'NHK教育3', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 201 INSERT INTO foltia_station VALUES (453, 'バンダイチャンネルキッズ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 202 INSERT INTO foltia_station VALUES (458, '日テレプラス&サイエンス', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 203 INSERT INTO foltia_station VALUES (460, 'ビクトリーチャンネル', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 204 INSERT INTO foltia_station VALUES (472, 'ytv', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 205 INSERT INTO foltia_station VALUES (422, '東海テレビ', -10, '', '', '', '', '', '',NULL,NULL); 206 INSERT INTO foltia_station VALUES (423, 'ShowTime', -10, '', '', '', '', '', '',NULL,NULL); 207 INSERT INTO foltia_station VALUES (424, 'メ〜テレ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 208 INSERT INTO foltia_station VALUES (425, '三重テレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 209 INSERT INTO foltia_station VALUES (426, '中京テレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 210 INSERT INTO foltia_station VALUES (293, 'AT-X', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 211 INSERT INTO foltia_station VALUES (295, 'フジ721', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 212 INSERT INTO foltia_station VALUES (380, 'スカパー180ch', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 213 INSERT INTO foltia_station VALUES (427, '岐阜放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 214 INSERT INTO foltia_station VALUES (428, 'テレビ新広島', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 215 INSERT INTO foltia_station VALUES (383, 'サンテレビ', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 216 INSERT INTO foltia_station VALUES (429, 'CBCテレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 217 INSERT INTO foltia_station VALUES (386, 'テレ朝チャンネル', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 218 INSERT INTO foltia_station VALUES (390, 'サンテレビジョン', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 219 INSERT INTO foltia_station VALUES (392, 'スカパー183ch', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 220 INSERT INTO foltia_station VALUES (394, 'スカパー160ch', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 221 INSERT INTO foltia_station VALUES (396, 'KBS京都', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 222 INSERT INTO foltia_station VALUES (398, 'テレビ大阪', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 223 INSERT INTO foltia_station VALUES (399, 'ABCテレビ', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 224 INSERT INTO foltia_station VALUES (400, 'なし', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 225 INSERT INTO foltia_station VALUES (402, '関西テレビ', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 226 INSERT INTO foltia_station VALUES (406, 'MBS毎日放送', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 227 INSERT INTO foltia_station VALUES (407, 'animate.tv', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 228 INSERT INTO foltia_station VALUES (410, 'テレビ愛知', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 229 INSERT INTO foltia_station VALUES (411, 'インターネット', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 230 INSERT INTO foltia_station VALUES (413, 'よみうりテレビ', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 231 INSERT INTO foltia_station VALUES (414, 'LFX488', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 232 INSERT INTO foltia_station VALUES (415, 'LFX', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 233 INSERT INTO foltia_station VALUES (416, 'LFX BB', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 234 INSERT INTO foltia_station VALUES (419, 'GyaO', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 235 INSERT INTO foltia_station VALUES (417, 'とちぎテレビ', -10, 'TTV', '', NULL, NULL, NULL, NULL,NULL,NULL); 236 INSERT INTO foltia_station VALUES (412, '群馬テレビ', -10, 'GTV', '', NULL, NULL, NULL, NULL,NULL,NULL); 237 INSERT INTO foltia_station VALUES (430, '奈良テレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 238 INSERT INTO foltia_station VALUES (431, 'TVQ九州放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 239 INSERT INTO foltia_station VALUES (432, 'テレビ北海道', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 240 INSERT INTO foltia_station VALUES (433, 'BIGLOBEストリーム', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 241 INSERT INTO foltia_station VALUES (434, 'テレビせとうち', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 242 INSERT INTO foltia_station VALUES (435, '中国放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 243 INSERT INTO foltia_station VALUES (436, '文化放送(1134)', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 244 INSERT INTO foltia_station VALUES (437, '広島ホームテレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 245 INSERT INTO foltia_station VALUES (438, '広島テレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 246 INSERT INTO foltia_station VALUES (439, '岡山放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 247 INSERT INTO foltia_station VALUES (440, '山陽放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 248 INSERT INTO foltia_station VALUES (441, 'びわ湖放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 249 INSERT INTO foltia_station VALUES (442, 'NHK-FM', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 250 INSERT INTO foltia_station VALUES (444, 'バンダイチャンネル', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 251 INSERT INTO foltia_station VALUES (445, 'フレッツ・スクウェア(NTT東日本)', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 252 INSERT INTO foltia_station VALUES (446, 'フジ739', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 253 INSERT INTO foltia_station VALUES (447, 'Yahoo!動画', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 202 254 203 255 trunk/install/perl/addpidatq.pl
r1 r83 47 47 if ($titlecount[0] == 1 ){ 48 48 49 $DBQuery = "SELECT bitrate FROM foltia_tvrecord , foltia_subtitle WHERE foltia_tvrecord.tid = foltia_subtitle.tid AND pid='$pid' ";49 $DBQuery = "SELECT bitrate,digital FROM foltia_tvrecord , foltia_subtitle WHERE foltia_tvrecord.tid = foltia_subtitle.tid AND pid='$pid' "; 50 50 $sth = $dbh->prepare($DBQuery); 51 51 $sth->execute(); 52 52 @titlecount= $sth->fetchrow_array; 53 53 $bitrate = $titlecount[0];#ビットレート取得 54 if ($titlecount[1] >= 1){ 55 $usedigital = $titlecount[1];#デジタル優先フラグ 56 }else{ 57 $usedigital = 0; 58 } 54 59 55 60 #PID抽出 56 61 $now = &epoch2foldate(`date +%s`); 57 62 58 $DBQuery = "SELECT stationrecch FROM foltia_station,foltia_subtitle WHERE foltia_subtitle.pid = '$pid' AND foltia_subtitle.stationid = foltia_station.stationid "; 63 #stationIDからrecch 64 $DBQuery = "SELECT stationrecch,digitalch ,digitalstationband ,foltia_station.stationid FROM foltia_station,foltia_subtitle WHERE foltia_subtitle.pid = '$pid' AND foltia_subtitle.stationid = foltia_station.stationid "; 59 65 60 61 #stationIDからrecch62 66 $stationh = $dbh->prepare($DBQuery); 63 67 $stationh->execute(); 64 68 @stationl = $stationh->fetchrow_array; 65 69 $recch = $stationl[0]; 66 70 if ($recch eq ""){ 71 &writelog("addpidatq ERROR recch is NULL:$DBQuery."); 72 exit 1; 73 } 74 if ($stationl[1] => 1){ 75 $digitalch = $stationl[1]; 76 }else{ 77 $digitalch = 0; 78 } 79 if ($stationl[2] => 1){ 80 $digitalstationband = $stationl[2]; 81 }else{ 82 $digitalstationband = 0; 83 } 67 84 $DBQuery = "SELECT * FROM foltia_subtitle WHERE pid='$pid' "; 68 85 $sth = $dbh->prepare($DBQuery); … … 109 126 } 110 127 111 Schedule::At::add (TIME => "$atdateparam", COMMAND => "$toolpath/perl/recwrap.pl $recch $reclength $bitrate $tid $countno $pid" , TAG => "$pid"."_R");112 &writelog("addpidatq TIME $atdateparam COMMAND $toolpath/perl/recwrap.pl $recch $reclength $bitrate $tid $countno $pid");128 Schedule::At::add (TIME => "$atdateparam", COMMAND => "$toolpath/perl/recwrap.pl $recch $reclength $bitrate $tid $countno $pid $stationid $usedigital $digitalstationband $digitalch" , TAG => "$pid"."_R"); 129 &writelog("addpidatq TIME $atdateparam COMMAND $toolpath/perl/recwrap.pl $recch $reclength $bitrate $tid $countno $pid $stationid $usedigital $digitalstationband $digitalch"); 113 130 114 131 }#end #もし新開始時刻が15分移譲先なら再キュー 115 132 116 133 }else{ 117 &writelog("addpidatq drop:expire $pid $startafter $now$startdatetime");134 &writelog("addpidatq drop:expire $pid $startafter $now $startdatetime"); 118 135 }#放送が未来の日付なら 119 136 trunk/install/perl/captureimagemaker.pl
r1 r83 100 100 # $captureimgdir = "$tid"."-"."$countno"."-"."$date"."-"."$time"; 101 101 $captureimgdir = $filename; 102 $captureimgdir =~ s/\.m2p$ //;102 $captureimgdir =~ s/\.m2p$|\.m2t$//; 103 103 104 104 unless (-e "$capimgdirname/$captureimgdir"){ … … 118 118 119 119 # 10秒ごとに 120 system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf crop=690:460:12:10,scale=160:120 -ao null -sstep 9 -v 3 $recfolderpath/$filename"); 120 if ($filename =~ /m2t$/){ 121 &writelog("captureimagemaker DEBUG mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf scale=192:108 -ao null -sstep 9 -v 3 $recfolderpath/$filename"); 122 system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf scale=192:108 -ao null -sstep 9 -v 3 $recfolderpath/$filename"); 123 }else{ 124 &writelog("captureimagemaker DEBUG mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf crop=690:460:12:10,scale=160:120 -ao null -sstep 9 -v 3 $recfolderpath/$filename"); 125 system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf crop=690:460:12:10,scale=160:120 -ao null -sstep 9 -v 3 $recfolderpath/$filename"); 126 } 121 127 trunk/install/perl/deletemovie.pl
r1 r83 32 32 33 33 #ファイル名正当性チェック 34 if ($fname =~ /.m2p \z/){34 if ($fname =~ /.m2p$|.m2t$/){ 35 35 36 36 }else{ trunk/install/perl/foltia_conf1.pl.template
r70 r83 15 15 $uhfbandtype = 1; # CATVなら1 UHF帯なら0 : 0=ntsc-bcast-jp 1=ntsc-cable-jp 16 16 $rapidfiledelete = 1;#1なら削除ファイルは「mita」ディレクトリに移動。0なら即時削除 17 $tunerinputnum = 6; #IO-DATA DV-MVP/RX,RX2,RX2W18 $svideoinputnum = 7;#IO-DATA DV-MVP/RX,RX2,RX2W19 $comvideoinputnum = 8;#IO-DATA DV-MVP/RX,RX2,RX2W17 $tunerinputnum = 0; #IO-DATA DV-MVP/RX,RX2,RX2W 18 $svideoinputnum = 1;#IO-DATA DV-MVP/RX,RX2,RX2W 19 $comvideoinputnum= 2;#IO-DATA DV-MVP/RX,RX2,RX2W 20 20 $haveirdaunit = 1;#Tira-2<http://www.home-electro.com/tira2.php>をつないでいるときに1,なければ0 21 21 $mp4filenamestyle = 1 ;#0:PSP ファームウェアver.2.80より前と互換性を持つファイル名 1;よりわかりやすいファイル名 22 22 $trconqty = 2; 23 #0:PSP/iPod XviD MPEG4(旧式):faacとMPEG4IPを使って変換 24 #1:iPod Xvid MPEG4 標準画質 15fps 300kbps 25 #2:iPod H.264 中画質 24fps 300kbps 26 #3:iPod H.264 高画質 30fps 300kbps 23 #0:PSP/iPod XviD MPEG4(旧式):faacとMPEG4IPを使って変換(古い設定) 24 #1:iPod Xvid MPEG4 標準画質 15fps 300kbps / デジタル 360x202 24.00fps 300kbps 25 #2:iPod H.264 中画質 24fps 300kbps / デジタル 480x272 29.97fps 400kbps 26 #3:iPod H.264 高画質 30fps 300kbps / デジタル 640x352 29.97fps 600kbps 27 27 $phptoolpath = $toolpath ;#php版の初期設定の位置。デフォルトではperlと同じ位置 28 28 trunk/install/perl/foltialib.pl
r70 r83 22 22 $DBPass=""; 23 23 24 25 26 $FILESTATUSRESERVINGLONG = 10; 27 $FILESTATUSRESERVINGSHORT = 20; 28 $FILESTATUSRECORDING = 30; 29 $FILESTATUSRECTSSPLITTING = 40; 30 $FILESTATUSRECEND = 50; 31 $FILESTATUSWAITINGCAPTURE = 55; 32 $FILESTATUSCAPTURE = 60; 33 $FILESTATUSCAPEND = 70; 34 $FILESTATUSTHMCREATE = 72; 35 $FILESTATUSWAITINGTRANSCODE = 80; 36 $FILESTATUSTRANSCODETSSPLITTING = 90; 37 $FILESTATUSTRANSCODEFFMPEG = 100; 38 $FILESTATUSTRANSCODEWAVE = 110; 39 $FILESTATUSTRANSCODEAAC = 120; 40 $FILESTATUSTRANSCODEMP4BOX = 130; 41 $FILESTATUSTRANSCODEATOM = 140; 42 $FILESTATUSTRANSCODECOMPLETE = 150; 43 $FILESTATUSALLCOMPLETE = 200; 44 24 45 25 46 #------------------------------ … … 258 279 259 280 281 sub getpidbympegfilename { 282 #引き数:m2pfilename 283 #戻り値:PID 284 my $m2pfilename = $_[0] ; 285 if ($m2pfilename eq ""){ 286 return 0 ; 287 } 288 289 my $DBQuery = "SELECT pid FROM foltia_subtitle WHERE m2pfilename = '$m2pfilename' LIMIT 1 "; 290 my $sth; 291 $sth = $dbh->prepare($DBQuery); 292 $sth->execute(); 293 #print "$DBQuery\n"; 294 my @pidinfo = $sth->fetchrow_array; 295 my $pid = $pidinfo[0]; 296 297 if ($pid eq ""){ 298 return 0 ; 299 }else{ 300 return $pid; 301 } 302 }#end sub getpidbympegfilename 303 304 sub changefilestatus { 305 #引き数:PID,updatestatus 306 #戻り値:エラーコード 307 my $pid = $_[0] ; 308 my $updatestatus = $_[1]; 309 if (($pid eq "" ) || ($updatestatus eq "")){ 310 return 0 ; 311 } 312 313 if ($updatestatus > 0 ){ 314 my $DBQuery = "UPDATE foltia_subtitle SET filestatus = $updatestatus , lastupdate = now() WHERE pid = $pid "; 315 my $sth; 316 $sth = $dbh->prepare($DBQuery); 317 $sth->execute(); 318 return 1; 319 }else{ 320 &writelog("foltialib changefilestatus ERR Sttus invalid:$updatestatus"); 321 return 0 ; 322 } 323 }# end sub changefilestatus 324 325 326 sub getfilestatus { 327 #引き数:PID 328 #戻り値:ステータス 329 330 #10:予約中(5分以上先) 331 #20:予約中(5分以内) 332 #30:録画中 333 #40:TSSplit中 334 #50:MPEG2録画終了 335 #55 静止画キャプチャ待 336 #60:静止画キャプ中 337 #70:静止画キャプ終了 338 #72:サムネイル作成済み(.THM) 339 #80:トラコン待 340 #90:トラコン中:TSsplit 341 #100:トラコン中:H264 342 #110:トラコン中:WAVE 343 #120:トラコン中:AAC 344 #130:トラコン中:MP4Box 345 #140:トラコン中:ATOM 346 #150:トラコン完了 347 #200:全完了 348 my $pid = $_[0] ; 349 if ($pid eq "" ){ 350 return 0 ; 351 } 352 353 my $DBQuery = "SELECT filestatus FROM foltia_subtitle WHERE pid = $pid "; 354 my $sth; 355 $sth = $dbh->prepare($DBQuery); 356 $sth->execute(); 357 358 my @statusinfo = $sth->fetchrow_array; 359 my $status = $statusinfo[0]; 360 361 if ($status eq ""){ 362 return 0 ; 363 }else{ 364 return $status; 365 } 366 367 368 }# end sub getfilestatus 369 370 371 sub makemp4dir{ 372 #TIDが100以上の3桁の場合はそのまま 373 my $pspfilnamehd = $_[0]; 374 my $tid = $_[0]; 375 my $pspdirname = "$tid.localized/"; 376 $pspdirname = $recfolderpath."/".$pspdirname; 377 378 #なければ作る 379 unless (-e $pspdirname ){ 380 system("$toolpath/perl/mklocalizeddir.pl $tid"); 381 #&writelog("recwrap mkdir $pspdirname"); 382 } 383 $pspdirname = "$tid.localized/mp4/"; 384 $pspdirname = $recfolderpath."/".$pspdirname; 385 #なければ作る 386 unless (-e $pspdirname ){ 387 mkdir $pspdirname ,0777; 388 #&writelog("recwrap mkdir $pspdirname"); 389 } 390 return ("$pspdirname"); 391 }#endsub makemp4dir 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 260 441 1; 261 442 trunk/install/perl/ipodtranscode.pl
r70 r83 1 1 #!/usr/bin/perl 2 #usage ipodtranscode.pl /path/to/mpeg2.m2p mp4filenamestring /path/to/mpeg2/tid.localized/mp4/ PID [aspect]2 #usage ipodtranscode.pl 3 3 # 4 4 # Anime recording system foltia 5 5 # http://www.dcc-jpl.com/soft/foltia/ 6 6 # 7 #8 7 # iPod MPEG4/H.264トラコン 9 8 # ffmpegを呼び出して変換 10 # ffmpegはiPodパッチあて版を想定している11 # ffmpegの作り方は12 # http://www.dcc-jpl.com/diary/ddata2006/02A.html#20060215-0013 9 # 14 10 # DCC-JPL Japan/foltia project … … 18 14 use DBD::Pg; 19 15 use Jcode; 20 21 16 22 17 $path = $0; … … 25 20 push( @INC, "$path"); 26 21 } 27 28 22 require "foltialib.pl"; 29 #引き数がアルか? 30 $recch = $ARGV[0] ; 31 if ($recch eq "" ){ 32 #引き数なしで実行されたら、終了 33 print "usage ipodtranscode.pl /path/to/mpeg2.m2p mp4filenamestring /path/to/mpeg2/tid.localized/mp4/ PID [aspect]\n"; 34 exit; 35 } 36 37 $inputmpeg2 = $ARGV[0]; 38 $mp4filenamestring = $ARGV[1]; 39 $mp4outdir = $ARGV[2]; 40 $pid = $ARGV[3]; 41 $aspect = $ARGV[4]; 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 } 42 35 43 36 #DB初期化 … … 46 39 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 47 40 48 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 # 実際のトラコン 49 86 # タイトル取得 50 87 if ($pid ne ""){ … … 82 119 83 120 } 84 # アスペクト比 85 if ($aspect == 16){ 86 $cropopt = " -croptop 70 -cropbottom 60 -cropleft 8 -cropright 14 -aspect 1.7777 "; 87 }else{ 88 $cropopt = " -croptop 8 -cropbottom 8 -cropleft 8 -cropright 14 "; 89 } 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 } 90 306 # クオリティごとに 91 if (($trconqty eq "")||($trconqty == 1)){#sample:src 106.6sec encode 82sec x0.77 382kbps @Celeron2.6GHz 92 93 $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"; 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"; 94 309 $mp4file = "${mp4outdir}M4V${mp4filenamestring}.MP4"; 95 96 }elsif($trconqty == 2){ #sample:src 106.6sec encode 117sec x1.1 597kbps @Celeron2.6GHz 97 98 $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"; 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"; 99 316 $mp4file = "${mp4outdir}MAQ${mp4filenamestring}.MP4"; 100 101 }elsif($trconqty == 3){ #sample:src 106.6sec encode 364sec x3.4 528kbps @Celeron2.6GHz 102 103 $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"; 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"; 104 323 $mp4file = "${mp4outdir}MAQ${mp4filenamestring}.MP4"; 105 106 }elsif($trconqty == 4){ #sample:src 106.6sec encode 239sec x2.24 1036kbps @Celeron2.6GHz 107 108 $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"; 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"; 109 330 $mp4file = "${mp4outdir}MAQ${mp4filenamestring}.MP4"; 110 111 }elsif($trconqty == 5){ #sample:src 106.6sec encode 1012sec x9.49 727kbps @Celeron2.6GHz 112 113 $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"; 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"; 114 337 $mp4file = "${mp4outdir}MAQ${mp4filenamestring}.MP4"; 115 } 116 117 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 } 118 343 119 344 $encodeoptionlog = $encodeoption; … … 122 347 &writelog("ipodtranscode START QTY=$trconqty $encodeoptionlog"); 123 348 #print "ffmpeg $encodeoptionlog \n"; 124 system ("/usr/local/bin/ffmpeg $encodeoption "); 349 &changefilestatus($pid,$FILESTATUSTRANSCODEFFMPEG); 350 system ("ffmpeg $encodeoption "); 125 351 &writelog("ipodtranscode FFEND $inputmpeg2"); 126 127 &writelog("ipodtranscode mp4psp -p $mp4file $movietitleeuc"); 128 system("/usr/local/bin/mp4psp -p $mp4file '$movietitleeuc' "); 129 &writelog("ipodtranscode mp4psp COMPLETE $mp4file "); 130 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 } trunk/install/perl/recwrap.pl
r70 r83 1 1 #!/usr/bin/perl 2 #usage recwrap.pl ch length(sec) [bitrate(5)] [TID] [NO] [PID]2 #usage recwrap.pl ch length(sec) [bitrate(5)] [TID] [NO] [PID] [stationid] [digitalflag] [digitalband] [digitalch] 3 3 # 4 4 # Anime recording system foltia … … 39 39 $tid = $ARGV[3] ; 40 40 $countno = $ARGV[4] ; 41 $pid = $ARGV[5] ; 41 $pid = $ARGV[5] ; 42 $stationid = $ARGV[6] ; 43 $usedigital = $ARGV[7] ; 44 $digitalstationband = $ARGV[8] ; 45 $digitalch= $ARGV[9] ; 46 47 #DB初期化 48 my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 49 $DBDriv,$DBName,$DBHost,$DBPort); 50 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 51 52 53 if ($usedigital == 1){ 54 $extension = ".m2t";#TSの拡張子 55 }else{ 56 $extension = ".m2p";#MPEG2の拡張子 57 } 42 58 43 59 $outputfile = `date +%Y%m%d-%H%M --date "1 min "`; 44 60 chomp($outputfile); 61 45 62 if ($tid == 0){ 46 $outputfilename = "0--".$outputfile."-".$recch. ".m2p";63 $outputfilename = "0--".$outputfile."-".$recch.$extension; 47 64 $mp4newstylefilename = "-0--".$outputfile."-".$recch; 48 65 }else{ 49 66 if ($countno == 0){ 50 $outputfilename = $tid ."--".$outputfile. ".m2p";67 $outputfilename = $tid ."--".$outputfile.$extension; 51 68 $mp4newstylefilename = "-" . $tid ."--".$outputfile; 52 69 }else{ 53 $outputfilename = $tid ."-".$countno."-".$outputfile. ".m2p";70 $outputfilename = $tid ."-".$countno."-".$outputfile.$extension; 54 71 $mp4newstylefilename = "-" . $tid ."-".$countno."-".$outputfile; 55 72 } 56 73 } 74 75 if ($usedigital == 1){ 76 #デジタルなら 77 &writelog("recwrap RECSTART DIGITAL $digitalstationband $digitalch $reclength $stationid 0 $outputfilename $tid $countno friio"); 78 #録画 79 $starttime = (`date +%s`); 80 $oserr = system("$toolpath/perl/digitaltvrecording.pl $digitalstationband $digitalch $reclength $stationid 0 $outputfilename $tid $countno friio"); 81 $oserr = $oserr / 256; 82 83 if ($oserr == 1){ 84 &writelog("recwrap ABORT recfile exist. [$outputfilename] $digitalstationband $digitalch $reclength $stationid 0 $outputfilename $tid $countno"); 85 exit; 86 }elsif ($oserr == 2){ 87 &writelog("recwrap ERR 2:friio busy;retry."); 88 &continuousrecordingcheck;#もうすぐ終わる番組をkill 89 sleep(2); 90 $oserr = system("$toolpath/perl/digitaltvrecording.pl $digitalstationband $digitalch $reclength $stationid N $outputfilename $tid $countno friio"); 91 $oserr = $oserr / 256; 92 if ($oserr == 2){ 93 &writelog("recwrap ERR 2:friio busy;Giving up digital recording."); 94 } 95 }elsif ($oserr == 3){ 96 &writelog("recwrap ABORT:ERR 3"); 97 exit ; 98 } 99 }else{ 57 100 #リモコン操作 58 101 # $haveirdaunit = 1;リモコンつないでるかどうか確認 … … 71 114 exit; 72 115 }#end if 73 74 &writelog("recwrap RECSTART $recch $reclength 0 $outputfilename $bitrate $tid $countno $pid"); 116 # アナログ録画 117 &writelog("recwrap RECSTART $recch $reclength 0 $outputfilename $bitrate $tid $countno $pid $usedigital $digitalstationband $digitalch"); 118 75 119 #録画 76 120 #system("$toolpath/perl/tvrecording.pl $recch $reclength 0 $outputfile $bitrate $tid $countno"); … … 83 127 exit; 84 128 } 129 130 }#endif #デジタル優先フラグ 131 85 132 #デバイスビジーで即死してないか検出 86 133 $now = (`date +%s`); 87 134 if ($now < $starttime + 100){ #録画プロセス起動してから100秒以内に戻ってきてたら 135 $retrycounter == 0; 88 136 while($now < $starttime + 100){ 137 if($retrycounter >= 5){ 138 &writelog("recwrap WARNING Giving up recording."); 139 last; 140 } 89 141 &writelog("recwrap retry recording $now $starttime"); 142 #アナログ録画 90 143 $starttime = (`date +%s`); 144 if($outputfilename =~ /.m2t$/){ 145 $outputfilename =~ s/.m2t$/.m2p/; 146 } 91 147 $oserr = system("$toolpath/perl/tvrecording.pl $recch $reclength N $outputfilename $bitrate $tid $countno"); 92 148 $now = (`date +%s`); … … 96 152 exit; 97 153 }# if 154 $retrycounter++; 98 155 }# while 99 156 } # if 100 157 101 102 158 &writelog("recwrap RECEND [$outputfilename] $recch $reclength 0 0 $bitrate $tid $countno $pid"); 103 159 104 #DB初期化105 my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d",106 $DBDriv,$DBName,$DBHost,$DBPort);107 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;;108 160 109 161 # m2pファイル名をPIDレコードに書き込み 110 $DBQuery = "UPDATE foltia_subtitle SET 111 m2pfilename = '$outputfilename' 112 WHERE pid = '$pid' "; 162 $DBQuery = "UPDATE foltia_subtitle SET m2pfilename = '$outputfilename' WHERE pid = '$pid' "; 113 163 $sth = $dbh->prepare($DBQuery); 114 164 $sth->execute(); 115 &writelog("recwrap UPDATEDB $DBQuery"); 165 &writelog("recwrap DEBUG UPDATEDB $DBQuery"); 166 &changefilestatus($pid,$FILESTATUSRECEND); 116 167 117 168 # m2pファイル名をPIDレコードに書き込み 118 $DBQuery = "insert into 169 $DBQuery = "insert into foltia_m2pfiles values ('$outputfilename')"; 119 170 $sth = $dbh->prepare($DBQuery); 120 171 $sth->execute(); 121 &writelog("recwrap UPDATEDB$DBQuery");172 &writelog("recwrap DEBUG UPDATEDB $DBQuery"); 122 173 123 174 # Starlight breaker向けキャプチャ画像作成 124 175 if (-e "$toolpath/perl/captureimagemaker.pl"){ 125 176 &writelog("recwrap Call captureimagemaker $outputfilename"); 177 &changefilestatus($pid,$FILESTATUSCAPTURE); 126 178 system ("$toolpath/perl/captureimagemaker.pl $outputfilename"); 127 } 128 129 130 131 # PSP ------------------------------------------------------ 132 #PSPトラコン必要かどうか 133 $DBQuery = "SELECT psp,aspect,title FROM foltia_program WHERE tid = '$tid' "; 179 &changefilestatus($pid,$FILESTATUSCAPEND); 180 } 181 182 183 184 # MPEG4 ------------------------------------------------------ 185 #MPEG4トラコン必要かどうか 186 $DBQuery = "SELECT psp,aspect,title FROM foltia_program WHERE tid = '$tid' "; 134 187 $sth = $dbh->prepare($DBQuery); 135 188 $sth->execute(); 136 189 @psptrcn= $sth->fetchrow_array; 137 if ($psptrcn[0] == 1 ){#トラコン番組 138 139 140 #PSPムービーディレクトリがアルかどうか 190 if ($psptrcn[0] == 1 ){#トラコン番組 191 &writelog("recwrap Launch ipodtranscode.pl"); 192 exec ("$toolpath/perl/ipodtranscode.pl"); 193 exit; 194 # 195 # ここから下は旧エンコード#2008/12/23 196 # 新エンコードはDBを見て未完了MPEG2を順次トラコン処理、 197 # 分散エンコードもきっとラクチンに対応可能 198 # 新エンコードではXviD/M4VスタイルとPSPファイル名対応を廃止 199 200 &changefilestatus($pid,80); 201 #MPEG4ムービーディレクトリがあるかどうか 141 202 142 203 #TIDが100以上の3桁の場合はそのまま 143 204 my $pspfilnamehd = ""; 144 205 145 $pspfilnamehd = $tid; 206 $pspfilnamehd = $tid; 207 &makemp4dir($tid); 146 208 $pspdirname = "$tid.localized/"; 147 209 $pspdirname = $recfolderpath."/".$pspdirname; 148 210 149 211 #なければ作る 150 unless (-e $pspdirname ){151 system("$toolpath/perl/mklocalizeddir.pl $tid");152 #&writelog("recwrap mkdir $pspdirname");153 }212 #unless (-e $pspdirname ){ 213 # system("$toolpath/perl/mklocalizeddir.pl $tid"); 214 # #&writelog("recwrap mkdir $pspdirname"); 215 #} 154 216 $pspdirname = "$tid.localized/mp4/"; 155 217 $pspdirname = $recfolderpath."/".$pspdirname; 156 218 #なければ作る 157 unless (-e $pspdirname ){158 mkdir $pspdirname ,0777;159 #&writelog("recwrap mkdir $pspdirname");160 }219 #unless (-e $pspdirname ){ 220 # mkdir $pspdirname ,0777; 221 # #&writelog("recwrap mkdir $pspdirname"); 222 #} 161 223 162 224 #ファイル名決定 … … 350 412 351 413 # MP4ファイル名をPIDレコードに書き込み 352 $DBQuery = "UPDATE foltia_subtitle SET 353 PSPfilename = '$mp4filename' 354 WHERE pid = '$pid' "; 414 $DBQuery = "UPDATE foltia_subtitle SET PSPfilename = '$mp4filename' WHERE pid = '$pid' "; 355 415 $sth = $dbh->prepare($DBQuery); 356 416 $sth->execute(); … … 358 418 359 419 # MP4ファイル名をfoltia_mp4files挿入 360 $DBQuery = "insert intofoltia_mp4files values ('$tid','$mp4filename') ";420 $DBQuery = "insert into foltia_mp4files values ('$tid','$mp4filename') "; 361 421 $sth = $dbh->prepare($DBQuery); 362 422 $sth->execute(); 363 423 &writelog("recwrap UPDATEmp4DB $DBQuery"); 364 424 425 &changefilestatus($pid,200); 365 426 }#PSPトラコンあり 366 427 367 368 369 428 sub continuousrecordingcheck(){ 429 my $now = `date +%s --date "2 min "`; 430 &writelog("recwrap DEBUG continuousrecordingcheck() now $now"); 431 my @processes =`ps ax | grep recfriio`; 432 433 my $psline = ""; 434 my @processline = ""; 435 my $pid = ""; 436 my @pid; 437 my $sth; 438 foreach (@processes){ 439 if (/friiodetect/) { 440 if (/^.[0-9]*\s/){ 441 push(@pid, $&); 442 }#if 443 }#if 444 }#foreach 445 446 if (@pid > 0){ 447 my @filenameparts; 448 my $tid = ""; 449 my $startdate = ""; 450 my $starttime = ""; 451 my $startdatetime = ""; 452 my @recfile; 453 my $endtime = ""; 454 my $endtimeepoch = ""; 455 foreach $pid (@pid){ 456 #print "DEBUG PID $pid\n"; 457 &writelog("recwrap DEBUG continuousrecordingcheck() PID $pid"); 458 459 my @lsofoutput = `/usr/sbin/lsof -p $pid`; 460 my $filename = ""; 461 #print "recfolferpath $recfolderpath\n"; 462 foreach (@lsofoutput){ 463 if (/m2t/){ 464 @processline = split(/\s+/,$_); 465 $filename = $processline[8]; 466 #print "DEBUG $_ \n"; 467 #print "DEBUG $processline[0]/$processline[1]/$processline[2]/$processline[3]/$processline[4]/$processline[5]/$processline[6]/$processline[7]/$processline[8] \n"; 468 $filename =~ s/$recfolderpath\///; 469 #print "DEBUG FILENAME $filename\n"; 470 &writelog("recwrap DEBUG continuousrecordingcheck() FILENAME $filename"); 471 # 1520-9-20081201-0230.m2t 472 @filenameparts = split(/-/,$filename); 473 $tid = $filenameparts[0]; 474 $startdate = $filenameparts[2]; 475 $starttime = $filenameparts[3]; 476 $startdatetime = $filenameparts[2].$filenameparts[3]; 477 #DBから録画中番組のデータ探す 478 $DBQuery = " 479 SELECT foltia_subtitle.tid,foltia_subtitle.countno,foltia_subtitle.subtitle,foltia_subtitle.startdatetime ,foltia_subtitle.enddatetime ,foltia_subtitle.lengthmin ,foltia_tvrecord.bitrate , foltia_subtitle.startoffset , foltia_subtitle.pid ,foltia_tvrecord.digital 480 FROM foltia_subtitle ,foltia_tvrecord 481 WHERE 482 foltia_tvrecord.tid = foltia_subtitle.tid AND 483 foltia_tvrecord.tid = $tid AND 484 foltia_subtitle.startdatetime = $startdatetime AND 485 foltia_tvrecord.digital = 1"; 486 &writelog("recwrap DEBUG continuousrecordingcheck() $DBQuery"); 487 $sth = $dbh->prepare($DBQuery); 488 &writelog("recwrap DEBUG continuousrecordingcheck() prepare"); 489 $sth->execute(); 490 &writelog("recwrap DEBUG continuousrecordingcheck() execute"); 491 @recfile = $sth->fetchrow_array; 492 &writelog("recwrap DEBUG continuousrecordingcheck() @recfile $recfile[0] $recfile[1] $recfile[2] $recfile[3] $recfile[4] $recfile[5] $recfile[6] $recfile[7] $recfile[8] $recfile[9] "); 493 #終了時刻 494 $endtime = $recfile[4]; 495 $endtimeepoch = &foldate2epoch($endtime); 496 &writelog("recwrap DEBUG continuousrecordingcheck() $recfile[0] $recfile[1] $recfile[2] $recfile[3] $recfile[4] $recfile[5] endtimeepoch $endtimeepoch"); 497 if ($endtimeepoch < $now){#まもなく終わる番組なら 498 #kill 499 system("kill $pid"); 500 &writelog("recwrap recording process killed $pid/$endtimeepoch/$now"); 501 } 502 }#endif m2t 503 }#foreach lsofoutput 504 }#foreach 505 }else{ 506 #print "DEBUG fecfriio NO PID\n"; 507 &writelog("recwrap No recording process killed."); 508 } 509 }#endsub 510 511 512 trunk/install/perl/tvrecording.pl
r79 r83 5 5 # 6 6 #tvrecording.pl 7 # record-v4l2.pl に準備処理を加えた録画モジュール。7 # record-v4l2.plを呼びだす録画モジュール。 8 8 # 9 9 #usage tvrecording.pl ch length(sec) [clip No(000-)] [filename] [bitrate(5)] [TID] [NO] [/dev/video0] … … 44 44 #$startupsleeptime = 52; #process wait(MAX60sec) 45 45 $startupsleeptime = 37; #process wait(MAX60sec) 46 #$startupsleeptime = 1; #process wait(MAX60sec) 46 47 47 48 48 #------------------------------- … … 64 64 $recfolderpath = '/home/foltia/php/tv'; 65 65 }#end sub getRecPath 66 66 # 67 # -- ここからメイン ---------------------------- 67 68 #準備 68 69 &prepare; … … 74 75 $reclengthsec = $reclengthsec + $extendrecendsec ; 75 76 77 &callrecordv4l; 78 76 79 &writelog("tvrecording:$recch:$reclengthsec:$outputfile:$recdevice:$capturedeviceinputnum:$ivtvrecch:$stdbitrate:$peakbitrate"); 77 80 78 #------------------------------ 79 80 81 # -- これ以下サブルーチン ---------------------------- 81 82 sub chkextinput{ 82 83 … … 87 88 $capturedeviceinputnum = 7 ; 88 89 } 89 $capturedeviceinputName = "S-Video 0";90 $capturedeviceinputName = "S-Video 1"; 90 91 $ivtvrecch = ''; 91 92 }elsif($recch == -1){ … … 95 96 $capturedeviceinputnum = 8; 96 97 } 97 $capturedeviceinputName = "Composite 0";98 $capturedeviceinputName = "Composite 1"; 98 99 $ivtvrecch = ''; 99 100 }else{ … … 103 104 $capturedeviceinputnum = 6 ; 104 105 } 105 $capturedeviceinputName = "Tuner 0";106 $capturedeviceinputName = "Tuner 1"; 106 107 $ivtvrecch = $recch; 107 108 } … … 304 305 $outputfile = $ARGV[3]; 305 306 $outputfile = &filenameinjectioncheck($outputfile); 307 $outputfilewithoutpath = $outputfile ; 306 308 $outputfile = $outputpath.$outputfile ; 307 309 # $outputfile .= "$ARGV[3]"; 308 310 # $outputfile .= `date +%Y%m%d-%H%M --date "1 min "`; 309 &writelog("tvrecording: DEBUG ARGV[3] ne null \$outputfile $outputfile "); 310 311 &writelog("tvrecording: DEBUG ARGV[2] ne null \$outputfile $outputfile "); 311 312 }else{ 312 $outputfile .= `date +%Y%m%d-%H%M --date "1 min "`;313 chomp($outputfile);314 $outputfile .= ".m2p";315 &writelog("tvrecording: DEBUG ARGV[3] is null \$outputfile $outputfile ");316 313 $outputfile .= `date +%Y%m%d-%H%M --date "1 min "`; 314 chomp($outputfile); 315 $outputfile .= ".m2p"; 316 $outputfilewithoutpath = $outputfile ; 317 &writelog("tvrecording: DEBUG ARGV[2] is null \$outputfile $outputfile "); 317 318 } 318 319 … … 341 342 }#end setbitrate 342 343 343 #------------------------------------------------------------------------------------------------- 344 # record-v4l2.pl created by James A. Pattie <james@pcxperience.com> 04/10/2003 345 # Copyright 2003 346 # Purpose: to record from the specified channel for the specified amount 347 # of time to the video OutputDirectory under the channel-start time name as video.mpg. 348 349 # 350 # You can always get the latest version of this script at 351 # http://www.pcxperience.org/ 352 # 353 354 #2003.11.18 patched by DCC-JPL 355 356 # 20030425 - 1.4 - Added devfs support based upon patch submitted by 357 # Jonathan Kolb <jkolb-ivtv@greyshift.net> 358 # 20030426 - 1.5 - Imported the ptune.pl functionality 359 # 20030426 - 1.6 - moved -F -> -L, -F now lets you specify the frequency to tune to. 360 # 20030427 - 1.7 - renamed to record_ivtv.pl per Kevin's request. Added -R option. 361 # 20030430 - 1.8 - fixing some comparisons that needed to be strings, etc. 362 # 20030504 - 1.9 - Migrating to Video::ivtv for video resolution support. 363 # 20030505 - 1.10- Replaced open w/ sysopen but it doesn't make a difference. 364 # Starting to replace the Standard code w/ Video::ivtv methods. 365 # Added the version numbers that I require to the use statements. 366 # 20030507 - 1.11- Migrated to using get/setFrequency from Video::ivtv 0.03. 367 # 20030510 - 1.12- Migrated to using get/setInput from Video::ivtv 0.04. Moved to using 368 # the exported method names rather than Video::ivtv::method(). 369 # Converted to using enumerateStandard(). 370 # Fixed the condition where switching Video Standards will most likely 371 # not get the correct channel and so would switch back with channel = 0 372 # which is invalid. In this case I store the previous frequency, do the 373 # channel change but signal to restore the previous frequency on cleanup. 374 # Converted to using enumerateInput(). 375 # 20030512 - 1.13- Added initial support for setting the bitrate/bitrate_peak values. 376 # 20030513 - 1.14- Tweaked the bitrate values to be closer to real DVD bitrates. 377 # Added support for the .ivtvrc config file and User Profiles. 378 # 20030516 - 1.15- Updated to the OO interface that Video::ivtv 0.06 now requires. 379 # Cleaned up a lot of the global variables into a settings hash. 380 # Made the -S command add any config items you specified on the command line 381 # that were not in the Profile being updated. This way you can add new items. 382 # Made the config file work from a mapping hash so that we can easily add/remove 383 # config items in the future. 384 # 20030518 - 1.16- Fixed a Frequency bug that happened when changing Video Standards and the 385 # Frequency came from a user specified Profile. 386 # 20030519 - 1.17- Adding the rest of the Codec related options to the config file / defaults. 387 # Switched to using Getopt::Long. You can specify all config file options at 388 # least by a --long version and still by the original -X command option. 389 # Cleaned up the option parsing code to take advantage of the mappings hash. 390 # 20030520 - 1.18- Fixing the handling of the Profile command line option. 391 # 20030524 - 1.19- Cleaned up the output for -L/--list-freqtable. Changed --list -> --list-freqtable. 392 # Added support to detect the v4l2 driver in use and disable the ivtv "enhancements" 393 # if driver != "ivtv". 394 # Renamed to record-v4l2.pl to reflect the ability of this program to record from any 395 # v4l2 device but with special support for the ivtv driver. 396 # 20030524 - 1.20- Improving the Ctrl-C handling (cleanup before dying). It may take a second or two 397 # before the program exits, but it should exit after resetting anything it changed, unless 398 # you had specified not to reset the card. 399 # Allow layering of profiles by calling -P/--profile multiple times. Each profile will 400 # be layered over the last. You will not be able to create/update a profile if you 401 # specify more than one though. 402 # Fixed a bug that would cause a parameter from the profile to be set n times, where n was 403 # the number of characters in the mapping string that consisted of the single letter | and 404 # the long command option name. Ex: Channel has 'c|channel' so the Channel value was being 405 # set 9 times instead of just the first time if it was in the profile. 406 # 20030525 - 1.21- Fixed devfsd detection code as it was overriding what came from the config file. 407 # Adding --no-record option so that we can start to implement the replacement functionality for 408 # ptune.pl (ie. Set all values and then exit, do not reset the card and do not capture) 409 # 20030607 - 1.22- Adding --directory-format and --date-format options so that the user can specify the 410 # naming convention to use when specifying the directory the output file should be put in. 411 # Tweaked some of the defaults. 412 # Create the config file if it doesn't exist, regardless of the --save flag being specified. 413 # Added method error() to output an error condition that doesn't warrant the whole usage and 414 # converted all relevant usage() calls to error() calls. 415 # Added option --debug to dynamically on the fly enable debug output. 416 # 20030609 - 1.23- Added option --list-channels to display the currently selected frequency tables contents. 417 # Changed the default output directory to '.'. 418 # Moved $debug -> $settings{Debug} so it can be stored in the config file. This allows you to 419 # turn debugging on for only certain profiles, etc. 420 # Restructured some of the validity tests to only happen as long as we are recording since they 421 # do not need to be validated when we are not recording. Mainly to do with the output stuff. 422 # 20030610 - 1.24- Moved the tunerNum variable into the config file: TunerNum 423 # Added --tuner-num option to dynamically set it. 424 # 20030614 - 1.25- I now require Video::ivtv 0.09 to make sure everyone is using the version that fixes the known 425 # reported segfault issues. 426 # Added freqtable "custom" support so that people using the new feature in ptune-ui.pl and have 427 # set their default frequency table to be "custom" will just work when they specify channel X, etc. 428 # I'm now sorting the command line input since otherwise I can't guarantee the order options get 429 # processed in, but even that is wrong. I need to use Tie::IxHash, but that isn't standard. 430 # 20030626 - 1.26- Updated to cover the audio -> audio_bitmask changes that Video::ivtv 0.11 implemented to cover 431 # the ivtv_ioctl_codec structure changes. 432 # Implemented config file versioning so that I know when the Audio entry needs to be updated in case it 433 # comes back in a future version of the ivtv_ioctl_codec structure. 434 # 20030628 - 1.27- Adding --list-inputs and --list-standards to display the available inputs and video standards. 435 # 20030713 - 1.28- Added code to make sure the codec properties are proper when switching standard to PAL/SECAM. 436 # Added config options SetMSPMatrix, MSPInput, MSPOutput, MSPSleep to allow the user to specify if they 437 # want the msp matrix updated any time the Video Standard is changed and to specify what they want programmed. 438 # Bumping the config file version to 2 to account for the new options. 439 # 20030715 - 1.29- Adding the missing msp matrix reset code in the reset section. 440 # Adding codec checks to make sure that they are right for NTSC. 441 # Made it legal to specify the channel by itself without -c/--channel. 442 443 444 #use strict; 445 use Getopt::Long qw(:config no_ignore_case bundling); 446 use Fcntl; 447 use Video::Frequencies 0.03; 448 use Video::ivtv 0.12; 449 use Config::IniFiles; 450 451 my $version="1.29"; 452 my $cfgVersion = "2"; 453 my $cfgVersionStr = "_configVersion_"; # hopefully unique [defaults] value to let me know what version the config file is. 454 455 my @capabilities = (); # The cards capabilities 456 457 my %settings = ( 458 Channel => $ivtvrecch , # default to the ivtv default channel 459 RecordDuration => $reclengthsec , # default to 59 minutes 50 seconds (in seconds) - This lets 2 back to back cron jobs work! 460 InputNum => $capturedeviceinputnum , # TV-Tuner 0 on GV-MVP/RX $capturedeviceinputnum 461 InputName => "$capturedeviceinputName", 462 OutputDirectory => "$recfolderpath", 463 VideoDevice => "$recdevice", 464 VideoWidth => "720", # 720x480-fullscreen NTSC 465 VideoHeight => "480", 466 VideoStandard => "NTSC", # NTSC, PAL or SECAM 467 VideoType => "mpeg", # mpeg, yuv 468 Bitrate => "$stdbitrate", 469 PeakBitrate => "$peakbitrate", # peak bitrate 470 Aspect => 2, 471 AudioBitmask => 0x00e9, 472 BFrames => 3, 473 DNRMode => 0, 474 DNRSpatial => 0, 475 DNRTemporal => 0, 476 DNRType => 0, 477 Framerate => 0, 478 FramesPerGOP => 15, 479 GOPClosure => 1, 480 Pulldown => 0, 481 StreamType => 0, # 10 = DVD format (almost) 482 OutputFileName => "$outputfile", 483 FrequencyTable => "$frequencyTable", # default to NTSC_CABLE mapping. 484 Frequency => "", # user specified frequency. 485 ResetCardSettings => 1, 486 ConfigFileName => "$ENV{HOME}/.ivtvrc", 487 UpdateConfigFile => 0, 488 UseConfigFile => 0, 489 UsingIvtvDriver => 1, # default to being able to use the ivtv "enhancements". 490 DontRecord => 0, # default to always recording data. 491 DirectoryFormatString => " ", # format string used to define the sub directory under OutputDirectory 492 DateTimeFormatString => "+%Y%m%d-%H%M", # format string used to represent the date/time if the user wants it in their DirectoryFormatString 493 # define the Codec related min/max values 494 minBitrate => 1, 495 maxBitrate => 14500000, 496 minPeakBitrate => 1500, 497 maxPeakBitrate => 16000000, 498 # msp matrix settings 499 SetMSPMatrix => 1, 500 MSPInput => 3, 501 MSPOutput => 1, 502 MSPSleep => 2, # number of seconds the card needs before we can set the msp matrix. 503 # other settings 504 Debug => 0,#DEBUG 505 TunerNum => 0, 506 ); 507 508 509 print " $settings{InputNum} / $settings{InputName} /IVTVRECCH:$settings{Channel}/$recdevice \n\n" if $settings{Debug}; 510 511 512 my $result=""; 513 my @profileNames=(); # list of user defined sections to work with in the config file. 514 my %configIni; # config hash we tie to for Config::IniFiles. 515 my $ivtvObj = Video::ivtv->new(); 516 517 # map the Settings/Config file parameter to the command line variable that specifies it. 518 my %mappings = ( 519 "Channel" => "c|channel", 520 "RecordDuration" => "t|duration", 521 "InputNum" => "i|inputnum", 522 "InputName" => "I|inputname", 523 "OutputDirectory" => "D|directory", 524 "VideoDevice" => "d|input", 525 "VideoWidth" => "W|width", 526 "VideoHeight" => "H|height", 527 "VideoStandard" => "s|standard", 528 "VideoType" => "T|type", 529 "Bitrate" => "b|bitrate", 530 "PeakBitrate" => "B|peakbitrate", 531 "Aspect" => "aspect", 532 "AudioBitmask" => "audio-bitmask", 533 "BFrames" => "bframes", 534 "DNRMode" => "dnrmode", 535 "DNRSpatial" => "dnrspatial", 536 "DNRTemporal" => "dnrtemporal", 537 "DNRType" => "dnrtype", 538 "Framerate" => "framerate", 539 "FramesPerGOP" => "framespergop", 540 "GOPClosure" => "gopclosure", 541 "Pulldown" => "pulldown", 542 "StreamType" => "streamtype", 543 "OutputFileName" => "o|output", 544 "FrequencyTable" => "f|freqtable", 545 "Frequency" => "F|frequency", 546 "ResetCardSettings" => "R|noreset", 547 "DirectoryFormatString" => "directory-format", 548 "DateTimeFormatString" => "date-format", 549 "Debug" => "debug", 550 "TunerNum" => "tuner-num", 551 "SetMSPMatrix" => "set-msp-matrix", 552 "MSPInput" => "msp-input", 553 "MSPOutput" => "msp-output", 554 "MSPSleep" => "msp-sleep", 555 "OutputMPGFileName" => "outputmpgfilename", 556 ); 557 558 my %codecMappings = ( 559 "Aspect" => "aspect", 560 "AudioBitmask" => "audio_bitmask", 561 "BFrames" => "bframes", 562 "Bitrate" => "bitrate", 563 "PeakBitrate" => "bitrate_peak", 564 "DNRMode" => "dnr_mode", 565 "DNRSpatial" => "dnr_spatial", 566 "DNRTemporal" => "dnr_temporal", 567 "DNRType" => "dnr_type", 568 "Framerate" => "framerate", 569 "FramesPerGOP" => "framespergop", 570 "GOPClosure" => "gop_closure", 571 "Pulldown" => "pulldown", 572 "StreamType" => "stream_type", 573 ); 574 575 # check for devfs support 576 if ( -e "/dev/.devfsd" ) 577 { 578 $settings{VideoDevice} = "/dev/v4l/video0"; 579 } 580 581 ## check for the config file 582 #if (-f $settings{ConfigFileName}) 583 #{ 584 # $settings{UseConfigFile} = 1; 585 # 586 # # tie to it. 587 # tie %configIni, 'Config::IniFiles', (-file => $settings{ConfigFileName}) or die "Error: Opening config file '$settings{ConfigFileName}' failed! $!\n"; 588 # 589 # my $profile = "defaults"; 590 # if (exists $configIni{$profile}) 591 # { 592 # my $saveFile = 0; 593 # # check version of the config file. 594 # if (!exists $configIni{$profile}{$cfgVersionStr}) 595 # { 596 # print "Updating config file to version 1...\n"; 597 # 598 # # first version config file! Update the Audio -> AudioBitmask entries. 599 # $configIni{$profile}{$cfgVersionStr} = 1; 600 # 601 # # find all entries that have Audio and move to AudioBitmask. 602 # foreach my $p (keys %configIni) 603 # { 604 # if (exists $configIni{$p}{Audio}) 605 # { 606 # $configIni{$p}{AudioBitmask} = $configIni{$p}{Audio}; 607 # delete $configIni{$p}{Audio}; 608 # } 609 # } 610 # 611 # $saveFile = 1; # signal we need to save the config changes. 612 # } 613 # if ($configIni{$profile}{$cfgVersionStr} != $cfgVersion) 614 # { 615 # # we need to upgrade 616 # if ($configIni{$profile}{$cfgVersionStr} == 1) 617 # { 618 # print "Updating config file to version 2...\n"; 619 # # add the MSP Matrix related options. 620 # $configIni{$profile}{SetMSPMatrix} = $settings{SetMSPMatrix}; 621 # $configIni{$profile}{MSPInput} = $settings{MSPInput}; 622 # $configIni{$profile}{MSPOutput} = $settings{MSPOutput}; 623 # $configIni{$profile}{MSPSleep} = $settings{MSPSleep}; 624 # $configIni{$profile}{$cfgVersionStr} = 2; 625 # $saveFile = 1; 626 # } 627 # } 628 # 629 # if ($saveFile) 630 # { 631 # # now save the updated config file before we continue. 632 # tied(%configIni)->RewriteConfig or die "Error: Writing config file '$settings{ConfigFileName}' failed! $!\n"; 633 # } 634 # 635 # # update the defaults stored. 636 # foreach my $arg (keys %mappings) 637 # { 638 # if (exists $configIni{$profile}{$arg}) 639 # { 640 # $settings{$arg} = $configIni{$profile}{$arg}; 641 # print "settings{$arg} = '" . $settings{$arg} . "'\n"; 642 # } 643 # } 644 # } 645 # else 646 # { 647 # print "Warning: config file '$settings{ConfigFileName}' exists but does not have the\n[$profile] section! Use -S to create it without specifying -P.\n\n"; 648 # } 649 #} 650 #else # create the config file 651 #{ 652 # print "Auto Creating config file $settings{ConfigFileName}...\n"; 653 # my $profile = "defaults"; 654 # 655 # # we have to create the config file and tie to it. 656 # tie %configIni, 'Config::IniFiles', () or die "Error: Initializing config file '$settings{ConfigFileName}' failed! $!\n"; 657 # 658 # # now set the name to work with. 659 # tied(%configIni)->SetFileName($settings{ConfigFileName}) or die "Error: Setting config file to '$settings{ConfigFileName}' failed! $!\n"; 660 # 661 # $configIni{$profile} = {}; # make sure the section exists. 662 # 663 # foreach my $arg (keys %mappings) 664 # { 665 # $configIni{$profile}{$arg} = $settings{$arg}; 666 # print "configIni{$profile}{$arg} = '" . $settings{$arg} . "'\n" if $settings{Debug}; 667 # } 668 # 669 # # set the config file version 670 # $configIni{$profile}{$cfgVersionStr} = $cfgVersion; 671 # 672 # # write the config file out. 673 # tied(%configIni)->RewriteConfig or die "Error: Writing config file '$settings{ConfigFileName}' failed! $!\n"; 674 #} 675 676 # build up the "custom" frequency table 677 my %customMap = (); 678 foreach my $profileName (keys %configIni) 679 { 680 next if $profileName =~ /^(defaults)$/; 681 682 if (exists $configIni{$profileName}{Frequency}) 683 { 684 $customMap{$profileName} = $configIni{$profileName}{Frequency}; 685 } 686 } 687 $CHANLIST{custom} = \%customMap; 688 689 # enumerations 690 my @standards; 691 my %name2std; 692 my @inputs; 693 my %name2input; 694 my @codecInfo; # stores the Codec Info 695 my @newCodecInfo; # the version we mess with. 696 # Current settings (Input, Channel, Standard) 697 my $curinput; 698 my $curinputName; 699 my $std; 700 my $curstd = "???"; 701 my $curStandard = 0; # numeric representation. 702 my $curChannel = 0; 703 my $curFrequency = 0; 704 705 my $tuner; 706 my $err; 707 my $v4l2input; 708 709 my $tmpDirectoryStr = formatDirectoryString(); 710 my $versionStr = "record-v4l2.pl $version for use with http://ivtv.sf.net/"; 711 my $usageStr = <<"END_OF_USAGE"; 712 $versionStr 713 714 Usage: record-v4l2.pl [--channel CHANNEL] [--duration TIME] 715 [--directory DIRECTORY] [--output OUTPUT] 716 [--directory-format FORMAT] [--date-format FORMAT] 717 [--input VIDEO_DEV][--width WIDTH --height HEIGHT] 718 [--standard STANDARD] [--type TYPE] 719 [--inputnum INPUT#] [--inputname INPUT NAME] 720 [--freqtable FREQENCY MAP] [--frequency FREQUENCY] 721 [--bitrate BITRATE] [--peakbitrate PEAK_BITRATE] 722 [--set-msp-matrix BOOL] [--msp-sleep SLEEP] 723 [--msp-input INPUT] [--msp-output OUTPUT] 724 [--profile PROFILE] [--list-freqtable] [--list-channels] 725 [--no-record] [--noreset] [--save] [--help] [--version] 726 [--aspect ASPECT] [--audio-bitmask AUDIO-BITMASK] [--bframes BFRAMES] 727 [--dnrmode DNRMODE] [--dnrspatial DNRSPATIAL] 728 [--dnrtemporal DNRTEMPORAL] [--dnrtype DNRTYPE] 729 [--framerate FRAMERATE] [--framespergop FRAMESPERGOP] 730 [--gopclosure GOPCLOSURE] [--pulldown PULLDOWN] 731 [--streamtype STREAMTYPE] [--debug] 732 [--tuner-num TUNERNUM] 733 [--list-inputs] [--list-standards] [CHANNEL] 734 735 -c/--channel CHANNEL: channel number to switch to 736 NOTE: You can also specify the channel by itself. 737 Ex. record-v4l2.pl 73 738 would change to channel 73 using the default settings 739 or the settings from your ~/.ivtvrc config file. 740 -t/--duration TIME: number of seconds to record 741 -D/--directory DIRECTORY: Base directory to record into 742 --directory-format FORMAT: format string that specifies the 743 sub-directory to create under the base directory that 744 the output file will be created in. This can be empty 745 to indicate no sub-directory should be created. 746 747 Available tokens are: 748 %d - date formatted by --date-format 749 %I - input name recorded from 750 Any white space in the name is converted to 751 underscores (_). Ex. 'Tuner 0' => 'Tuner_0' 752 753 %c - channel or "freq-#" frequency 754 755 --date-format FORMAT: format string that specifies the 756 date format string to generate and substitute for 757 %d in the --directory-format string. 758 759 Available tokens: see the date commands man page. 760 The string must start with a + (plus). 761 762 -o/--output OUTPUT: name of file to create 763 -d/--input VIDEO_DEV: video device to capture from 764 -W/--width WIDTH: width of screen (720 for NTSC fullscreen) 765 -H/--height HEIGHT: height of screen (480 for NTSC fullscreen) 766 -s/--standard STANDARD: NTSC, PAL or SECAM - video standard to record in 767 -T/--type TYPE: mpeg or yuv output 768 -i/--inputnum INPUT#: 769 The index number of the input you want to use (0 -> n-1) 770 -I/--inputname INPUT NAME: The name of the input you want to use. 771 -f/--freqtable FREQUENCY MAP: Specify the frequency mapping to use. 772 -F/--frequency FREQUENCY: Specify the frequency to tune to. 773 ex. 517250 = NTSC Cable 73 (SCiFi) 774 --tuner-num TUNERNUM: Specify the tuner to use. 775 --set-msp-matrix BOOL: 1 - set the msp matrix after Video Standard changes 776 0 - never set the msp matrix 777 Uses the --msp-input and --msp-output options. 778 --msp-sleep SLEEP: number of seconds the card needs before we can program 779 the msp matrix. 780 --msp-input INPUT: Specify the input parameter to program the msp matrix. 781 Valid values are from 1 - 8. 782 --msp-output OUTPUT: Specify the output parameter to program the msp matrix. 783 Valid values are from 0 - 3. 784 -L/--list-freqtable: 785 list all available frequency mappings that Video::Frequencies knows 786 --list-channels: lists all channels and their frequencies for the 787 specified frequency table being used. 788 --list-inputs: lists all inputs the v4l2 driver reports. 789 --list-standards: lists all Video Standards the v4l2 driver supports. 790 -R/--noreset: Do not Reset anything that was changed 791 (standard, channel, resolution, etc.) 792 --no-record: Do not create any directories, capture data or reset the card 793 back to original settings. This is the ptune.pl mode. 794 -h/--help: display this help 795 -v/--version: display the version of this program 796 --debug: turns on debug output 797 798 Codec related options: 799 -b/--bitrate BITRATE: Specify the Bitrate to capture at 800 -B/--peakbitrate PEAK_BITRATE: Specify the Peak Bitrate to capture at 801 --aspect ASPECT: Specify the aspect value 802 --audio-bitmask AUDIO-BITMASK: Specify the audio bitmask value 803 --bframes BFRAMES: Specify the bframes value 804 --dnrmode DNRMODE: Specify the dnr_mode value 805 --dnrspatial DNRSPATIAL: Specify the dnr_spatial value 806 --dnrtemporal DNRTEMPORAL: Specify the dnr_temporal value 807 --dnrtype DNRTYPE: Specify the dnr_type value 808 --framerate FRAMERATE: Specify the framerate value 809 --framespergop FRAMESPERGOP: Specify the framespergop value 810 --gopclosure GOPCLOSURE: Specify the gop_closure value 811 --pulldown PULLDOWN: Specify the pulldown value 812 --streamtype STREAMTYPE: Specify the stream_type value 813 814 Config file related options: 815 -P/--profile PROFILE: Override defaults and command line values with the 816 config entries in the section labeled [PROFILE] from the 817 config file $settings{ConfigFileName}. 818 Examples: -P NTSC-DVD, -P PAL-DVD, --profile MY-SETTINGS 819 820 You can specify this option multiple times and each successive 821 profile will overlay the defaults and any previous profiles. 822 You will not be able to create/update a profile if you do 823 specify multiple profiles. 824 -S/--save: save the current values as the defaults in 825 $settings{ConfigFileName}. 826 If -P/--profile PROFILE is specified, then those values that exist in 827 the specified profile will be updated. If the profile doesn't exist, 828 then it will be created, but will have all possible config items 829 defined in it. It will be your responsibility to hand check the 830 config file and remove any config items you do not want set for 831 that profile. 832 Any options specified on the command line will override options 833 defined in the config file. 834 835 Notes: 836 If you specify both -i/--inputnum and -I/--inputname then 837 -i/--inputnum will take precedence. 838 839 If you specify both -c/--channel and -F/--frequency then 840 -F/--frequency will take precedence. 841 842 If you use a Profile, it has the ability to override all command line 843 arguments, so check your Profile first if things seem to be ignored. 844 845 Defaults: 846 --duration $settings{RecordDuration} --input $settings{VideoDevice} --width $settings{VideoWidth} --height $settings{VideoHeight} --standard $settings{VideoStandard} 847 --type $settings{VideoType} --directory $settings{OutputDirectory} --output $settings{OutputFileName} 848 --directory-format "$settings{DirectoryFormatString}" --date-format "$settings{DateTimeFormatString}" 849 --inputnum $settings{InputNum} --inputname '$settings{InputName}' --freqtable $settings{FrequencyTable} 850 --set-msp-matrix $settings{SetMSPMatrix} --msp-sleep $settings{MSPSleep} --msp-input $settings{MSPInput} --msp-output $settings{MSPOutput} 851 --bitrate $settings{Bitrate} --peakbitrate $settings{PeakBitrate} --aspect $settings{Aspect} --audio-bitmask $settings{AudioBitmask} --bframes $settings{BFrames} 852 --dnrmode $settings{DNRMode} --dnrspatial $settings{DNRSpatial} --dnrtemporal $settings{DNRTemporal} --dnrtype $settings{DNRType} 853 --framerate $settings{Framerate} --framespergop $settings{FramesPerGOP} --gopclosure $settings{GOPClosure} --pulldown $settings{Pulldown} --streamtype $settings{StreamType} 854 --tuner-num $settings{TunerNum} 855 856 config file = '$settings{ConfigFileName}' 857 858 If Channel = $settings{Channel}, this would create: 859 $tmpDirectoryStr$settings{OutputFileName} 860 861 Note: This script relies on Perl Modules: Video::Frequencies, Video::ivtv, 862 Config::IniFiles and Getopt::Long. 863 END_OF_USAGE 864 865 # handle user input here 866 my %opts; 867 #getopts('c:t:o:hd:W:H:s:T:D:vi:I:f:F:LRb:B:P:S', \%opts); 868 GetOptions(\%opts, "channel|c=s", "duration|t=i", "output|o=s", "help|h", "input|d=s", "width|W=i", "height|H=i", "standard|s=s", 869 "type|T=s", "directory|D=s", "version|v", "inputnum|i=i", "inputname|I=s", "freqtable|f=s", "frequency|F=i", "list-freqtable|L", 870 "noreset|R", "bitrate|b=i", "peakbitrate|B=i", "profile|P=s@", "save|S", "aspect=i", "audio-bitmask=s", "bframes=i", "dnrmode=i", "dnrspatial=i", 871 "dnrtemporal=i", "dnrtype=i", "framerate=i", "framespergop=i", "gopclosure=i", "pulldown=i", 872 "streamtype=i", "no-record", "directory-format=s", "date-format=s", "debug", "list-channels", 873 "tuner-num=i", "list-inputs", "list-standards", "set-msp-matrix=i", "msp-input=i", "msp-output=i", "outputmpgfilename=s"); 874 if (scalar keys %opts == 0 && @ARGV == 0) 875 { 876 usage(0, ""); 877 } 878 foreach my $option (sort keys %opts) 879 { 880 my $found = 0; 881 foreach my $mapName (keys %mappings) 882 { 883 if ($option =~ /^($mappings{$mapName})$/) 884 { 885 $settings{$mapName} = $opts{$option}; 886 $found = 1; 887 print "$mapName = '$opts{$option}'\n" if $settings{Debug}; 888 } 889 } 890 if (!$found) 891 { 892 # handle the non-settings cases. 893 if ($option =~ /^(L|list-freqtable)$/) 894 { 895 my $errStr = "\nAvailable Frequency Mappings:\n"; 896 foreach my $name (sort keys %CHANLIST) 897 { 898 $errStr .= "$name\n"; 899 } 900 print "$versionStr\n$errStr"; 901 exit 0; 902 } 903 elsif ($option eq "list-channels") 904 { 905 my $errStr = "\nAvailable Channels for $settings{FrequencyTable}:\n"; 906 foreach my $name (sort { $a <=> $b } keys %{$CHANLIST{$settings{FrequencyTable}}}) 907 { 908 $errStr .= "$name\t= $CHANLIST{$settings{FrequencyTable}}->{$name}\n"; 909 } 910 print "$versionStr\n$errStr"; 911 exit 0; 912 } 913 elsif ($option =~ /^(no-record)$/) 914 { 915 $settings{DontRecord} = 1; 916 } 917 elsif ($option =~ /^(S|save)$/) 918 { 919 $settings{UpdateConfigFile} = 1; 920 } 921 elsif ($option =~ /^(P|profile)$/) 922 { 923 @profileNames = @{$opts{$option}}; 924 } 925 elsif ($option =~ /^(v|version)$/) 926 { 927 print "$versionStr\n"; 928 exit 0; 929 } 930 elsif ($option =~ /^(h|help)$/) 931 { 932 usage(0, ""); 933 } 934 elsif ($option =~ /^(list-inputs|list-standards)$/) 935 { 936 # do nothing for now since they will be handled later. 937 } 938 939 else 940 { 941 usage(1, "-$option is an unknown option!"); 942 } 943 } 944 } 945 946 if (@profileNames) 947 { 948 # loop over all profiles the user specified. 949 foreach my $profileName (@profileNames) 950 { 951 print "profile = '$profileName'\n" if $settings{Debug}; 952 # for now the profile can not be "defaults". 953 if ($profileName eq "defaults") 954 { 955 error(1, "Profile = '$profileName' is invalid!"); 956 } 957 if (exists $configIni{$profileName}) 958 { 959 # update defaults/override command line arguments that exist in this profile. 960 my $profileUpdating = (((exists $opts{S} || exists $opts{save}) && @profileNames == 1) ? 1 : 0); 961 my $profile = $profileName; 962 963 foreach my $arg (keys %mappings) 964 { 965 foreach my $option (split(/\|/, $mappings{$arg})) # handle the long/short command option versions 966 { 967 #print "arg = '$arg', option = '$option'\n" if $settings{Debug}; 968 if (exists $configIni{$profile}{$arg} && !($profileUpdating && exists $opts{$option})) 969 { 970 $settings{$arg} = $configIni{$profile}{$arg}; 971 print "settings{$arg} = '" . $settings{$arg} . "'\n" if $settings{Debug}; 972 last; 973 } 974 } 975 } 976 } 977 else 978 { 979 if ($settings{UpdateConfigFile} && @profileNames == 1) 980 { 981 print "Warning: Profile = '$profileName' will be created.\n" if ($settings{Debug}); 982 } 983 else 984 { 985 error(1, "Profile = '$profileName' does not exist! You must specify -S/--save to create it."); 986 } 987 } 988 } 989 } 990 991 # verify input 992 993 if (@ARGV) 994 { 995 if (exists $opts{c} || exists $opts{channel}) 996 { 997 print "Warning: ignoring channel argument and using '$ARGV[0]' instead.\n"; 998 } 999 $settings{Channel} = $ARGV[0]; 1000 } 1001 1002 if (!$settings{DontRecord}) 1003 { 1004 print "RecordDuration = $settings{RecordDuration}\n" if $settings{Debug}; 1005 1006 if ($settings{VideoType} !~ /^(mpeg|yuv)$/) 1007 { 1008 error(1, "Video Type = '$settings{VideoType}' is invalid!"); 1009 } 1010 if ($settings{VideoType} eq "yuv") 1011 { 1012 # see if we need to change our defaults. 1013 if (!exists $opts{o} && !exists $opts{output}) 1014 { 1015 $settings{OutputFileName} = "video.yuv"; 1016 } 1017 if (!exists $opts{d} && !exists $opts{input}) 1018 { 1019 if ( -e "/dev/.devfsd" ) 1020 { 1021 $settings{VideoDevice} = "/dev/v4l/yuv0"; 1022 } 1023 else 1024 { 1025 $settings{VideoDevice} = "/dev/yuv0"; 1026 } 1027 } 1028 } 1029 } 1030 1031 if ( ! -c "$settings{VideoDevice}") 1032 { 1033 error(1, "Video Dev = '$settings{VideoDevice}' is invalid! $!"); 1034 } 1035 1036 # now that the video device has been semi validated, we can use it to lookup 1037 # the inputs, standards, etc. and use that for validating some of the following 1038 # pieces of user input. 1039 sysopen($tuner, $settings{VideoDevice}, O_RDWR) or die "Error unable to open '$settings{VideoDevice}': $!"; 1040 my $tunerFD = fileno($tuner); 1041 1042 # get the current capabilities. 1043 @capabilities = $ivtvObj->getCapabilities($tunerFD); 1044 if (@capabilities != keys %{$ivtvObj->{capIndexes}}) 1045 { 1046 error(1, "getCapabilities() failed!"); 1047 } 1048 if ($capabilities[$ivtvObj->{capIndexes}{driver}] ne "ivtv") 1049 { 1050 $settings{UsingIvtvDriver} = 0; # we can't use the ivtv "enhancements". 1051 print "Warning: V4l2 driver = '$capabilities[$ivtvObj->{capIndexes}{driver}]' does not support the ivtv \"enhancements\"!\n"; 1052 print " All codec related options will be ignored.\n\n"; 1053 } 1054 1055 my $i; 1056 1057 # get the current video standard 1058 $std = $ivtvObj->getStandard($tunerFD); 1059 if ($std > 0) 1060 { 1061 printf("Standard: 0x%08x\n",$std) if ($settings{Debug}); 1062 } 1063 else 1064 { 1065 die "Error: getStandard() failed!\n"; 1066 } 1067 1068 # get the current input 1069 $curinput = $ivtvObj->getInput($tunerFD); 1070 if ($curinput < 0) 1071 { 1072 die "Error: getInput() failed!\n"; 1073 } 1074 printf("Input: 0x%08x\n",$curinput) if ($settings{Debug}); 1075 1076 my $done=0; 1077 # Standards 1078 for ($i=0; !$done; ++$i) 1079 { 1080 my($index,$std_id,$name,$frameperiod_n,$frameperiod_d,$framelines) = $ivtvObj->enumerateStandard($tunerFD, $i); 1081 if ($index == -1) 1082 { 1083 $done = 1; 1084 } 1085 else 1086 { 1087 printf("%d 0x%08x %s %d/%d %d\n",$index,$std_id,$name,$frameperiod_n,$frameperiod_d,$framelines) if ($settings{Debug}); 1088 push @standards, [($name,$std_id)]; 1089 $name2std{$name} = $std_id; 1090 if( (($std_id & $std) == $std)) 1091 { 1092 $curstd = $name; 1093 $curStandard = $std; 1094 } 1095 } 1096 } 1097 1098 if (exists $opts{'list-standards'}) 1099 { 1100 print "$versionStr\n"; 1101 print "Available Video Standards:\n"; 1102 foreach my $standard (@standards) 1103 { 1104 print "$standard->[0]\n"; 1105 } 1106 exit 0; 1107 } 1108 1109 $done=0; 1110 # Inputs 1111 for ($i=0; !$done; ++$i) 1112 { 1113 my($index,$name,$type,$audioset,$tuner,$std,$status) = $ivtvObj->enumerateInput($tunerFD, $i); 1114 if ($index == -1) 1115 { 1116 $done = 1; 1117 } 1118 else 1119 { 1120 push @inputs, $name; 1121 $name2input{$name} = $index; 1122 } 1123 } 1124 $curinputName = $inputs[$curinput]; 1125 1126 if (exists $opts{'list-inputs'}) 1127 { 1128 print "$versionStr\n"; 1129 print "Available Inputs:\n"; 1130 my $counter = 0; 1131 foreach my $input (@inputs) 1132 { 1133 print "$counter: $input\n"; 1134 $counter++; 1135 } 1136 exit 0; 1137 } 1138 1139 if ($settings{UsingIvtvDriver}) 1140 { 1141 # get the current Codec Info 1142 @codecInfo = $ivtvObj->getCodecInfo($tunerFD); 1143 if (@codecInfo != keys %{$ivtvObj->{codecIndexes}}) 1144 { 1145 error(1, "getCodecInfo() failed!"); 1146 } 1147 @newCodecInfo = $ivtvObj->getCodecInfo($tunerFD); 1148 if (@newCodecInfo != keys %{$ivtvObj->{codecIndexes}}) 1149 { 1150 error(1, "getCodecInfo() failed!"); 1151 } 1152 } 1153 1154 # finish validating the user input. 1155 1156 if (!$settings{DontRecord}) 1157 { 1158 if ($settings{RecordDuration} !~ /^(\d+)$/) 1159 { 1160 error(1, "Time = '$settings{RecordDuration}' is invalid!"); 1161 } 1162 1163 if ( ! -d "$settings{OutputDirectory}") 1164 { 1165 error(1, "Directory = '$settings{OutputDirectory}' is invalid! $!"); 1166 } 1167 1168 # assume for now we are only generating mpeg files. 1169 # if (($settings{VideoType} eq "mpeg" && $settings{OutputFileName} !~ /^.+\.mpg$/) || ($settings{VideoType} eq "yuv" && $settings{OutputFileName} !~ /^.+\.yuv$/)) 1170 # { 1171 # error(1, "Output = '$settings{OutputFileName}' is invalid!"); 1172 # } 1173 # 1174 if ($settings{DateTimeFormatString} !~ /^(\+((\%.)|.)+)$/) 1175 { 1176 usage(1, "Date Format String = '$settings{DateTimeFormatString}' is invalid!"); 1177 } 1178 } 1179 1180 if ($settings{VideoWidth} !~ /^(\d+)$/) 1181 { 1182 error(1, "Width = '$settings{VideoWidth}' is invalid!"); 1183 } 1184 1185 if ($settings{VideoHeight} !~ /^(\d+)$/) 1186 { 1187 error(1, "Height = '$settings{VideoHeight}' is invalid!"); 1188 } 1189 1190 if (!exists $name2std{$settings{VideoStandard}}) 1191 { 1192 my $validStandards = join(", ", keys(%name2std)); 1193 error(1, "Video Standard = '$settings{VideoStandard}' is invalid!\nValid Standards are: $validStandards"); 1194 } 1195 1196 if (exists $opts{i} || exists $opts{inputnum}) 1197 { 1198 if ($settings{InputNum} < 0 || $settings{InputNum} >= scalar(@inputs)) 1199 { 1200 error(1, "Video Input = '$settings{InputNum}' is invalid!\nValid Inputs are from 0 - " . int(scalar(@inputs) - 1)); 1201 } 1202 $settings{InputName} = $inputs[$settings{InputNum}]; 1203 } 1204 1205 if ((exists $opts{I} || exists $opts{inputname}) && !(exists $opts{i} || exists $opts{inputnum})) 1206 { 1207 if (!exists $name2input{$settings{InputName}}) 1208 { 1209 my $validInputs = join(", ", @inputs); 1210 error(1, "Video Input Name = '$settings{InputName}' is invalid!\nValid Input Names are: $validInputs"); 1211 } 1212 $settings{InputNum} = $name2input{$settings{InputName}}; 1213 } 1214 1215 if (!exists $CHANLIST{$settings{FrequencyTable}}) 1216 { 1217 error(1, "Frequency Table = '$settings{FrequencyTable}' is invalid!"); 1218 } 1219 1220 # only validate the channel if the input is a tuner. 1221 if ($inputs[$settings{InputNum}] =~ /Tuner/) 1222 { 1223 if ($settings{TunerNum} !~ /^(\d)$/) 1224 { 1225 error(1, "TunerNum = '$settings{TunerNum}' is invalid!"); 1226 } 1227 if (exists $opts{F} || exists $opts{frequency} || $settings{Frequency}) # the user may have specified a Frequency in their config file 1228 { 1229 if ($settings{Frequency} !~ /^(\d+)$/) 1230 { 1231 error(1, "Frequency = '$settings{Frequency}' is invalid!"); 1232 } 1233 $settings{Channel} = "freq-$settings{Frequency}"; # make sure we output the channel part. 1234 } 1235 # now verify that the channel exists in the frequency table! 1236 else 1237 { 1238 if (!$settings{Channel}) 1239 { 1240 error(1, "channel = '$settings{Channel}' is invalid!"); 1241 } 1242 # first verify the freqency table is appropriate for the standard (NTSC, PAL, SECAM), 1243 # unless they specified the frequency to tune to. 1244 if ($settings{FrequencyTable} !~ /^(custom|$settings{VideoStandard})/i) 1245 { 1246 error(1, "You specified Video Standard '$settings{VideoStandard}' which is incompatible with Frequency Table '$settings{FrequencyTable}'!"); 1247 } 1248 if (!exists $CHANLIST{$settings{FrequencyTable}}->{$settings{Channel}}) 1249 { 1250 error(1, "Channel = '$settings{Channel}' does not exist in Frequency Table '$settings{FrequencyTable}'!"); 1251 } 1252 } 1253 1254 # get the current channel/frequency value. 1255 my $Frequency; 1256 if(($Frequency = $ivtvObj->getFrequency($tunerFD, $settings{TunerNum})) >= 0) 1257 { 1258 my $freq = ($Frequency * 1000) / 16; 1259 print "freq = $freq\n" if ($settings{Debug}); 1260 # find the associated channel. 1261 if ((!exists $opts{F} && !exists $opts{frequency} && !$settings{Frequency}) && ($curstd eq $settings{VideoStandard}) ) 1262 { 1263 foreach my $chan (keys %{$CHANLIST{$settings{FrequencyTable}}}) 1264 { 1265 if ($CHANLIST{$settings{FrequencyTable}}->{$chan} == $freq) 1266 { 1267 $curChannel = $chan; 1268 } 1269 } 1270 print "curChannel = $curChannel\n" if ($settings{Debug}); 1271 } 1272 else 1273 { 1274 $curFrequency = $freq; 1275 } 1276 } 1277 else 1278 { 1279 die "Error: getFrequency() failed!\n"; 1280 } 1281 } 1282 else 1283 { 1284 # set the channel = "" so we know to ignore it. 1285 $settings{Channel} = ""; 1286 } 1287 1288 if ($settings{UsingIvtvDriver}) 1289 { 1290 # validate the Codec related stuff. 1291 if ($settings{Bitrate} < $settings{minBitrate} || $settings{Bitrate} > $settings{maxBitrate}) 1292 { 1293 error(1, "Bitrate = '$settings{Bitrate}' is invalid!"); 1294 } 1295 if ($settings{PeakBitrate} <= $settings{Bitrate}) 1296 { 1297 error(1, "PeakBitrate can not be less than or equal to Bitrate!"); 1298 } 1299 elsif ($settings{PeakBitrate} < $settings{minPeakBitrate} || $settings{PeakBitrate} > $settings{maxPeakBitrate}) 1300 { 1301 error(1, "PeakBitrate = '$settings{PeakBitrate}' is invalid!"); 1302 } 1303 1304 if ($settings{VideoStandard} !~ /^(NTSC)/) 1305 { 1306 my $warn = 0; 1307 if ($settings{Framerate} == 0) 1308 { 1309 $settings{Framerate} = 1; 1310 $warn = 1; 1311 } 1312 if ($settings{FramesPerGOP} == 15) 1313 { 1314 $settings{FramesPerGOP} = 12; 1315 $warn = 1; 1316 } 1317 if ($warn) 1318 { 1319 print "Warning: Setting Framerate/FramesPerGOP to PAL settings for Video Standard '$settings{VideoStandard}'!\n\nYou should either specify on the command line or in the ~/.ivtvrc config file.\n"; 1320 } 1321 } 1322 elsif ($settings{VideoStandard} =~ /^(NTSC)/) 1323 { 1324 my $warn = 0; 1325 if ($settings{Framerate} == 1) 1326 { 1327 $settings{Framerate} = 0; 1328 $warn = 1; 1329 } 1330 if ($settings{FramesPerGOP} == 12) 1331 { 1332 $settings{FramesPerGOP} = 15; 1333 $warn = 1; 1334 } 1335 if ($warn) 1336 { 1337 print "Warning: Setting Framerate/FramesPerGOP to NTSC settings for Video Standard '$settings{VideoStandard}'!\n\nYou should either specify on the command line or in the ~/.ivtvrc config file.\n"; 1338 } 1339 } 1340 1341 if ($settings{SetMSPMatrix} !~ /^(0|1)$/) 1342 { 1343 error(1, "SetMSPMatrix = '$settings{SetMSPMatrix}' is invalid! It can only be 0 or 1."); 1344 } 1345 if ($settings{MSPInput} < 1 || $settings{MSPInput} > 8) 1346 { 1347 error(1, "MSPInput = '$settings{MSPInput}' is invalid! It can only be 1 - 8."); 1348 } 1349 if ($settings{MSPOutput} < 0 || $settings{MSPOutput} > 3) 1350 { 1351 error(1, "MSPOutput = '$settings{MSPOutput}' is invalid! It can only be 0 - 3."); 1352 } 1353 } 1354 1355 # update the config file if the user wants us to. 1356 if ($settings{UpdateConfigFile}) 1357 { 1358 my $profile; 1359 if (@profileNames > 1) 1360 { 1361 print "Warning: Not updating config file as you have more than 1 profile specified!\n"; 1362 } 1363 elsif (@profileNames == 1) 1364 { 1365 $profile = $profileNames[0]; 1366 } 1367 else 1368 { 1369 $profile = "defaults"; 1370 } 1371 if ($profile) 1372 { 1373 my $createProfile = (exists $configIni{$profile} ? 0 : 1); 1374 print "Creating Profile = '$profile': $createProfile\n" if ($settings{Debug}); 1375 1376 if (!$settings{UseConfigFile}) 1377 { 1378 # we have to create the config file and tie to it. 1379 tie %configIni, 'Config::IniFiles', () or die "Error: Initializing config file '$settings{ConfigFileName}' failed! $!\n"; 1380 1381 # now set the name to work with. 1382 tied(%configIni)->SetFileName($settings{ConfigFileName}) or die "Error: Setting config file to '$settings{ConfigFileName}' failed! $!\n"; 1383 1384 $configIni{$profile} = {}; # make sure the section exists. 1385 } 1386 1387 foreach my $arg (keys %mappings) 1388 { 1389 foreach my $option (split(/\|/, $mappings{$arg})) # handle the long/short command option versions 1390 { 1391 if (exists $configIni{$profile}{$arg} || $createProfile || exists $opts{$option}) 1392 { 1393 $configIni{$profile}{$arg} = $settings{$arg}; 1394 print "configIni{$profile}{$arg} = '" . $settings{$arg} . "'\n" if $settings{Debug}; 1395 last; 1396 } 1397 } 1398 } 1399 1400 # write the config file out. 1401 tied(%configIni)->RewriteConfig or die "Error: Writing config file '$settings{ConfigFileName}' failed! $!\n"; 1402 } 1403 } 1404 1405 # this hash keeps track of those values I have to set back. 1406 my %changedSettings = ( 1407 resolution => 0, 1408 standard => 0, 1409 VideoType => 0, 1410 InputNum => 0, 1411 Channel => 0, 1412 Frequency => 0, 1413 codec => 0, 1414 ); 1415 1416 my $directoryName; 1417 if (!$settings{DontRecord}) 1418 { 1419 # make directory 1420 #$directoryName = formatDirectoryString(); 1421 #$result=`mkdir -p $directoryName`; 1422 $directoryName = $settings{DirectoryFormatString}; 1423 } 1424 1425 # change the channel 1426 if ($inputs[$settings{InputNum}] =~ /Tuner/) 1427 { 1428 if (exists $opts{F} || exists $opts{frequency} || $settings{Frequency}) 1429 { 1430 if ($settings{Frequency} != $curFrequency) 1431 { 1432 $changedSettings{Frequency} = 1; 1433 tuneFrequency($settings{Frequency}); 1434 } 1435 } 1436 else 1437 { 1438 if ($curstd ne $settings{VideoStandard}) 1439 { 1440 # we have to set the channel regardless. 1441 # but we want to tune back to the previous frequency. 1442 $changedSettings{Frequency} = 1; 1443 changeChannel($settings{Channel}); 1444 } 1445 elsif ($settings{Channel} ne $curChannel) 1446 { 1447 # otherwise we just changeChannel and restore the previous channel. 1448 $changedSettings{Channel} = 1; 1449 changeChannel($settings{Channel}); 1450 } 1451 } 1452 } 1453 1454 # set the video standard 1455 if ($settings{VideoStandard} ne $curstd) 1456 { 1457 $changedSettings{standard} = 1; 1458 change_standard(); 1459 1460 # see if we have to re-program the msp matrix 1461 if ($settings{UsingIvtvDriver}) 1462 { 1463 if ($settings{SetMSPMatrix}) 1464 { 1465 print "Setting msp matrix: input = $settings{MSPInput}, output = $settings{MSPOutput}\n" if $settings{Debug}; 1466 sleep ($settings{MSPSleep}); # sleep for 2 seconds to let card settle down. 1467 $result = $ivtvObj->mspMatrixSet($tunerFD, $settings{MSPInput}, $settings{MSPOutput}); 1468 if (not defined $result) 1469 { 1470 die "Error calling mspMatrixSet!\n"; 1471 } 1472 if (!$result) 1473 { 1474 die "Error in mspMatrixSet ioctl call!\n"; 1475 } 1476 } 1477 } 1478 } 1479 1480 # set the input 1481 if ($settings{InputNum} != $curinput || $settings{InputName} ne $curinputName) 1482 { 1483 $changedSettings{InputNum} = 1; 1484 if (!(exists $opts{i} || exists $opts{inputnum} || exists $opts{I} || exists $opts{inputname})) # our defaults are different than the current values! 1485 { 1486 ## print "Warning: Changing input from $curinputName to $settings{InputName}\n"; 1487 &writelog("tvrecording: Changing input from $curinputName to $settings{InputName}"); 1488 } 1489 change_input(); 1490 } 1491 1492 # set the capture type 1493 1494 # store the current width,height so we can restore afterwards 1495 my ($oldWidth, $oldHeight) = $ivtvObj->getResolution($tunerFD); 1496 print "oldWidth = '$oldWidth', oldHeight = '$oldHeight'\n" if ($settings{Debug}); 1497 1498 if ($settings{VideoWidth} != $oldWidth || $settings{VideoHeight} != $oldHeight) 1499 { 1500 $changedSettings{resolution} = 1; 1501 } 1502 1503 # specify the width,height to capture 1504 if ($changedSettings{resolution}) 1505 { 1506 $result = $ivtvObj->setResolution($tunerFD, $settings{VideoWidth}, $settings{VideoHeight}); 1507 if (not defined $result) 1508 { 1509 die "Error calling setResolution!\n"; 1510 } 1511 if (!$result) 1512 { 1513 die "Error in setResolution ioctl call!\n"; 1514 } 1515 } 1516 1517 if ($settings{UsingIvtvDriver}) 1518 { 1519 # specify the codec options to capture mpeg's at. 1520 foreach my $codecName (keys %codecMappings) 1521 { 1522 my $codecIndex = $ivtvObj->{codecIndexes}{$codecMappings{$codecName}}; 1523 if ($codecInfo[$codecIndex] != $settings{$codecName}) 1524 { 1525 $changedSettings{codec} = 1; 1526 $newCodecInfo[$codecIndex] = $settings{$codecName}; 1527 print "new $codecName = '$settings{$codecName}', old $codecName = '$codecInfo[$codecIndex]'\n" if $settings{Debug}; 1528 } 1529 } 1530 } 1531 1532 if ($changedSettings{codec}) 1533 { 1534 $result = $ivtvObj->setCodecInfo($tunerFD, @newCodecInfo); 1535 if (!$result) 1536 { 1537 die "Error calling setCodecInfo()!\n"; 1538 } 1539 } 1540 1541 if (!$settings{DontRecord}) 1542 { 1543 # capture the video/audio to video.mpg 1544 #print "directoryName:$directoryName, RecordDuration:$settings{RecordDuration},OutputFileName:$settings{OutputFileName}:tuner:$tuner ,OutputMPGFileName:$settings{OutputMPGFileName} \n"; 1545 #directoryName:, RecordDuration:60,OutputFileName:/tv/JOAX-20040615-1411-000.MPG:tuner:GLOB(0x8224838) ,OutputMPGFileName: 1546 captureVideo(directoryName => $directoryName, RecordDuration => $settings{RecordDuration}, 1547 OutputFileName => $settings{OutputFileName}, tuner => $tuner ,OutputMPGFileName => $settings{OutputMPGFileName}); 1548 } 1549 1550 if ($settings{ResetCardSettings} && !$settings{DontRecord}) 1551 { 1552 # restore Codec values 1553 if ($changedSettings{codec}) 1554 { 1555 $result = $ivtvObj->setCodecInfo($tunerFD, @codecInfo); 1556 if (!$result) 1557 { 1558 die "Error calling setCodecInfo()!\n"; 1559 } 1560 } 1561 1562 # restore the previous width,height settings 1563 if ($changedSettings{resolution}) 1564 { 1565 $result = $ivtvObj->setResolution($tunerFD, $oldWidth, $oldHeight); 1566 if (not defined $result) 1567 { 1568 die "Error calling setResolution!\n"; 1569 } 1570 if (!$result) 1571 { 1572 die "Error in setResolution ioctl call!\n"; 1573 } 1574 } 1575 1576 # restore the previous input setting 1577 if ($changedSettings{InputNum}) 1578 { 1579 # reset back to the old input name 1580 $settings{InputName} = $curinputName; 1581 change_input(); 1582 } 1583 1584 # restore the previous video standard 1585 if ($changedSettings{standard}) 1586 { 1587 $settings{VideoStandard} = $curstd; 1588 change_standard(); 1589 1590 # see if we have to re-program the msp matrix 1591 if ($settings{UsingIvtvDriver}) 1592 { 1593 if ($settings{SetMSPMatrix}) 1594 { 1595 print "Setting msp matrix: input = $settings{MSPInput}, output = $settings{MSPOutput}\n" if $settings{Debug}; 1596 sleep ($settings{MSPSleep}); # sleep for 2 seconds to let card settle down. 1597 $result = $ivtvObj->mspMatrixSet($tunerFD, $settings{MSPInput}, $settings{MSPOutput}); 1598 if (not defined $result) 1599 { 1600 die "Error calling mspMatrixSet!\n"; 1601 } 1602 if (!$result) 1603 { 1604 die "Error in mspMatrixSet ioctl call!\n"; 1605 } 1606 } 1607 } 1608 } 1609 1610 # restore the previous channel 1611 if ($changedSettings{Channel}) 1612 { 1613 changeChannel($curChannel); 1614 } 1615 if ($changedSettings{Frequency}) 1616 { 1617 tuneFrequency($curFrequency); 1618 } 1619 } 1620 1621 # close the tuner device 1622 close($tuner); 1623 1624 1625 exit 0; 1626 1627 # usage(returnValue, ErrorString) 1628 # returnValue = 1 or 0 1629 # ErrorString = message you want to tell the user, but only if returnValue = 1. 1630 sub usage 1631 { 1632 my $errorCode = shift; 1633 my $error = shift; 1634 1635 print $usageStr; 1636 print "\nError: $error\n" if ($errorCode == 1); 1637 print "$error\n" if ($errorCode == 2); 1638 1639 exit $errorCode; 1640 } 1641 1642 # error(returnValue, ErrorString) 1643 # returnValue = 1 or 0 1644 # ErrorString = message you want to tell the user. 1645 sub error 1646 { 1647 my $errorCode = shift; 1648 my $error = shift; 1649 1650 print "$versionStr"; 1651 print "\nError: $error\n"; 1652 1653 exit $errorCode; 1654 } 1655 1656 # changes the input to $settings{InputNum} as long as it isn't = $curinput 1657 sub change_input { 1658 my $preinput = $name2input{$settings{InputName}}; 1659 if($preinput != $curinput) 1660 { 1661 $curinput = $preinput; 1662 print "input now $settings{InputName}, #$preinput\n" if ($settings{Debug}); 1663 my $result = $ivtvObj->setInput($tunerFD, $preinput); 1664 if (!$result) 1665 { 1666 die "Error: setInput($preinput) failed!\n"; 1667 } 1668 } 1669 } 1670 1671 # changes the video standard to $settings{VideoStandard} as long as it isn't = $curstd 1672 sub change_standard { 1673 my $standard = $name2std{$settings{VideoStandard}}; 1674 if($standard != $curStandard) 1675 { 1676 $curStandard = $standard; 1677 print "standard now $settings{VideoStandard}, #$standard\n" if ($settings{Debug}); 1678 my $result = $ivtvObj->setStandard($tunerFD, $standard); 1679 if (!$result) 1680 { 1681 die "Error: setStandard($standard) failed!\n"; 1682 } 1683 } 1684 } 1685 1686 # changes the channel 1687 # takes the channel to change 1688 sub changeChannel 1689 { 1690 my $ch = shift; 1691 my $freq = $CHANLIST{$settings{FrequencyTable}}->{$ch}; 1692 my $driverf = ($freq * 16)/1000; 1693 1694 print "Ch.$ch: $freq $driverf\n" if ($settings{Debug}); 1695 1696 if (!$ivtvObj->setFrequency($tunerFD, $settings{TunerNum}, $driverf)) 1697 { 1698 die "Error: changeChannel($ch) failed!\n"; 1699 } 1700 } 1701 1702 # tunes to the specified frequency 1703 # takes the frequency to tune to 1704 sub tuneFrequency 1705 { 1706 my $freq = shift; 1707 my $driverf = ($freq * 16)/1000; 1708 1709 print "freq: $freq $driverf\n" if ($settings{Debug}); 1710 1711 if (!$ivtvObj->setFrequency($tunerFD, $settings{TunerNum}, $driverf)) 1712 { 1713 die "Error: tuneFrequency($freq) failed!\n"; 1714 } 1715 } 1716 1717 my $done = 0; 1718 1719 sub catch_alarm { 1720 $done = 1; 1721 } 1722 sub get_next_file_name 1723 { 1724 1725 my $file_name = shift(@_); 1726 $file_name =~ m/^(.+?)\-(\d{4})(\d{2})(\d{2})\-(\d{2})(\d{2})\-(\d{3})\.(.+?)$/; 1727 1728 my $station = $1; 1729 my $year = $2; 1730 my $month = $3; 1731 my $day = $4; 1732 my $hour = $5; 1733 my $min = $6; 1734 my $seq = $7; 1735 my $ext = $8; 1736 $seq++; 1737 my $new_file_name = sprintf("%s-%04d%02d%02d-%02d%02d-%03d.%s", 1738 $station,$year,$month,$day,$hour,$min,$seq,$ext); 1739 return $new_file_name 1740 } 1741 1742 # does the actual video capturing work. 1743 # takes directoryName, RecordDuration, OutputFileName, tuner 1744 sub captureVideo 1745 { 1746 my %args = ( @_ ); 1747 my $directoryName = $args{directoryName}; 1748 my $RecordDuration = $args{RecordDuration}; 1749 my $OutputFileName = $args{OutputFileName}; 1750 my $tuner = $args{tuner}; 1751 my $fname = "$directoryName/$OutputFileName"; 1752 # "OutputMPGFileName" => "outputmpgfilename", 1753 # my $OutputFileName = $args{OutputMPGFileName}; 1754 my $OutputFileName = $args{OutputFileName}; 1755 # my $fname = "$directoryName/$OutputFileName"; 1756 my $fname = $args{OutputFileName}; 1757 1758 1759 # setup global variables, signal handlers, etc. 1760 1761 $SIG{ALRM} = \&catch_alarm; 1762 $SIG{INT} = \&catch_alarm; # handle Ctrl-C 1763 1764 # turn off file buffering. 1765 #$|=1; 1766 1767 # open the file for writing. 1768 1769 1770 1771 sysopen(OUTPUT, "$fname", O_CREAT | O_WRONLY | O_LARGEFILE) or die "Error creating file '$fname': $!\n"; 1772 1773 alarm($RecordDuration); 1774 my $buf = ""; 1775 my $len = 0; 1776 while (!$done && read($tuner, $buf, 16384)) 1777 { 1778 $len += length($buf); 1779 # if ($len >= $max_file_size ) 1780 # { 1781 # close(OUTPUT); 1782 # $OutputFileName = get_next_file_name($OutputFileName); 1783 ## $fname = "$directoryName/$OutputFileName"; 1784 # $fname = "$OutputFileName"; 1785 # &writelog("tvrecording switch next clip.$fname"); 1786 # sysopen(OUTPUT, "$fname", O_CREAT | O_WRONLY | O_LARGEFILE) 1787 # or die "Error creating file '$fname': $!\n"; 1788 # $len = 0; 1789 # } 1790 1791 # read from the device and write to the file. 1792 print OUTPUT $buf; 1793 } 1794 1795 # close the file 1796 close(OUTPUT); 1797 1798 #$|=0; # turn file buffering back on. 1799 } 1800 1801 # returns the formatted directory string 1802 sub formatDirectoryString 1803 { 1804 my $temp = $settings{DirectoryFormatString}; 1805 my $result = $settings{OutputDirectory}; 1806 my %lookupTable = ( 1807 "d" => `/bin/date "$settings{DateTimeFormatString}"`, 1808 "I" => $settings{InputName}, 1809 "c" => $settings{Channel}, 1810 ); 1811 1812 # fixup the InputName value 1813 $lookupTable{I} =~ s/\s/_/g; 1814 # cleanup the trailing slash on the date 1815 chomp $lookupTable{d}; 1816 1817 foreach my $option ("d", "I", "c") 1818 { 1819 $temp =~ s/\%$option/$lookupTable{$option}/g; 1820 } 1821 1822 $result .= "/" . ($temp ? "$temp/" : ""); 1823 1824 return $result; 1825 } 1826 1827 1828 1829 1830 344 345 sub callrecordv4l{ 346 347 #$frequency = `ivtv-tune -d $recdevice -t $frequencyTable -c $ivtvrecch | awk '{print $2}'|tr -d .`; 348 my $ivtvtuneftype = ''; 349 if ($frequencyTable eq "ntsc-cable-jp"){ 350 $ivtvtuneftype = 'japan-cable'; 351 }else{ 352 $ivtvtuneftype = 'japan-bcast'; 353 } 354 #print "ivtv-tune -d $recdevice -t $ivtvtuneftype -c $ivtvrecch\n"; 355 &writelog("tvrecording DEBUG ivtv-tune -d $recdevice -t $ivtvtuneftype -c $ivtvrecch"); 356 &writelog("tvrecording DEBUG $ENV{PATH}"); 357 358 $frequency = `env PATH=PATH=/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/bin:/usr/bin:/home/foltia/bin ivtv-tune -d $recdevice -t $ivtvtuneftype -c $ivtvrecch`; 359 &writelog("tvrecording DEBUG frequency:$frequency"); 360 @frequency = split(/\s/,$frequency); 361 $frequency[1] =~ s/\.//gi; 362 $frequency = $frequency[1] ; 363 &writelog("tvrecording DEBUG frequency:$frequency"); 364 365 my $recordv4lcallstring = "$toolpath/perl/record-v4l2.pl --frequency $frequency --duration $reclengthsec --input $recdevice --directory $recfolderpath --inputnum $capturedeviceinputnum --inputname '$capturedeviceinputName' --freqtable $frequencyTable --bitrate $stdbitrate --peakbitrate $peakbitrate --output $outputfilewithoutpath "; 366 367 &writelog("tvrecording $recordv4lcallstring"); 368 &writelog("tvrecording DEBUG $ENV{HOME}/.ivtvrc"); 369 $oserr = `env HOME=$toolpath $recordv4lcallstring`; 370 &writelog("tvrecording DEBUG $oserr"); 371 372 }#end callrecordv4l 373 trunk/install/perl/updatem2pfiletable.pl
r69 r83 34 34 $sth->execute(); 35 35 36 while ($file = glob("$recfolderpath/*.m2 p")) {36 while ($file = glob("$recfolderpath/*.m2?")) { 37 37 $file =~ s/$recfolderpath\///; 38 38 $query = "insert into foltia_m2pfiles values ('$file')"; … … 57 57 $filetid = $fileline[0]; 58 58 $filetid =~ s/[^0-9]//g; 59 60 $query = "insert into foltia_mp4files values ('$filetid','$fileline[2]')";61 $oserr = $dbh->do($query);59 if (($filetid ne "" )&& ($fileline[2] ne "" )){ 60 $query = "insert into foltia_mp4files values ('$filetid','$fileline[2]')"; 61 $oserr = $dbh->do($query); 62 62 #print "$filetid;$fileline[2];$query\n" 63 63 # http://www.atmarkit.co.jp/fnetwork/rensai/sql03/sql1.html 64 65 } 64 }#end if 65 }# end foreach 66 66 $oserr = $dbh->commit; 67 67 trunk/install/php/foltia_config2.php.template
r70 r83 17 17 $recfolderpath = '/home/foltia/php/tv'; //録画ファイルの保存先のパス。 18 18 $httpmediamappath = '/tv'; //ブラウザから見える録画ファイルのある位置。 19 $recunits = '4'; //搭載 エンコーダの数19 $recunits = '4'; //搭載アナログキャプチャカードチャンネル数 20 20 21 21 $protectmode = 0; //未使用:(ブラウザからの予約削除を禁止するなどの保護モードで動作します) … … 24 24 $environmentpolicytoken = "";//環境ポリシーのパスワードに連結されるセキュリティコード 25 25 $perltoolpath = $toolpath ;//perl版の初期設定の位置。デフォルトではphpと同じ位置 26 $usedigital = 1;//Friioなどでデジタル録画をするか 1:する 0:しない 26 27 27 28 // データベース接続設定 trunk/install/php/index.php
r70 r83 13 13 オプション 14 14 mode:"new"を指定すると、新番組(第1話)のみの表示となる。 15 now:YmdHi形式で日付を指定するとその日からの番組表が表示される。 15 16 16 17 DCC-JPL Japan/foltia project … … 32 33 }//end if login 33 34 34 $now = date("YmdHi"); 35 35 $now = getgetnumform(date); 36 if(($now < 200001010000 ) || ($now > 209912342353 )){ 37 $now = date("YmdHi"); 38 } 36 39 function printtitle(){ 37 40 … … 64 67 WHERE foltia_tvrecord.tid = foltia_program.tid 65 68 AND foltia_program.tid = foltia_subtitle.tid 66 AND foltia_subtitle.enddatetime >= '$now' 67 ORDER BY \"startdatetime\" ASC 69 AND foltia_subtitle.enddatetime >= '$now' 70 ORDER BY \"startdatetime\" ASC 71 LIMIT 1000 68 72 "; 69 73 $reservedrssametid = m_query($con, $query, "DBクエリに失敗しました"); … … 112 116 LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) 113 117 WHERE foltia_tvrecord.stationid = 0 AND 114 foltia_subtitle.enddatetime >= '$now' ORDER BY \"startdatetime\" ASC 118 foltia_subtitle.enddatetime >= '$now' ORDER BY \"startdatetime\" ASC 119 LIMIT 1000 115 120 "; 116 121 … … 145 150 WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid 146 151 AND foltia_subtitle.enddatetime >= '$now' AND foltia_subtitle.countno = '1' 147 ORDER BY foltia_subtitle.startdatetime ASC 152 ORDER BY foltia_subtitle.startdatetime ASC 153 LIMIT 1000 148 154 "; 149 155 $rs = m_query($con, $query, "DBクエリに失敗しました"); … … 166 172 WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid 167 173 AND foltia_subtitle.enddatetime >= '$now' 168 ORDER BY foltia_subtitle.startdatetime ASC 174 ORDER BY foltia_subtitle.startdatetime ASC 175 LIMIT 1000 169 176 "; 170 177 $rs = m_query($con, $query, "DBクエリに失敗しました"); trunk/install/php/listreserve.php
r70 r83 46 46 $mymemberid = getmymemberid($con); 47 47 $now = getgetnumform(startdate); 48 *if ($now == ""){ 49 $now = getgetnumform(date); 50 } 48 51 49 52 if ($now > 200501010000){ … … 63 66 foltia_subtitle.startoffset , 64 67 foltia_subtitle.pid , 65 foltia_subtitle.epgaddedby 68 foltia_subtitle.epgaddedby , 69 foltia_tvrecord.digital 66 70 FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord 67 71 WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid … … 79 83 foltia_subtitle.startoffset , 80 84 foltia_subtitle.pid , 81 foltia_subtitle.epgaddedby 85 foltia_subtitle.epgaddedby , 86 foltia_tvrecord.digital 82 87 FROM foltia_tvrecord 83 88 LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) … … 127 132 <th align="left">話数</th> 128 133 <th align="left">サブタイトル</th> 129 <th align="left">開始時刻 </th>134 <th align="left">開始時刻(ズレ)</th> 130 135 <th align="left">総尺</th> 131 136 <th align="left">画質</th> 137 <th align="left">デジタル優先</th> 132 138 133 139 </tr> … … 165 171 foltia_tvrecord.bitrate , 166 172 foltia_subtitle.startoffset , 167 foltia_subtitle.pid 173 foltia_subtitle.pid , 174 foltia_tvrecord.digital 168 175 FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord 169 176 WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid … … 181 188 foltia_tvrecord.bitrate , 182 189 foltia_subtitle.startoffset , 183 foltia_subtitle.pid 190 foltia_subtitle.pid , 191 foltia_tvrecord.digital 184 192 FROM foltia_tvrecord 185 193 LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) … … 218 226 foltia_tvrecord.bitrate , 219 227 foltia_subtitle.startoffset , 220 foltia_subtitle.pid 228 foltia_subtitle.pid , 229 foltia_tvrecord.digital 221 230 FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord 222 231 WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid … … 235 244 foltia_tvrecord.bitrate , 236 245 foltia_subtitle.startoffset , 237 foltia_subtitle.pid 246 foltia_subtitle.pid , 247 foltia_tvrecord.digital 238 248 FROM foltia_tvrecord 239 249 LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) … … 277 287 }else{ 278 288 print "<a href=\"http://cal.syoboi.jp/tid/$tid\" target=\"_blank\">$title</a>"; 289 279 290 } 280 291 print "</td>\n"; … … 305 316 //録画レート 306 317 echo("<td>".htmlspecialchars($rowdata[7])."<br></td>\n"); 318 319 //デジタル優先 320 echo("<td>"); 321 if (htmlspecialchars($rowdata[11]) == 1){ 322 print "する"; 323 }else{ 324 print "しない"; 325 } 326 echo("<br></td>\n"); 307 327 echo("</tr>\n"); 308 328 } … … 313 333 314 334 <table> 335 <tr><td>アナログ重複表示</td><td><br /></td></tr> 315 336 <tr><td>エンコーダ数</td><td><?=$recunits ?></td></tr> 316 337 <tr class="overwraped"><td>チューナー重複</td><td><br /></td></tr> … … 329 350 foltia_program .title , 330 351 foltia_tvrecord.bitrate , 331 foltia_tvrecord.stationid 352 foltia_tvrecord.stationid , 353 foltia_tvrecord.digital 332 354 FROM foltia_tvrecord , foltia_program , foltia_station 333 WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid 355 WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid 334 356 ORDER BY foltia_program.tid DESC 335 357 "; … … 354 376 <th align="left">録画リスト</th> 355 377 <th align="left">画質</th> 378 <th align="left">デジタル優先</th> 379 356 380 </tr> 357 381 </thead> … … 385 409 //MP4 386 410 echo("<td><a href=\"showlibc.php?tid=$tid\">mp4</a></td>\n"); 387 411 //画質(アナログビットレート) 388 412 echo("<td>".htmlspecialchars($rowdata[3])."<br></td>\n"); 389 413 //デジタル優先 414 echo("<td>"); 415 if (htmlspecialchars($rowdata[5]) == 1){ 416 print "する"; 417 }else{ 418 print "しない"; 419 } 390 420 echo("</tr>\n"); 391 421 }else{ … … 395 425 <td>EPG録画</td> 396 426 <td><a href=\"showlibc.php?tid=0\">mp4</a></td>"; 397 echo("<td>".htmlspecialchars($rowdata[3])."<br></td>\n</tr>"); 427 echo("<td>".htmlspecialchars($rowdata[3])."<br></td>"); 428 //デジタル優先 429 echo("<td>"); 430 if (htmlspecialchars($rowdata[5]) == 1){ 431 print "する"; 432 }else{ 433 print "しない"; 434 } 435 echo("\n</tr>"); 398 436 }//if tid 0 399 437 }//for trunk/install/php/m.php
r77 r83 35 35 36 36 $now = date("YmdHi"); 37 $today = date("Ymd"); 38 $nowdate = date("Hi",(mktime(date("G"),date("i")+8,date("s"),date("m"),date("d"),date("Y")))); 37 39 $errflag = 0; 38 40 $pname = "手動録画"; … … 74 76 $recstid = getgetnumform(recstid); 75 77 $pname = getgetform(pname); 78 //$usedigital = getgetnumform(usedigital); 79 76 80 //確認 77 81 $startdatetime = "$startdate"."$starttime"; … … 105 109 } 106 110 } 111 //デジタル優先 112 /*if ($usedigital == 1){ 113 }else{ 114 $usedigital = 0; 115 } 116 */ 107 117 //正しければ 108 118 if ($errflag == 0){ … … 193 203 <p>放送日: 194 204 <input name="startdate" type="text" id="startdate" size="9" value="<?=$startdate?>" /> 195 年月日 Ex. 19800121</p>205 年月日 Ex.<?=$today?></p> 196 206 <p>録画開始時刻: 197 207 <input name="starttime" type="text" id="starttime" size="5" value="<?=$starttime?>" /> 198 時分 Ex. 2304</p>208 時分 Ex.<?=$nowdate?> </p> 199 209 <p> 200 210 録画尺: … … 205 215 <?php 206 216 $query = " 207 SELECT stationid,stationname,stationrecch 217 SELECT stationid,stationname,stationrecch ,digitalch 208 218 FROM foltia_station 209 219 WHERE stationrecch > 0 220 UNION 221 SELECT DISTINCT stationid,stationname,stationrecch ,digitalch 222 FROM foltia_station 223 WHERE digitalch > 0 210 224 ORDER BY \"stationid\" ASC"; 211 225 … … 248 262 } 249 263 } 250 264 /* 265 print "<p>デジタル録画を優先:"; 266 267 if ($usedigital == 1){ 268 print "<input name="useditial" type="radio" value="1" selected /> する 269 <input name="useditial" type="radio" value="0" /> しない 270 "; 271 }else{ 272 print "<input name="useditial" type="radio" value="1" /> する 273 <input name="useditial" type="radio" value="0" selected /> しない 274 "; 275 } 276 */ 251 277 ?> 252 278 <p>番組名: trunk/install/php/reservecomp.php
r70 r83 54 54 $station = 0; 55 55 } 56 56 $usedigital = getgetnumform(usedigital); 57 if ($usedigital == "") { 58 $usedigital = 0; 59 } 57 60 $bitrate = getgetnumform(bitrate); 58 61 if ($bitrate == "") { … … 202 205 203 206 if ($maxrows == 0) { //新規追加 204 $query = "INSERT INTO foltia_tvrecord values ('$tid','$station','$bitrate' )";207 $query = "INSERT INTO foltia_tvrecord values ('$tid','$station','$bitrate','$usedigital')"; 205 208 $rs = m_query($con, $query, "DB書き込みに失敗しました"); 206 209 }else{//修正 (ビットレート) 207 210 $query = "UPDATE foltia_tvrecord SET 208 bitrate = '$bitrate' WHERE tid = '$tid' AND stationid = '$station' 209 "; 211 bitrate = '$bitrate' , digital = '$usedigital' WHERE tid = '$tid' AND stationid = '$station' "; 210 212 $rs = m_query($con, $query, "DB書き込みに失敗しました"); 211 213 } trunk/install/php/reserveepgcomp.php
r70 r83 78 78 }else{ 79 79 $rowdata = pg_fetch_row($rs, 0); 80 80 81 $insertpid = $rowdata[0]; 81 $insertpid-- ; 82 if ($insertpid > 0){ 83 $insertpid = -1; 84 }else{ 85 $insertpid-- ; 86 } 82 87 } 83 88 // next 話数を探す … … 121 126 values ( '$insertpid','0','$stationid', 122 127 '$nextcno','$subtitle','$startdatetime','$enddatetime','0' ,'$lengthmin' , '$memberid')"; 123 124 128 $rs = m_query($con, $query, "DBクエリに失敗しました"); 125 129 … … 143 147 } 144 148 145 ?>146 149 147 148 <?php149 150 print "<table width=\"100%\" border=\"0\"> 150 151 <tr><td>放送開始</td><td>$startdatetime</td></tr> trunk/install/php/reserveprogram.php
r70 r83 89 89 <tr> 90 90 <td>放送局</td> 91 <td>ビットレート</td> 91 <td>デジタル録画優先</td> 92 <td>アナログビットレート</td> 92 93 </tr> 93 94 <tr> … … 128 129 129 130 </td> 131 132 <td> 133 <select name="usedigital"> 134 <?php 135 if ($usedigital == 1){ 136 print " 137 <option value=\"1\" selected>する</option> 138 <option value=\"0\">しない</option> 139 "; 140 }else{ 141 print " 142 <option value=\"1\">する</option> 143 <option value=\"0\" selected>しない</option> 144 "; 145 } 146 ?> 147 </select> 148 </td> 149 130 150 <td><select name="bitrate"> 131 151 <option value="14">最高画質</option> trunk/install/php/selectcaptureimage.php
r70 r83 116 116 $tid = ereg_replace("[^0-9]", "", $tid); 117 117 118 $path = ereg_replace("\.m2p$ ", "", $m2pfilename);118 $path = ereg_replace("\.m2p$|\.m2t$", "", $m2pfilename); 119 119 $serveruri = getserverfqdn (); 120 120 … … 124 124 125 125 if (file_exists("./sb-edit.php") ) { 126 print "<a href=\"./sb-edit.php?pid=$pid&f=$filetid\"><img src='http://$serveruri$httpmediamappath/$tid.localized/img/$path/$filetid' width='160' height='120'alt='$tid:$countno:$filetid'></a>\n";126 print "<a href=\"./sb-edit.php?pid=$pid&f=$filetid\"><img src='http://$serveruri$httpmediamappath/$tid.localized/img/$path/$filetid' alt='$tid:$countno:$filetid'></a>\n"; 127 127 }else{ 128 print "<img src='http://$serveruri$httpmediamappath/$tid.localized/img/$path/$filetid' width='160' height='120'alt='$tid:$countno:$filetid'>\n";128 print "<img src='http://$serveruri$httpmediamappath/$tid.localized/img/$path/$filetid' alt='$tid:$countno:$filetid'>\n"; 129 129 } 130 130 }//foreach trunk/install/php/showlib.php
r70 r83 36 36 <head> 37 37 <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP"> 38 <meta http-equiv="Content-Style-Type" content="text/css"> 39 <link rel="stylesheet" type="text/css" href="graytable.css"> 40 <link rel="alternate" type="application/rss+xml" title="RSS" href="./folcast.php" /> 38 <?php 39 if (file_exists ( "./iui/iui.css" )){ 40 $useragent = $_SERVER['HTTP_USER_AGENT']; 41 } 42 if(ereg("iPhone",$useragent)){ 43 print "<meta name=\"viewport\" content=\"width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;\"/> 44 <link rel=\"apple-touch-icon\" type=\"image/png\" href=\"./img/icon.png\" /> 45 46 <style type=\"text/css\" media=\"screen\">@import \"./iui/iui.css\";</style> 47 <script type=\"application/x-javascript\" src=\"./iui/iui.js\"></script>"; 48 }else{ 49 print "<meta http-equiv=\"Content-Style-Type\" content=\"text/css\"> 50 <link rel=\"stylesheet\" type=\"text/css\" href=\"graytable.css\"> 51 <link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"./folcast.php\" />"; 52 } 53 ?> 41 54 <title>foltia:MP4 Lib</title> 42 55 </head> 43 56 44 57 <?php 45 $now = date("YmdHi"); 58 $now = date("YmdHi"); 59 if(ereg("iPhone",$useragent)){ 60 print "<body onclick=\"console.log('Hello', event.target);\"> 61 <div class=\"toolbar\"> 62 <h1 id=\"pageTitle\"></h1> 63 <a id=\"backButton\" class=\"button\" href=\"#\"></a> 64 </div> 65 "; 66 }else{ 67 print "<body BGCOLOR=\"#ffffff\" TEXT=\"#494949\" LINK=\"#0047ff\" VLINK=\"#000000\" ALINK=\"#c6edff\" > 68 <div align=\"center\"> 69 "; 70 printhtmlpageheader(); 71 print " <p align=\"left\"><font color=\"#494949\" size=\"6\">録画ライブラリ表示</font></p> 72 <hr size=\"4\"> 73 <p align=\"left\">再生可能ライブラリを表示します。<br> 74 "; 75 } 46 76 47 ?>48 <body BGCOLOR="#ffffff" TEXT="#494949" LINK="#0047ff" VLINK="#000000" ALINK="#c6edff" >49 <div align="center">50 <?php51 printhtmlpageheader();52 ?>53 <p align="left"><font color="#494949" size="6">録画ライブラリ表示</font></p>54 <hr size="4">55 <p align="left">再生可能ライブラリを表示します。<br>56 57 <?58 77 //新仕様 /* 2006/10/26 */ 59 78 $query = " … … 70 89 71 90 if ($maxrows > 0 ){ 91 if(ereg("iPhone",$useragent)){ 92 print "<ul id=\"home\" title=\"録画ライブラリ表示\" selected=\"true\">"; 93 }else{ 72 94 print " 73 95 <table BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"2\" WIDTH=\"100%\"> … … 82 104 <tbody> 83 105 "; 106 } 84 107 for ($row = 0; $row < $maxrows; $row++) { 85 108 $rowdata = pg_fetch_row($rs, $row); … … 90 113 $counts = htmlspecialchars($counts); 91 114 115 if(ereg("iPhone",$useragent)){ 116 print "<li><a href=\"showlibc.php?tid=$tid\" target=\"_self\">$title</a></li>\n"; 117 }else{ 92 118 print " 93 119 <tr> … … 98 124 </tr>\n 99 125 "; 126 } 100 127 }//for 128 129 if(ereg("iPhone",$useragent)){ 130 print "</ul>\n</body>\n</html>\n"; 131 }else{ 101 132 print " 102 133 </tbody> … … 105 136 </html> 106 137 "; 138 } 139 107 140 }else{ 108 141 print "録画ファイルが存在しません。</body></html>"; trunk/install/php/showlibc.php
r74 r83 41 41 <head> 42 42 <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP"> 43 <meta http-equiv="Content-Style-Type" content="text/css">44 <link rel="stylesheet" type="text/css" href="graytable.css">45 <script src="http://images.apple.com/main/js/ac_quicktime.js" language="JavaScript" type="text/javascript"></script>46 43 <?php 47 print "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"./folcast.php?tid=$tid\" /> 48 "; 49 if ($tid == "") { 44 if (file_exists ( "./iui/iui.css" )){ 45 $useragent = $_SERVER['HTTP_USER_AGENT']; 46 } 47 if(ereg("iPhone",$useragent)){ 48 print "<meta name=\"viewport\" content=\"width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;\"/> 49 <link rel=\"apple-touch-icon\" type=\"image/png\" href=\"./img/icon.png\" /> 50 <style type=\"text/css\" media=\"screen\">@import \"./iui/iui.css\";</style> 51 <script type=\"application/x-javascript\" src=\"./iui/iui.js\"></script>"; 52 }else{ 53 print "<meta http-equiv=\"Content-Style-Type\" content=\"text/css\"> 54 <link rel=\"stylesheet\" type=\"text/css\" href=\"graytable.css\"> 55 <script src=\"http://images.apple.com/main/js/ac_quicktime.js\" language=\"JavaScript\" type=\"text/javascript\"></script> 56 <link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"./folcast.php?tid=$tid\" /> 57 "; 58 } 59 if ($tid == "") { 50 60 print "<title>foltia:Lib</title> 51 61 </head><body BGCOLOR=\"#ffffff\" TEXT=\"#494949\" LINK=\"#0047ff\" VLINK=\"#000000\" ALINK=\"#c6edff\" > \n"; 52 62 printhtmlpageheader(); 53 63 die_exit("再生可能番組がありません<BR>"); 54 64 } 55 65 $now = date("YmdHi"); 56 66 … … 75 85 } 76 86 //ヘッダ続き 77 print "<title>foltia:Lib $tid:$title</title> 78 </head> 79 <body BGCOLOR=\"#ffffff\" TEXT=\"#494949\" LINK=\"#0047ff\" VLINK=\"#000000\" ALINK=\"#c6edff\" > 87 print "<title>foltia:Lib $tid:$title</title></head>"; 88 $serveruri = getserveruri(); 89 90 if(ereg("iPhone",$useragent)){ 91 print "<body onclick=\"console.log('Hello', event.target);\"> 92 <div class=\"toolbar\"> 93 <h1 id=\"pageTitle\"></h1> 94 <a id=\"backButton\" class=\"button\" href=\"#\"></a> 95 </div> 96 "; 97 }else{ 98 99 print "<body BGCOLOR=\"#ffffff\" TEXT=\"#494949\" LINK=\"#0047ff\" VLINK=\"#000000\" ALINK=\"#c6edff\" > 80 100 <div align=\"center\"> 81 101 "; … … 84 104 <hr size=\"4\"> 85 105 <p align=\"left\">再生可能ムービーを表示します。<br>"; 86 87 $serveruri = getserveruri();88 106 if ($tid == 0){ 89 107 print "$title 【<A HREF = \"./folcast.php?tid=$tid\">この番組のFolcast</A> [<a href=\"itpc://$serveruri/folcast.php?tid=$tid\">iTunesに登録</a>】 <br>\n"; … … 93 111 htmlspecialchars($tid) . "\" target=\"_blank\">$title</a> 【<A HREF = \"./folcast.php?tid=$tid\">この番組のFolcast</A> [<a href=\"itpc://$serveruri/folcast.php?tid=$tid\">iTunesに登録</a>]】 <br>\n"; 94 112 } 113 }// endif if(ereg("iPhone",$useragent)) 114 95 115 //確認 96 116 if (file_exists ("$recfolderpath/$tid.localized")){ … … 101 121 exit; 102 122 } 103 104 105 123 106 124 //新仕様/* 2006/10/26 */ … … 133 151 $maxrows = pg_num_rows($rs); 134 152 if ($maxrows > 0 ){ 153 if(ereg("iPhone",$useragent)){ 154 print "<ul id=\"home\" title=\"$title\" selected=\"true\">"; 155 }else{ 135 156 print " 136 157 <table BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"2\" WIDTH=\"100%\"> 137 158 <tbody> 138 159 "; 139 160 } 140 161 for ($row = 0; $row < $maxrows; $row++) { 141 162 $rowdata = pg_fetch_row($rs, $row); … … 178 199 179 200 if (($sbpluginexist == 1) && (pg_num_rows ($rs ) > 0)){ 180 $capimgpath = htmlspecialchars(preg_replace("/.m2p/", "", $rowdata[5])); 201 //$capimgpath = htmlspecialchars(preg_replace("/.m2p/", "", $rowdata[5])); 202 $capimgpath = htmlspecialchars(preg_replace("/.m2./", "", $rowdata[5])); 181 203 182 204 if (($capimgpath != "") && (file_exists("$recfolderpath/$tid.localized/img/$capimgpath") )){ … … 195 217 } 196 218 197 219 if(ereg("iPhone",$useragent)){ 220 221 print "<li><a href=\"http://$serverfqdn/$httpmediamappath/$tid.localized/mp4/$fName\" target=\"_self\">$count $subtitle $onairdate</a></li>\n"; 222 223 }else{ 198 224 print " <tr> 199 225 <td rowspan=\"4\" width=\"170\"><a href = \"$httpmediamappath/$tid.localized/mp4/$fName\" target=\"_blank\"><img src = \"$imgsrcuri\" width=\"160\" height=\"120\"></a></td> … … 202 228 <tr> 203 229 "; 204 if ($tid == 0){205 print "\n <td>$subtitle</td>";206 }else{207 print "\n <td><a href = \"http://cal.syoboi.jp/tid/$tid/time#$pid\" target=\"_blank\">$subtitle</a></td>";208 }//if230 if ($tid == 0){ 231 print "\n <td>$subtitle</td>"; 232 }else{ 233 print "\n <td><a href = \"http://cal.syoboi.jp/tid/$tid/time#$pid\" target=\"_blank\">$subtitle</a></td>"; 234 }//if 209 235 print " </tr> 210 236 <tr> … … 216 242 "; 217 243 244 }//endif iPhone 245 218 246 }//for 219 247 }else{ 220 248 print "録画ファイルがありません<br>\n"; 221 249 }//if 250 251 if(ereg("iPhone",$useragent)){ 252 print "<li><a href=\"http://$serveruri/showlib.php\" target=\"_self\">一覧へ戻る</a></li>\n"; 253 print "</ul>\n"; 254 }else{ 255 print "</tbody></table>\n"; 256 } 222 257 ?> 223 </tbody>224 </table>225 226 258 </body> 227 259 </html> 260 261 trunk/install/php/showplaylist.php
r70 r83 14 14 省略時、録画順にソートされる。 15 15 titleのときに、番組順ソートされる。 16 rawのときに、DBに記録されている番組録画情報ではなくディレクトリにあるm2p ファイルを全て表示する。16 rawのときに、DBに記録されている番組録画情報ではなくディレクトリにあるm2p/m2tファイルを全て表示する。 17 17 18 18 DCC-JPL Japan/foltia project … … 97 97 //旧仕様 98 98 if($list == "raw"){ 99 exec ("ls -t $recfolderpath/*.m2 p", $m2pfiles);99 exec ("ls -t $recfolderpath/*.m2?", $m2pfiles); 100 100 101 101 … … 106 106 107 107 if(($fName == ".") or ($fName == "..") ){ continue; } 108 if (ereg(".m2 p", $fName)){108 if (ereg(".m2.+", $fName)){ 109 109 $filesplit = split("-",$fName); 110 110 … … 230 230 } 231 231 if (file_exists("./selectcaptureimage.php") ) { 232 $capimgpath = preg_replace("/.m2 p/", "", $fName);232 $capimgpath = preg_replace("/.m2.+/", "", $fName); 233 233 print " <td align=\"left\"><a href=\"./selectcaptureimage.php?pid=$pid\">キャプ</a></td>\n"; 234 234 }