Changeset 26948 for gs2-extensions/video-and-audio/trunk
- Timestamp:
- 2013-02-26T10:41:13+13:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/video-and-audio/trunk/src/perllib/plugins/SimpleVideoPlugin.pm
r25842 r26948 90 90 {'name' => "false", 'desc' => "{common.false}"}], 91 91 'deft' => "false", 92 'reqd' => "no" } 92 'reqd' => "no" }, 93 { 'name' => "fixedCore", 94 'desc' => "Restrict the execution of Handbrake to a single core (0 = no restriction, > 0 use value-1'th core)", 95 'type' => "int", 96 'deft' => "0", 97 'reqd' => "no" }, 93 98 ]; 94 99 … … 135 140 136 141 137 $file =~ /[\/]?( .+)\.(?:ts)$/;142 $file =~ /[\/]?([^\/]+)\.(?:ts)$/; 138 143 my $filename = $1; 139 140 144 141 145 # Optional date metadata (available on raw ReplayMe recordings) … … 148 152 } 149 153 154 # Special Case: HDFS *only* supported by separateIO flag (you need to move 155 # the file out of HDFS to local filespace to allow MediaInfo and Handbrake 156 # to be run on it. 157 my $separate_io = $self->{'separateIO'}; 158 if (&util::isHDFS($file)) 159 { 160 $separate_io = 'true'; 161 } 162 150 163 my $process_dir = $ENV{'GSDLCOLLECTDIR'}; 151 164 # If we are in a cluster, then we don't want to be writing all the logs 152 165 # etc to the shared file system. Instead, we write to the tmp drive 153 my $separate_io = $self->{'separateIO'}; 154 if ($separate_io) 166 if ($separate_io eq 'true') 155 167 { 156 168 $process_dir = &util::filename_cat('/tmp', 'gsimport-' . $filename); 157 if (! -d $process_dir)169 if (!&util::dir_exists($process_dir)) 158 170 { 159 171 mkdir($process_dir, 0775); … … 161 173 } 162 174 my $logs_dir = &util::filename_cat($process_dir, "logs"); 163 if (! -d $logs_dir)175 if (!&util::dir_exists($logs_dir)) 164 176 { 165 177 mkdir($logs_dir, 0775); … … 168 180 my $pass_log_path = &util::filename_cat($logs_dir, 'convert-' . $filename . '-pass'); 169 181 my $tmp_dir = &util::filename_cat($process_dir, "cached"); 170 if (! -d $tmp_dir)182 if (!&util::dir_exists($tmp_dir)) 171 183 { 172 184 mkdir($tmp_dir, 0775); 173 185 } 174 186 $tmp_dir = &util::filename_cat($tmp_dir, $filename); 175 if (! -d $tmp_dir)187 if (!&util::dir_exists($tmp_dir)) 176 188 { 177 189 mkdir($tmp_dir, 0775); … … 181 193 # the process directory (local tmp) as well 182 194 my $ivideo_path = &util::filename_cat($base_dir, $file); 183 if ($separate_io )195 if ($separate_io eq 'true') 184 196 { 185 197 print STDERR "[B1:" . time() . "] Creating local copy of file\n"; 186 my $local_ivideo_path = &util::filename_cat($process_dir, $file); 187 my $copy_cmd = 'cp "' . $ivideo_path . '" "' . $local_ivideo_path . '"'; 188 `$copy_cmd`; 198 my $local_ivideo_path = &util::filename_cat($process_dir, $filename . ".ts"); 199 &util::cp($ivideo_path, $local_ivideo_path); 189 200 $ivideo_path = $local_ivideo_path; 190 201 print STDERR "[B2:" . time() . "] Complete\n"; … … 214 225 print STDERR "[D1:" . time() . "] Converting video to streamble format\n"; 215 226 my $ovideo_path = &util::filename_cat($tmp_dir, 'gsv.mp4'); 216 if ( -f $ovideo_path)227 if (&util::file_exists($ovideo_path)) 217 228 { 218 229 print " - Found existing converted video in cache\n"; … … 249 260 # causing all other threads to wait anyway). It will interesting to test 250 261 # whether parallel processing or serial processing (with HandBrake parallel 251 # processing) is faster. 252 if ($is_parallel && !$is_cluster) 262 # processing) is faster. *update* threads=1 *only* controls the encoding and 263 # several other parts of Handbrake can run parallel (demuxing etc). I've 264 # had to include a 'taskset' command to truely make Handbrake serial 265 if ($is_parallel eq 'true' && $is_cluster eq 'false') 253 266 { 254 267 $mencoder_options .= ':threads=1'; 255 268 } 256 my $cmd = 'HandBrakeCLI -i "' . $ivideo_path . '" -t 1 -c 1 -f mp4 -O -o "' . $ovideo_path . '" ' . $video_processing_parameters . ' -e x264 -b ' . $streaming_HQ_VideoBitrate . ' -a 1 -E faac -6 dpl2 -R Auto -B ' . $streaming_HQ_AudioBitrate . ' -D 0.0 -x ' . $mencoder_options . ' > "' . $convert_log_path . '" 2>&1'; 269 # Banish HandbrakeCLI to the (fixedCore-1)'th CPU if necessary 270 my $cmd = ''; 271 if (defined $self->{'fixedCore'} && $self->{'fixedCore'} > 0) 272 { 273 $cmd .= 'taskset -c ' . ($self->{'fixedCore'} - 1) . ' '; 274 } 275 $cmd .= 'HandBrakeCLI -i "' . $ivideo_path . '" -t 1 -c 1 -f mp4 -O -o "' . $ovideo_path . '" ' . $video_processing_parameters . ' -e x264 -b ' . $streaming_HQ_VideoBitrate . ' -a 1 -E faac -6 dpl2 -R Auto -B ' . $streaming_HQ_AudioBitrate . ' -D 0.0 -x ' . $mencoder_options . ' > "' . $convert_log_path . '" 2>&1'; 257 276 print "[DEBUG: " . $cmd . "]\n"; 258 277 `$cmd`; 259 278 } 260 if (! -f $ovideo_path)279 if (!&util::file_exists($ovideo_path)) 261 280 { 262 281 die("Fatal Error! Failed to convert video: " . $ovideo_path . "\nReason:" . $! . "\n"); … … 267 286 print STDERR "[E1:" . time() . "] Extract keyframes\n"; 268 287 my $oshots_path = &util::filename_cat($tmp_dir, 'shots.xml'); 269 if ( -f $oshots_path)288 if (&util::file_exists($oshots_path)) 270 289 { 271 290 print " - Found existing keyframe images in cache\n"; … … 278 297 `$cmd`; 279 298 } 280 if (! -f $oshots_path)299 if (!&util::file_exists($oshots_path)) 281 300 { 282 301 die("Fatal Error! Failed to extract keyframe images: " . $oshots_path . "\nReason:" . $! . "\n");
Note:
See TracChangeset
for help on using the changeset viewer.