Changeset 25516 for gs2-extensions/video-and-audio/trunk
- Timestamp:
- 2012-05-02T17:08:23+12:00 (12 years ago)
- Location:
- gs2-extensions/video-and-audio/trunk/src/perllib/plugins
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/video-and-audio/trunk/src/perllib/plugins/VideoConverter.pm
r25346 r25516 121 121 'deft' => "false", 122 122 'reqd' => "no" }, 123 124 { 'name' => "keyframesize", 125 'desc' => "{ImageConverter.keyframesize}", 126 'type' => "int", 127 'deft' => "520", 128 'range' => "1,", 129 'reqd' => "no" }, 130 123 131 { 'name' => "keyframes_algorithm", 124 132 'desc' => "{VideoPlugin.keyframesAlgorithm}", … … 602 610 { 603 611 my $self = shift (@_); 604 my ($ivideo_filename ) = @_;612 my ($ivideo_filename,$video_width,$video_height) = @_; 605 613 606 614 my $video_ext_dir = &util::filename_cat($ENV{'GSDLHOME'},"ext","video"); … … 620 628 my $mtn_detect_blank = $mtn_detect_blank_perc/100.0; 621 629 622 my $keyframe_height; 623 if ($self->{'create_screenview'} eq "true") { 624 $keyframe_height = $self->{'screenviewsize'}; 625 } 626 else { 630 my $keyframe_height = $self->{'keyframesize'}; 631 632 # if ($self->{'create_screenview'} eq "true") { 633 # $keyframe_height = $self->{'screenviewsize'}; 634 # } 635 # else { 627 636 # assume thumbnail size 628 $keyframe_height = $self->{'thumbnailsize'}; 629 } 630 637 # $keyframe_height = $self->{'thumbnailsize'}; 638 # } 639 640 641 631 642 $main_opts .= " -B $mtn_skip_intro_secs"; 632 643 $main_opts .= " -E $mtn_skip_end_secs"; … … 1010 1021 1011 1022 #print STDERR "***** grabbing keyframe as 50% of $video_duration\n"; 1012 my $ss_opt = ($video_duration / 1000.0) * 0. 35;1023 my $ss_opt = ($video_duration / 1000.0) * 0.45; 1013 1024 #print STDERR "*** ssopt = $ss_opt\n"; 1014 1025 … … 1108 1119 'keyframeindex' => $keyframe_index, 1109 1120 'timestamp' => $time_msec, 1110 'thumb' => $f,1121 'thumb' => &util::filename_cat("frames",$f), 1111 1122 'keyframenum' => $keyframe_index }; 1112 1123 -
gs2-extensions/video-and-audio/trunk/src/perllib/plugins/VideoPlugin.pm
r25346 r25516 121 121 } 122 122 123 123 124 124 sub extract_keyframes 125 125 { 126 126 my $self = shift (@_); 127 my ($doc_obj,$originalfilename,$filename, $video_width,$video_height) = @_; 128 129 130 if ($self->{'keyframes_algorithm'} eq "ffkeyframe") { 131 $self->extract_ffKeyframes($doc_obj,$originalfilename,$filename); 132 } 133 else { 134 $self->extract_mtnKeyframes($doc_obj,$originalfilename,$filename, $video_width,$video_height); 135 } 136 } 137 138 139 sub extract_ffKeyframes 140 { 141 my $self = shift (@_); 127 142 my ($doc_obj,$originalfilename,$filename) = @_; 128 143 … … 134 149 # Generate the keyframes with ffmpeg and hive 135 150 my $ifilename = $originalfilename || $filename; 136 my ($keyframe_cmd,$okeyframe_filename) = $self-> keyframe_cmd($ifilename);151 my ($keyframe_cmd,$okeyframe_filename) = $self->ffKeyframe_cmd($ifilename); 137 152 138 153 my $keyframe_options = { @{$self->{'ffmpeg_monitor'}}, … … 150 165 } 151 166 167 168 sub extract_mtnKeyframes 169 { 170 my $self = shift (@_); 171 my ($doc_obj,$originalfilename,$filename,$video_width,$video_height) = @_; 172 173 my $section = $doc_obj->get_top_section(); 174 175 my $output_dir = $self->{'cached_dir'}; 176 my $ivideo_root = $self->{'cached_file_root'}; 177 178 my $verbosity = $self->{'verbosity'}; 179 my $outhandle = $self->{'outhandle'}; 180 181 # Generate the keyframes with ffmpeg and hive 182 my $ifilename = $originalfilename || $filename; 183 my ($keyframe_cmd,$okeyframe_filename) = $self->mtnKeyframe_cmd($ifilename, $video_width,$video_height); 184 185 my $keyframe_options = { 'verbosity' => $verbosity, 186 'outhandle' => $outhandle, 187 'message_prefix' => "Keyframe", 188 'message' => "Extracting keyframes" }; 189 190 $self->run_cached_general_cmd($keyframe_cmd, 191 $ifilename,$okeyframe_filename, 192 $keyframe_options); 193 194 $self->parse_shot_dir(); 195 196 my $keep_keyframe_timeline = $self->{'keep_keyframe_timeline'}; 197 $self->associate_keyframes($doc_obj,$section,$keep_keyframe_timeline); 198 199 } 152 200 153 201 … … 340 388 } 341 389 342 my ($video_type, $video_width, $video_height, $video_duration, $durationDisplay, $video_size, 343 $vcodec,$vrate,$vfps,$atype,$afreq,$achan,$arate) 344 = &VideoConverter::identify($filename, $outhandle, $verbosity); 345 390 my $identify_hash = &VideoConverter::identifyMI($filename, $outhandle, $verbosity); 391 392 my $video_type = $identify_hash->{'vtype'}; 393 my $video_width = $identify_hash->{'width'}; 394 my $video_height = $identify_hash->{'height'}; 395 my $video_duration = $identify_hash->{'duration'}; 396 my $video_size = $identify_hash->{'filesize'}; 397 my $vcodec = $identify_hash->{'vcodec'}; 398 my $vfps = $identify_hash->{'fps'}; 399 my $atype = $identify_hash->{'acodec'}; 400 my $afreq = $identify_hash->{'afreq'}; 401 my $achan = $identify_hash->{'achan'}; 402 my $arate = $identify_hash->{'arate'}; 403 404 if ($video_duration =~ m/^(\d\d):(\d\d):(\d\d)\.(\d+)$/) { 405 # ffmpeg can generate durations in this form. 406 # MediaInof works in milliseconds, so work to this same resolution 407 $video_duration = ($1*3600 + $2*60 + $3 + ($4/10.0)) * 1000.0; 408 } 346 409 347 410 # if ($video_duration =~ m/^(\d\d):(\d\d):(\d\d)\.(\d+)$/) { … … 361 424 $vfps = 25; 362 425 } 363 364 #my ($dur_hour,$dur_min,$dur_sec)365 #= ($video_duration =~ m/(\d+):(\d+):(\d+\.\d+)/);366 #my $total_dur_secs = $dur_hour*3600 + $dur_min*60 + $dur_sec;367 426 368 427 my $total_dur_secs = $video_duration / 1000; … … 505 564 506 565 $file = $file_unicode; 566 507 567 # my $filemeta = $self->filename_to_utf8_metadata($file); 508 568 # my $filemeta_url_safe = $self->url_safe($filemeta); … … 550 610 551 611 552 if ($self->{' extract_keyframes'}) {553 $self->extract_keyframes($doc_obj,$originalfilename,$filename );612 if ($self->{'create_keyframes'} eq "true") { 613 $self->extract_keyframes($doc_obj,$originalfilename,$filename,$video_width,$video_height); 554 614 } 555 615 … … 626 686 } 627 687 628 if ( $self->{'extract_keyframes'}) {688 if (($self->{'create_keyframes'} eq "true") && ($self->{'create_montage'} eq "true")) { 629 689 $self->extract_keyframes_montage($doc_obj,$filename,$thumbnailtype); 630 690 } … … 686 746 ? 1 : 0; 687 747 688 if (($enable_streaming) && ($self->{' extract_keyframes'})) {748 if (($enable_streaming) && ($self->{'create_keyframes'} eq "true")) { 689 749 my $section = $doc_obj->get_top_section(); 690 750 my $oflash_filename = $self->{'oflash_filename'}; … … 713 773 714 774 775 sub open_on_cue 776 { 777 my ($self) = shift @_; 778 my ($cue_filename) = @_; 779 780 open(CUEOUT,">$cue_filename") 781 || die "Unable to open $cue_filename: $!\n"; 782 print CUEOUT "<tags>\n"; 783 784 } 785 786 sub close_on_cue 787 { 788 print CUEOUT "</tags>\n"; 789 close(CUEOUT); 790 } 715 791 716 792 sub output_distributed_keyframes … … 970 1046 if ($element eq "seg") { 971 1047 972 $self->output_distributed_keyframes($self->{'keyframe_timeline'},$self->{' keep_keyframes'});1048 $self->output_distributed_keyframes($self->{'keyframe_timeline'},$self->{'ffkeyframe_num_shots'}); 973 1049 974 1050
Note:
See TracChangeset
for help on using the changeset viewer.