Changeset 22432
- Timestamp:
- 2010-07-19T14:00:53+12:00 (14 years ago)
- Location:
- gs2-extensions/video/trunk/perllib/plugins
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/video/trunk/perllib/plugins/VideoConverter.pm
r21824 r22432 208 208 # Here we use mediaInfo to get all the possible metadata in XML form that could then be parsed 209 209 #the result will vary depending on the file type and how it was encoded 210 sub mediaInfo_XML_Cmd 211 212 213 210 sub mediaInfo_XML_Cmd { 211 my ($video, $outhandle, $verbosity) = @_; 212 213 # Use MediaInfo CLI to get the file spec according to the requested parameter 214 214 my $command = "mediainfo --Output=XML \"$video\""; 215 215 216 216 print $outhandle " $command\n" if ($verbosity > 2); 217 217 my $result = ''; 218 218 $result = `$command 2>&1`; 219 219 print $outhandle " $result\n" if ($verbosity > 4); 220 220 221 221 # Return the asked spec 222 222 return ($result); … … 224 224 225 225 #Here we parse the video specs contained in the XML text in order to create a metadata entry for each field 226 sub mediaInfo_parse_XML { 227 my ($xmlTxt, $outhandle, $verbosity) = @_; 228 229 my @parts = split(/<track\s+type=\"(.*?)\">/is,$xmlTxt); 230 231 shift @parts; # Skip preamble 232 my $metadata_table = {}; 233 234 while (@parts) { 235 my $type = shift(@parts); 236 my $vals = shift(@parts); 237 my @fieldlist=(); 238 while ($vals =~ s/<(.*?)>(.*?)<\/\1>//) { 239 my $metaname = $1; 240 my $metaval = $2; 241 my $fullmetaname = "mi.$type\^$metaname"; 242 $metadata_table->{$fullmetaname}= $metaval; 243 push(@fieldlist,$fullmetaname); 244 } 245 246 $metadata_table->{"mi.${type}Fields"}= join(",",@fieldlist); 247 226 sub mediaInfo_parse_XML { 227 my ($xmlTxt, $outhandle, $verbosity) = @_; 228 229 my @parts = split(/<track\s+type=\"(.*?)\">/is,$xmlTxt); 230 231 shift @parts; # Skip preamble 232 my $metadata_table = {}; 233 234 while (@parts) { 235 my $type = shift(@parts); 236 my $vals = shift(@parts); 237 my @fieldlist=(); 238 while ($vals =~ s/<(.*?)>(.*?)<\/\1>//) { 239 my $metaname = $1; 240 my $metaval = $2; 241 my $fullmetaname = "mi.$type\^$metaname"; 242 $metadata_table->{$fullmetaname}= $metaval; 243 push(@fieldlist,$fullmetaname); 248 244 } 249 245 250 return $metadata_table; 251 252 } 253 254 sub identify { 246 $metadata_table->{"mi.${type}Fields"}= join(",",@fieldlist); 247 248 } 249 250 return $metadata_table; 251 252 } 253 254 sub identifyMI { 255 255 my ($video, $outhandle, $verbosity) = @_; 256 256 … … 291 291 292 292 293 sub identify 2{293 sub identify { 294 294 my ($video, $outhandle, $verbosity) = @_; 295 295 … … 1001 1001 1002 1002 1003 my $ifilename = $originalfilename || $filename; 1004 1003 1005 my ($stream_cmd,$ofla_filename,$ofla_file) 1004 = $self->stream_flv_audio_cmd($ originalfilename || $filename);1006 = $self->stream_flv_audio_cmd($ifilename); 1005 1007 1006 1008 … … 1011 1013 1012 1014 my ($streamable_regenerated,$streamable_result,$streamable_had_error) 1013 = $self->$optionally_run_general_cmd($stream_cmd,$ofla_filename, 1015 = $self->$optionally_run_general_cmd($stream_cmd, 1016 $ifilename,$ofla_filename, 1014 1017 $streamable_options); 1015 1018 … … 1072 1075 my $streaming_quality = "high"; 1073 1076 1077 my $ifilename = $originalfilename || $filename; 1078 1074 1079 my ($stream_cmd,$oflash_filename,$oflash_file) 1075 = $self->stream_flv_video_cmd($ originalfilename || $filename,1080 = $self->stream_flv_video_cmd($ifilename, 1076 1081 $video_width,$video_height, 1077 1082 $streaming_quality, … … 1085 1090 1086 1091 my ($streamable_regenerated,$streamable_result,$streamable_had_error) 1087 = $self->$optionally_run_general_cmd($stream_cmd,$oflash_filename,$streamable_options); 1092 = $self->$optionally_run_general_cmd($stream_cmd, 1093 $ifilename,$oflash_filename, 1094 $streamable_options); 1088 1095 1089 1096 if (!$streamable_had_error) { … … 1131 1138 sub enable_h264_streaming 1132 1139 { 1133 1140 my $self = shift (@_); 1134 1141 my ($doc_obj,$originalfilename,$filename,$convertto_regenerated, 1135 1142 $video_width,$video_height) = @_; 1136 1143 1137 1144 1138 1145 my $section = $doc_obj->get_top_section(); … … 1153 1160 my $streaming_HQ_AudioBitrate = $self->{'streamingHQAudioBitrate'}; 1154 1161 1162 my $ifilename = $originalfilename || $filename; 1155 1163 my ($stream_cmd,$oflash_filename,$oflash_file) 1156 = $self->stream_mp4_video_cmd($ originalfilename || $filename,1164 = $self->stream_mp4_video_cmd($ifilename, 1157 1165 $streaming_HQ_size, 1158 1166 $streaming_HQ_VideoBitrate, … … 1161 1169 1162 1170 my $streamable_options = { @{$self->{'handbrake_monitor'}}, 1163 1164 1171 'message_prefix' => "MP4 Stream", 1172 'message' => "Generating streamable MP4 video: $oflash_file" }; 1165 1173 1166 1174 1167 1175 my ($streamable_regenerated,$streamable_result,$streamable_had_error) 1168 = $self->$optionally_run_general_cmd($stream_cmd,$oflash_filename,$streamable_options); 1176 = $self->$optionally_run_general_cmd($stream_cmd, 1177 $ifilename,$oflash_filename, 1178 $streamable_options); 1169 1179 1170 1180 if (!$streamable_had_error) { -
gs2-extensions/video/trunk/perllib/plugins/VideoPlugin.pm
r21825 r22432 133 133 134 134 # Generate the keyframes with ffmpeg and hive 135 my ($keyframe_cmd,$okeyframe_filename) = $self->keyframe_cmd($originalfilename || $filename); 135 my $ifilename = $originalfilename || $filename; 136 my ($keyframe_cmd,$okeyframe_filename) = $self->keyframe_cmd($ifilename); 136 137 137 138 my $keyframe_options = { @{$self->{'ffmpeg_monitor'}}, … … 139 140 'message' => "Extracting keyframes" }; 140 141 141 $self->run_cached_general_cmd($keyframe_cmd,$okeyframe_filename,$keyframe_options); 142 $self->run_cached_general_cmd($keyframe_cmd, 143 $ifilename,$okeyframe_filename, 144 $keyframe_options); 142 145 $self->parse_shot_xml(); 143 146 … … 164 167 165 168 166 # Generate the thumbnail with convert, a la ImagePlug 169 # Generate the thumbnail with convert, a la ImagePlugin 167 170 168 171 my $thumbnailfile = &util::filename_cat($output_dir,"$ivideo_root-thumbnail.$thumbnailtype"); 169 170 172 171 173 my $optionally_run_general_cmd = "run_uncached_general_cmd"; … … 176 178 177 179 ### print STDERR "**** creating thumbnail: $thumbnail_width x $thumbnail_height\n"; 178 180 my $ofilename = $self->get_ovideo_filename($self->{'enable_streaming'}); 179 181 my ($thumb_cmd ,$othumb_filename) 180 182 = $self->keyframe_thumbnail_cmd($ofilename,$thumbnailfile,$thumbnail_width,$thumbnail_height); … … 186 188 187 189 my ($thumb_regenerated,$thumb_result,$thumb_had_error) 188 = $self->$optionally_run_general_cmd($thumb_cmd,$ thumbnailfile,$thumb_options);190 = $self->$optionally_run_general_cmd($thumb_cmd,$ofilename,$thumbnailfile,$thumb_options); 189 191 190 192 # Add the thumbnail as an associated file ... … … 209 211 # 2.thumbnail was cached, so imagemagick convert was not run 210 212 # Either way, the solution is the same: 211 # => run "identify $thumbnailfile" and parse result 212 213 $thumb_result = `identify \"$thumbnailfile\"`; 213 # => run "identify $thumbnailfile" and parse result 214 $thumb_result = `identify \"$thumbnailfile\" 2>&1`; 214 215 215 216 if ($thumb_result =~ m/([0-9]+)x([0-9]+)/) { … … 285 286 286 287 my ($screenview_regenerated,$screenview_result,$screenview_had_error) 287 = $self->$optionally_run_general_cmd($screenview_cmd,$screenviewfilename,$screenview_options); 288 = $self->$optionally_run_general_cmd($screenview_cmd, 289 $filename,$screenviewfilename, 290 $screenview_options); 288 291 289 292 … … 341 344 = &VideoConverter::identify($filename, $outhandle, $verbosity); 342 345 346 if ($video_duration =~ m/^(\d\d):(\d\d):(\d\d)\.(\d)$/) { 347 $video_duration = $1*3600 + $2*60 + $3 + ($4/10.0); 348 } 349 343 350 #if ($vfps eq "unknown") { 344 351 #print $outhandle "Unknown framerate, defaulting to 25 frames per second.\n"; … … 350 357 #my $total_dur_secs = $dur_hour*3600 + $dur_min*60 + $dur_sec; 351 358 352 359 my $total_dur_secs = $video_duration / 1000; 353 360 354 361 $self->{'video-fps'} = $vfps; … … 448 455 449 456 ($convertto_regenerated,$convertto_result,$convertto_error) 450 = $self->run_cached_general_cmd($convertto_command,$filename,$convertto_options); 457 = $self->run_cached_general_cmd($convertto_command, 458 $originalfilename,$filename, 459 $convertto_options); 451 460 452 461 $type = $converttotype; … … 580 589 $thumbnail_width,$thumbnail_height); 581 590 } 582 583 591 584 592 if ($self->{'extract_keyframes'}) {
Note:
See TracChangeset
for help on using the changeset viewer.