Changeset 25516

Show
Ignore:
Timestamp:
02.05.2012 17:08:23 (7 years ago)
Author:
davidb
Message:

Code changes prompted by the development of ReplayMe?

Location:
gs2-extensions/video-and-audio/trunk/src/perllib/plugins
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • gs2-extensions/video-and-audio/trunk/src/perllib/plugins/VideoConverter.pm

    r25346 r25516  
    121121    'deft' => "false", 
    122122    'reqd' => "no" }, 
     123     
     124    { 'name' => "keyframesize", 
     125    'desc' => "{ImageConverter.keyframesize}", 
     126    'type' => "int", 
     127    'deft' => "520", 
     128    'range' => "1,", 
     129    'reqd' => "no" }, 
     130     
    123131       { 'name' => "keyframes_algorithm", 
    124132    'desc' => "{VideoPlugin.keyframesAlgorithm}", 
     
    602610{ 
    603611    my $self = shift (@_); 
    604     my ($ivideo_filename) = @_; 
     612    my ($ivideo_filename,$video_width,$video_height) = @_; 
    605613 
    606614    my $video_ext_dir = &util::filename_cat($ENV{'GSDLHOME'},"ext","video"); 
     
    620628    my $mtn_detect_blank = $mtn_detect_blank_perc/100.0; 
    621629     
    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 { 
    627636        # assume thumbnail size 
    628         $keyframe_height = $self->{'thumbnailsize'}; 
    629     } 
    630          
     637#       $keyframe_height = $self->{'thumbnailsize'}; 
     638#   } 
     639     
     640     
     641     
    631642    $main_opts .= " -B $mtn_skip_intro_secs"; 
    632643    $main_opts .= " -E $mtn_skip_end_secs"; 
     
    10101021     
    10111022    #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; 
    10131024    #print STDERR "*** ssopt = $ss_opt\n"; 
    10141025     
     
    11081119                 'keyframeindex' => $keyframe_index, 
    11091120                 'timestamp' => $time_msec, 
    1110                  'thumb' => $f, 
     1121                 'thumb' => &util::filename_cat("frames",$f), 
    11111122                 'keyframenum' => $keyframe_index }; 
    11121123     
  • gs2-extensions/video-and-audio/trunk/src/perllib/plugins/VideoPlugin.pm

    r25346 r25516  
    121121} 
    122122 
    123  
     123  
    124124sub extract_keyframes 
    125125{ 
    126126    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   
     139sub extract_ffKeyframes 
     140{ 
     141    my $self = shift (@_); 
    127142    my ($doc_obj,$originalfilename,$filename) = @_; 
    128143 
     
    134149    # Generate the keyframes with ffmpeg and hive 
    135150    my $ifilename = $originalfilename || $filename; 
    136     my ($keyframe_cmd,$okeyframe_filename) = $self->keyframe_cmd($ifilename); 
     151    my ($keyframe_cmd,$okeyframe_filename) = $self->ffKeyframe_cmd($ifilename); 
    137152     
    138153    my $keyframe_options = { @{$self->{'ffmpeg_monitor'}}, 
     
    150165} 
    151166 
     167 
     168sub 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} 
    152200 
    153201 
     
    340388    } 
    341389 
    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    } 
    346409 
    347410#    if ($video_duration =~ m/^(\d\d):(\d\d):(\d\d)\.(\d+)$/) { 
     
    361424    $vfps = 25; 
    362425    } 
    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; 
    367426     
    368427    my $total_dur_secs = $video_duration / 1000; 
     
    505564 
    506565    $file = $file_unicode; 
     566 
    507567#    my $filemeta = $self->filename_to_utf8_metadata($file); 
    508568#    my $filemeta_url_safe = $self->url_safe($filemeta); 
     
    550610 
    551611 
    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); 
    554614    } 
    555615 
     
    626686    } 
    627687 
    628     if ($self->{'extract_keyframes'}) { 
     688    if (($self->{'create_keyframes'}  eq "true") && ($self->{'create_montage'}  eq "true")) { 
    629689    $self->extract_keyframes_montage($doc_obj,$filename,$thumbnailtype); 
    630690    } 
     
    686746    ? 1 : 0; 
    687747 
    688     if (($enable_streaming) && ($self->{'extract_keyframes'})) { 
     748    if (($enable_streaming) && ($self->{'create_keyframes'} eq "true")) { 
    689749    my $section = $doc_obj->get_top_section(); 
    690750    my $oflash_filename = $self->{'oflash_filename'}; 
     
    713773 
    714774 
     775sub 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 
     786sub close_on_cue 
     787{ 
     788    print CUEOUT "</tags>\n"; 
     789    close(CUEOUT); 
     790} 
    715791 
    716792sub output_distributed_keyframes 
     
    9701046    if ($element eq "seg") { 
    9711047 
    972     $self->output_distributed_keyframes($self->{'keyframe_timeline'},$self->{'keep_keyframes'}); 
     1048    $self->output_distributed_keyframes($self->{'keyframe_timeline'},$self->{'ffkeyframe_num_shots'}); 
    9731049 
    9741050