Changeset 27527
- Timestamp:
- 2013-06-04T09:45:11+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/video-and-audio/trunk/src/perllib/plugins/SimpleVideoPlugin.pm
r27426 r27527 33 33 use MetadataRead; 34 34 use util; 35 use FileUtils; 35 36 36 37 use strict; … … 156 157 # to be run on it. 157 158 my $separate_io = $self->{'separateIO'}; 158 if (& util::isHDFS($file))159 if (&FileUtils::isHDFS($file)) 159 160 { 160 161 $separate_io = 'true'; … … 166 167 if ($separate_io eq 'true') 167 168 { 168 $process_dir = & util::filename_cat('/tmp', 'gsimport-' . $filename);169 if (!& util::dir_exists($process_dir))169 $process_dir = &FileUtils::filenameConcatenate('/tmp', 'gsimport-' . $filename); 170 if (!&FileUtils::directoryExists($process_dir)) 170 171 { 171 172 mkdir($process_dir, 0775); 172 173 } 173 174 } 174 my $logs_dir = & util::filename_cat($process_dir, "logs");175 if (!& util::dir_exists($logs_dir))175 my $logs_dir = &FileUtils::filenameConcatenate($process_dir, "logs"); 176 if (!&FileUtils::directoryExists($logs_dir)) 176 177 { 177 178 mkdir($logs_dir, 0775); 178 179 } 179 my $convert_log_path = & util::filename_cat($logs_dir, 'convert-' . $filename . '.log');180 my $pass_log_path = & util::filename_cat($logs_dir, 'convert-' . $filename . '-pass');181 my $tmp_dir = & util::filename_cat($process_dir, "cached");182 if (!& util::dir_exists($tmp_dir))180 my $convert_log_path = &FileUtils::filenameConcatenate($logs_dir, 'convert-' . $filename . '.log'); 181 my $pass_log_path = &FileUtils::filenameConcatenate($logs_dir, 'convert-' . $filename . '-pass'); 182 my $tmp_dir = &FileUtils::filenameConcatenate($process_dir, "cached"); 183 if (!&FileUtils::directoryExists($tmp_dir)) 183 184 { 184 185 mkdir($tmp_dir, 0775); 185 186 } 186 $tmp_dir = & util::filename_cat($tmp_dir, $filename);187 if (!& util::dir_exists($tmp_dir))187 $tmp_dir = &FileUtils::filenameConcatenate($tmp_dir, $filename); 188 if (!&FileUtils::directoryExists($tmp_dir)) 188 189 { 189 190 mkdir($tmp_dir, 0775); … … 192 193 # If we are separating IO, then we also start by copying the file to 193 194 # the process directory (local tmp) as well 194 my $ivideo_path = &util::filename_cat($base_dir, $file); 195 my $ivideo_path = $file; 196 if (!&FileUtils::isFilenameAbsolute($file) && $base_dir ne '') 197 { 198 $ivideo_path = &FileUtils::filenameConcatenate($base_dir, $file); 199 } 195 200 if ($separate_io eq 'true') 196 201 { 197 print STDERR "[B1:" . time() . "] Creating local copy of file \n";198 my $local_ivideo_path = & util::filename_cat($process_dir, $filename . ".ts");199 & util::cp($ivideo_path, $local_ivideo_path);202 print STDERR "[B1:" . time() . "] Creating local copy of file: " . $ivideo_path . "\n"; 203 my $local_ivideo_path = &FileUtils::filenameConcatenate($process_dir, $filename . ".ts"); 204 &FileUtils::copyFiles($ivideo_path, $local_ivideo_path); 200 205 $ivideo_path = $local_ivideo_path; 201 206 print STDERR "[B2:" . time() . "] Complete\n"; … … 224 229 # - generate a path for our temporary converted video file 225 230 print STDERR "[D1:" . time() . "] Converting video to streamble format\n"; 226 my $ovideo_path = & util::filename_cat($tmp_dir, 'gsv.mp4');227 if (& util::file_exists($ovideo_path))231 my $ovideo_path = &FileUtils::filenameConcatenate($tmp_dir, 'gsv.mp4'); 232 if (&FileUtils::fileExists($ovideo_path)) 228 233 { 229 234 print " - Found existing converted video in cache\n"; … … 281 286 `$cmd`; 282 287 } 283 while ($attempt_count < 5 && !& util::file_exists($ovideo_path))284 } 285 if (!& util::file_exists($ovideo_path))288 while ($attempt_count < 5 && !&FileUtils::fileExists($ovideo_path)) 289 } 290 if (!&FileUtils::fileExists($ovideo_path)) 286 291 { 287 292 die("Fatal Error! Failed to convert video: " . $ovideo_path . "\nReason:" . $! . "\n"); … … 291 296 # 3. Extract keyframes using hive 292 297 print STDERR "[E1:" . time() . "] Extract keyframes\n"; 293 my $oshots_path = & util::filename_cat($tmp_dir, 'shots.xml');294 if (& util::file_exists($oshots_path))298 my $oshots_path = &FileUtils::filenameConcatenate($tmp_dir, 'shots.xml'); 299 if (&FileUtils::fileExists($oshots_path)) 295 300 { 296 301 print " - Found existing keyframe images in cache\n"; … … 303 308 `$cmd`; 304 309 } 305 if (!& util::file_exists($oshots_path))310 if (!&FileUtils::fileExists($oshots_path)) 306 311 { 307 312 die("Fatal Error! Failed to extract keyframe images: " . $oshots_path . "\nReason:" . $! . "\n"); … … 321 326 foreach my $shot (sort @shots) 322 327 { 323 my $shot_path = & util::filename_cat($tmp_dir, $shot);328 my $shot_path = &FileUtils::filenameConcatenate($tmp_dir, $shot); 324 329 if ($shot =~ /.jpg$/) 325 330 {
Note:
See TracChangeset
for help on using the changeset viewer.