Changeset 25346 for gs2-extensions
- Timestamp:
- 2012-04-05T15:53:05+12:00 (12 years ago)
- Location:
- gs2-extensions/video-and-audio/trunk/src/perllib/plugins
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/video-and-audio/trunk/src/perllib/plugins/AudioConverter.pm
r18556 r25346 155 155 156 156 157 sub audio_stream_ cmd157 sub audio_stream_ffmpeg_cmd 158 158 { 159 159 my $self = shift (@_); 160 my ($iaudio_filename, 160 my ($iaudio_filename, $ofile_ext, 161 161 $streaming_bitrate,$streaming_size, 162 162 $opt_streaming_achan, $opt_streaming_arate) = @_; … … 171 171 my $iaudio_root = $self->{'cached_file_root'}; 172 172 173 my $ mp3_file = "${iaudio_root}_stream.mp3";174 my $ mp3_filename = &util::filename_cat($output_dir,$mp3_file);173 my $op_file = "${iaudio_root}_stream.$ofile_ext"; 174 my $op_filename = &util::filename_cat($output_dir,$op_file); 175 175 176 176 my $exp_duration = $self->{'exp_duration'}; … … 188 188 189 189 my $iaudio_filename_gsdlenv = $self->gsdlhome_independent($iaudio_filename); 190 my $mp3_filename_gsdlenv = $self->gsdlhome_independent($mp3_filename); 191 192 193 $ffmpeg_cmd = "ffmpeg -i \"$iaudio_filename_gsdlenv\" $all_opts -y \"$mp3_filename_gsdlenv\""; 194 195 return ($ffmpeg_cmd,$mp3_filename,$mp3_file); 196 } 190 my $op_filename_gsdlenv = $self->gsdlhome_independent($op_filename); 191 192 193 $ffmpeg_cmd = "ffmpeg -i \"$iaudio_filename_gsdlenv\" $all_opts -y \"$op_filename_gsdlenv\""; 194 195 return ($ffmpeg_cmd,$op_filename,$op_file); 196 } 197 198 199 200 sub stream_mp4_audio_cmd 201 { 202 my $self = shift (@_); 203 my ($ivideo_filename,$streaming_HQ_size, $streaming_HQ_AudioBitrate) = @_; 204 205 my $output_dir = $self->{'cached_dir'}; 206 my $ivideo_root = $self->{'cached_file_root'}; 207 208 my $omp4_file = "${ivideo_root}_aHQstream.mp4"; 209 my $omp4_filename = &util::filename_cat($output_dir,$omp4_file); 210 211 212 #my $exp_duration = $self->{'exp_duration'}; 213 #my $t_opt = (defined $exp_duration) ? "-t $exp_duration" : ""; 214 215 my $deinterlace = $self->{'videoDeinterlacingFilter'}; 216 my $video_processing_parameters; 217 # Use specific resizing algorythms depending if we need to downsize the video resolution or not 218 if(!$streaming_HQ_size || $streaming_HQ_size eq "fullsize") { 219 $video_processing_parameters = "--strict-anamorphic"; 220 } else { 221 $video_processing_parameters = "-w $streaming_HQ_size --loose-anamorphic"; 222 } 223 # Use the deinterlace video filter if enabled in the plugin 224 if ($deinterlace eq "true") 225 { 226 $video_processing_parameters .= " --decomb"; 227 } 228 229 my $ivideo_filename_gsdlenv = $self->gsdlhome_independent($ivideo_filename); 230 my $omp4_filename_gsdlenv = $self->gsdlhome_independent($omp4_filename); 231 232 # Generate the pre and post video parameters for Handbrake v0.9.4 233 my $pre_opts = "-t 1 -c 1"; 234 my $post_opts = "-f mp4 -O $video_processing_parameters -e x264 -a 1 -E faac -6 dpl2 -R Auto -B $streaming_HQ_AudioBitrate -D 0.0 -x ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0"; 235 236 my $handbrake_cmd = "HandbrakeCLI.exe -i \"$ivideo_filename_gsdlenv\" $pre_opts -o \"$omp4_filename_gsdlenv\" $post_opts"; 237 238 #print STDERR "****\nHandbrake command: $handbrake_cmd\n****\n"; 239 240 return ($handbrake_cmd,$omp4_filename,$omp4_file); 241 } 242 243 197 244 198 245 -
gs2-extensions/video-and-audio/trunk/src/perllib/plugins/AudioPlugin.pm
r20003 r25346 247 247 248 248 $file = $file_unicode; 249 my $filemeta = $self->filename_to_utf8_metadata($file); 250 my $filemeta_url_safe = $self->url_safe($filemeta); 249 # my $filemeta = $self->filename_to_utf8_metadata($file); 250 # my $filemeta_url_safe = $self->url_safe($filemeta); 251 252 my $filemeta_url_safe = &unicode::filename_to_url($file); 251 253 252 254 $doc_obj->add_utf8_metadata ($section, "Audio", $filemeta_url_safe); … … 254 256 # Also want to set filename as 'Source' metadata to be 255 257 # consistent with other plugins 256 $doc_obj->add_utf8_metadata ($section, "Source", $filemeta_url_safe);258 # $doc_obj->add_utf8_metadata ($section, "Source", $filemeta_url_safe); 257 259 258 260 … … 288 290 if ($self->{'enable_streaming'}) { 289 291 292 my $enable_streaming = $self->{'enable_streaming'}; 293 290 294 # Even if the original file or 'converttotype' is set to MP3 291 295 # we'll still go ahead and generate this MP3 as it might very … … 295 299 my $streaming_size = $self->{'streamingsize'}; 296 300 297 298 my ($stream_cmd,$mp3_filename,$mp3_file) 299 = $self->audio_stream_cmd($originalfilename || $filename, 300 $streaming_bitrate, $streaming_size); 301 my $ifilename = $originalfilename || $filename; 302 303 my ($stream_cmd,$mp_filename,$mp_file); 304 if ($enable_streaming eq "mp4") { 305 ($stream_cmd,$mp_filename,$mp_file) 306 = $self->audio_mp4_stream_cmd($ifilename, $streaming_size, 307 $streaming_bitrate); 308 } 309 else { 310 ($stream_cmd,$mp_filename,$mp_file) 311 = $self->audio_stream_ffmpeg_cmd($ifilename, $enable_streaming, 312 $streaming_bitrate, $streaming_size,); 313 314 } 301 315 302 316 303 317 my $streamable_options = { @{$self->{'ffmpeg_monitor'}}, 304 318 'message_prefix' => "Stream", 305 'message' => "Generating streamable audio: $mp 3_file" };319 'message' => "Generating streamable audio: $mp_file" }; 306 320 307 321 my $streamable_result; 308 322 my $streamable_had_error; 309 323 ($streamable_regenerated,$streamable_result,$streamable_had_error) 310 = $self->$optionally_run_general_cmd($stream_cmd,$ mp3_filename,$streamable_options);324 = $self->$optionally_run_general_cmd($stream_cmd,$ifilename,$mp_filename,$streamable_options); 311 325 312 326 if (!$streamable_had_error) { 313 327 314 my $streamable_url = $mp 3_file;328 my $streamable_url = $mp_file; 315 329 my $streamable_url_safe = $self->url_safe($streamable_url); 316 330 317 331 $doc_obj->add_utf8_metadata ($section, "streamableaudio", $streamable_url_safe); 318 $doc_obj->associate_file($mp 3_filename,$mp3_file,"audio/mpeg",332 $doc_obj->associate_file($mp_filename,$mp_file,"audio/mpeg", 319 333 $section); 320 334 } … … 322 336 # The following aren't currently used 323 337 324 $self->{'mp 3_file'} = $mp3_file;325 $self->{'mp 3_filename'} = $mp3_filename;338 $self->{'mp_file'} = $mp_file; 339 $self->{'mp_filename'} = $mp_filename; 326 340 } 327 341 -
gs2-extensions/video-and-audio/trunk/src/perllib/plugins/VideoConverter.pm
r24188 r25346 717 717 my $post_opts = "-f mp4 -O $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 ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0"; 718 718 719 my $handbrake_cmd = "Hand brakeCLI.exe-i \"$ivideo_filename_gsdlenv\" $pre_opts -o \"$omp4_filename_gsdlenv\" $post_opts";719 my $handbrake_cmd = "HandBrakeCLI -i \"$ivideo_filename_gsdlenv\" $pre_opts -o \"$omp4_filename_gsdlenv\" $post_opts"; 720 720 721 721 #print STDERR "****\nHandbrake command: $handbrake_cmd\n****\n"; … … 1005 1005 my $ivideo_filename_gsdlenv = $self->gsdlhome_independent($ivideo_filename); 1006 1006 1007 1008 1009 1007 # If ever reused, then needs to change to newer hashmap method 1008 #my ($vtype, $width, $height, $duration, $vsize, 1009 # $vcodec ,$fps ,$atype ,$afreq ,$achan ,$arate) = identify($ivideo_filename_gsdlenv,$outhandle,0); 1010 1010 1011 1011 #print STDERR "***** grabbing keyframe as 50% of $video_duration\n"; … … 1015 1015 $command = "ffmpeg -ss $ss_opt -i \"$ivideo_filename_gsdlenv\" -ss 4.5 -an -vframes 1 -f image2 -s ${thumbnailwidth}x${thumbnailheight} -deinterlace -y \"$thumbnailfile_gsdlenv\""; 1016 1016 #$command = "ffmpeg -ss 4.5 -i \"$ivideo_filename_gsdlenv\" -ss 4.5 -an -vframes 1 -f image2 -s ${thumbnailwidth}x${thumbnailheight} -deinterlace -y \"$thumbnailfile_gsdlenv\""; 1017 1018 ## $command = "ffmpeg -i \"$ivideo_filename_gsdlenv\" -ss 10.5 -vframes 1 -f image2 -s ${thumbnailwidth}x${thumbnailheight} -deinterlace -y \"$thumbnailfile_gsdlenv\""; 1019 1020 $command = "ffmpeg -i \"$ivideo_filename_gsdlenv\" -ss 16.5 -vframes 1 -f image2 -s ${thumbnailwidth}x${thumbnailheight} -deinterlace -y \"$thumbnailfile_gsdlenv\""; 1021 1017 1022 1018 1023 # fmpeg -i input.dv -r 1 -f image2 -s 120x96 images%05d.png -
gs2-extensions/video-and-audio/trunk/src/perllib/plugins/VideoPlugin.pm
r23406 r25346 156 156 my $self = shift (@_); 157 157 my ($doc_obj,$filename,$convertto_regenerated,$thumbnailtype, 158 $thumbnail_width, $thumbnail_height ) = @_;158 $thumbnail_width, $thumbnail_height,$video_duration) = @_; 159 159 160 160 my $section = $doc_obj->get_top_section(); … … 180 180 # my $ofilename = $self->get_ovideo_filename($self->{'enable_streaming'}); 181 181 my ($thumb_cmd ,$othumb_filename) 182 = $self->keyframe_thumbnail_cmd($filename,$thumbnailfile,$thumbnail_width,$thumbnail_height );182 = $self->keyframe_thumbnail_cmd($filename,$thumbnailfile,$thumbnail_width,$thumbnail_height,$video_duration); 183 183 184 184 my $thumb_options = { 'verbosity' => $verbosity, … … 261 261 { 262 262 my $self = shift (@_); 263 my ($doc_obj,$filename,$convertto_regenerated, $screenviewtype, $screenview_width,$screenview_height ) = @_;263 my ($doc_obj,$filename,$convertto_regenerated, $screenviewtype, $screenview_width,$screenview_height,$video_duration) = @_; 264 264 265 265 my $section = $doc_obj->get_top_section(); … … 279 279 280 280 my ($screenview_cmd,$oscreenview_filename) 281 = $self->keyframe_thumbnail_cmd($filename,$screenviewfilename,$screenview_width,$screenview_height );281 = $self->keyframe_thumbnail_cmd($filename,$screenviewfilename,$screenview_width,$screenview_height,$video_duration); 282 282 283 283 my $screenview_options = { 'message_prefix' => "Screenview", … … 344 344 = &VideoConverter::identify($filename, $outhandle, $verbosity); 345 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 } 346 347 # if ($video_duration =~ m/^(\d\d):(\d\d):(\d\d)\.(\d+)$/) { 348 # $video_duration = $1*3600 + $2*60 + $3 + ($4/10.0); 349 # } 350 351 my $identify_vals = &VideoConverter::identifyMI($filename, $outhandle, $verbosity); 352 $video_duration = $identify_vals->{'duration'}; 353 $vfps = $identify_vals->{'fps'}; 354 $video_width = $identify_vals->{'width'}; 355 $video_height = $identify_vals->{'height'}; 356 357 print STDERR "**** video width x height: $video_width x $video_height\n"; 349 358 350 359 if ($vfps eq "unknown") { … … 496 505 497 506 $file = $file_unicode; 498 my $filemeta = $self->filename_to_utf8_metadata($file); 499 my $filemeta_url_safe = $self->url_safe($filemeta); 507 # my $filemeta = $self->filename_to_utf8_metadata($file); 508 # my $filemeta_url_safe = $self->url_safe($filemeta); 509 510 my $filemeta_url_safe = &unicode::filename_to_url($file); 500 511 501 512 $doc_obj->add_utf8_metadata ($section, "Video", $filemeta_url_safe); … … 579 590 my $thumbnail_height; 580 591 592 # if ($video_width<$video_height) { 593 # my $scale_ratio = $video_height / $video_width; 594 # $thumbnail_width = $thumbnailsize; 595 # $thumbnail_height = int($thumbnailsize * $scale_ratio); 596 # } 597 # else { 598 ## Standardizes on height, width scaled to keep aspectc ration the same 599 # my $scale_ratio = $video_width / $video_height; 600 # $thumbnail_width = int($thumbnailsize * $scale_ratio); 601 # $thumbnail_height = $thumbnailsize; 602 # } 603 581 604 if ($video_width<$video_height) { 605 my $scale_ratio = $video_width / $video_height; 606 $thumbnail_width = int($thumbnailsize * $scale_ratio); 607 $thumbnail_height = $thumbnailsize; 608 } 609 else { 582 610 my $scale_ratio = $video_height / $video_width; 583 611 $thumbnail_width = $thumbnailsize; 584 612 $thumbnail_height = int($thumbnailsize * $scale_ratio); 585 613 } 586 else {587 my $scale_ratio = $video_width / $video_height;588 $thumbnail_width = int($thumbnailsize * $scale_ratio);589 $thumbnail_height = $thumbnailsize;590 }591 614 592 615 # for some video formats, extracted size needs to be multiple of 2 … … 594 617 $thumbnail_height = int($thumbnail_height/2) * 2; 595 618 619 ## print STDERR "*** thumbsize: $thumbnailsize"; 620 ## print STDERR "*** thumbnail: $thumbnail_width x $thumbnail_height\n"; 621 596 622 $self->extract_thumbnail($doc_obj,$filename,$convertto_regenerated, 597 623 $thumbnailtype, 598 $thumbnail_width,$thumbnail_height); 624 $thumbnail_width,$thumbnail_height, 625 $video_duration); 599 626 } 600 627 … … 633 660 $self->extract_screenview($doc_obj,$filename, $convertto_regenerated, 634 661 $screenviewtype, 635 $screenview_width,$screenview_height); 662 $screenview_width,$screenview_height, 663 $video_duration); 636 664 } 637 665
Note:
See TracChangeset
for help on using the changeset viewer.