Changeset 19785 for extensions


Ignore:
Timestamp:
2009-06-10T11:57:45+12:00 (15 years ago)
Author:
davidb
Message:

General improvements to processing audio and for TIMEDHTMLPLugin to process files that have been edited by OpenOffice

Location:
extensions/gsdl-video/trunk/perllib/plugins
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/gsdl-video/trunk/perllib/plugins/TimedHTMLPlugin.pm

    r18982 r19785  
    122122    my $metatable_store = {};
    123123
    124     my $metatable_re = "<table([^>]*)>(.*?<p class=\"?Metadata\"?>.*?)<\\/table>";
     124    my $metatable_re = "<table([^>]*)>(.*?<p[^>]+class=\"?Metadata\"?[^>]*>.*?)<\\/table>";
    125125
    126126    if ($$textref =~ m/$metatable_re/gsi) {
     
    216216    my $time_encoded_file = "$hh$mm$ss";
    217217
     218    print STDERR "***** time endocde = $time_encoded\n";
     219
    218220    my $time_pos = $self->{'time_pos'};
    219221    my $time_num = scalar(@{$self->{'time_seq'}});
     
    291293
    292294
     295    # Embed link to allow video to stream from marked time event
    293296    if ($media_type eq "video") {
    294297
    295298        # video excerpt
    296 
    297         my $encoded_file = "$media_dir\_$time_encoded_file.avi";
    298 
    299         my $ve_filename
    300         = &util::filename_cat($collect_dir,"media","video_excerpt",$encoded_file);
    301 
    302         if ($only_num < $only_limit) {
    303         if (! -e $ve_filename) {
    304             # my $args = "-vcodec mpeg2video";
    305             my $args = "-vcodec msmpeg4";
    306299           
    307             my $ve_cmd = "gsmpeg.sh -v 1 -i $src_filename $args -ss $time_encoded ";
    308            
    309             if (defined $excerpt_len) {
    310             $ve_cmd .= "-t $excerpt_len ";
    311             }
    312            
    313             $ve_cmd .= $ve_filename;
    314            
    315 ##          print STDERR "$ve_cmd\n";
    316            
    317 ##          `$ve_cmd`;
    318         }
    319            
    320 ##      my $avi_url = "http://mcgonagall.cs.waikato.ac.nz:8201/gsdl/collect/hauraki2/media/video_excerpt/$media_dir\_$time_encoded_file.avi";
    321         my $avi_url = "_httpprefix_/collect/hauraki2/media/video_excerpt/$media_dir\_$time_encoded_file.avi";
     300        $avi_html .= "<a class=\"mm\" href=\"javascript:videoplayerseek($hh,$mm,$ss)\"><img border=1 src=\"_httpvideoimages_/ivideo.gif\"></a>";
     301
     302        # save 'time-stamp' as metadata???         
     303
     304    }
     305   
     306    # Do similar for audio.
     307    #   Obviously, pure audio needs to be handled here, but also
     308    #   video (and link in to its audio track)
     309
     310    if ($media_type =~ m/^(video|audio)$/) {
     311
    322312       
    323 ##      $avi_html = "<a class=\"mm\" href=\"$avi_url\"><img border=1 src=\"_httpcimages_\/video5.gif\"></a>";
    324        
    325        
    326         ## my $stream_url = "_httpstreamserver_/$local_root.asf";
    327 ##      my $stream_url = "http://mcgonagall.cs.waikato.ac.nz:8090/$local_root.avi";
    328 ##      $avi_html .= "<a class=\"mm\" href=\"$stream_url\">Stream</a>";
    329 
    330 
    331         ## $avi_html .= "<a class=\"mm\" href=\"_httpcurrentdocumentwithvplayer_\"><img border=1 src=\"_httpcimages_\/video5.gif\"></a>";
    332 
    333         $avi_html .= "<a class=\"mm\" href=\"javascript:videoplayerseek($hh,$mm,$ss)\"><img border=1 src=\"_httpcimages_\/video5.gif\"></a>";
    334 
    335         # save 'time-stamp' as metadata???
    336        
    337 
    338 
    339         }
    340         else {
    341         $avi_html = "<img src=\"_httpcimages_\/video5.gif\">";
    342         }
    343     }
    344 
    345     if ($media_type =~ m/^(video|audio)$/) {
    346 
    347         # audio excerpt
    348 #       my $encoded_file = "$media_dir\_$time_encoded_file.mp3";
    349 
    350 #       ## my $src_file = "$media_root\_Tape$tape_num.avi";
    351 
    352 #       #my $src_filename
    353 #       #   = &util::filename_cat($collect_dir,"media",$media_type ,$media_dir, $src_file);
    354 
    355 #       my $ae_filename
    356 #       = &util::filename_cat($collect_dir,"media","audio_excerpt",$encoded_file);
    357 
    358 
    359         if ($only_num < $only_limit) {
    360 
    361         $excerpt_len = 120 if (!defined $excerpt_len); #######
    362 
    363         my ($ae_cmd,$omp3_filename,$omp3_file)
    364             = $self->audio_excerpt_cmd($src_filename,
    365                            $hh,$mm,$ss,$excerpt_len);
    366        
    367         my $ae_options = { @{$self->{'ffmpeg_monitor'}},
    368                    'message_prefix' => "Audio Excerpt",
    369                    'message' => "Generating audio excerpt: $omp3_file" };
    370        
    371         my ($ae_regenerated,$ae_result,$ae_had_error)
    372             = $self->run_cached_general_cmd($ae_cmd,$omp3_filename,$ae_options);
    373 
    374         push(@{$self->{'mp3_excerpts'}}, { 'omp3_file' => $omp3_file, 'omp3_filename' => $omp3_filename} );
    375 
    376         }
    377 
    378 
    379 
    380 
    381         #    if (! -e $ae_filename) {
    382         if ($only_num < $only_limit) {
    383 #       if (! -e $ae_filename) {
    384            
    385 #           my $args = "-acodec mp3";
    386            
    387 #           ## my $src_filename = "media/video/mirth/VTS_01_1.avi";
    388 #           my $ae_cmd = "gsmpeg.sh -v 1 -i $src_filename $args -ss $time_encoded ";
    389            
    390 #           if (defined $excerpt_len) {
    391 #           $ae_cmd .= "-t $excerpt_len ";
    392 #           }
    393            
    394 #           $ae_cmd .= $ae_filename;
    395                                    
    396 ##          print STDERR "$ae_cmd\n";
    397            
    398 ##          `$ae_cmd`;
    399 #       }
    400        
    401        
    402 ##      my $mp3_url = "http://mcgonagall.cs.waikato.ac.nz:8201/gsdl/collect/hauraki2/media/audio_excerpt/$media_dir\_$time_encoded_file.mp3";
    403 #       my $mp3_url = "_httpprefix_/collect/hauraki2/media/audio_excerpt/$media_dir\_$time_encoded_file.mp3";
    404    
    405313        my ($voa_root) = ($src_file =~ m/^(.*)\..*?$/);
    406314   
    407         my $mp3_url = "javascript:audioexcerptplay('$voa_root','$hh','$mm','$ss')";
    408 
    409 #       my $mp3_url = "_httpcollection_/index/assoc/{If}{[assocfilepath],[assocfilepath],[parent(Top):assocfilepath]}/$media_dir\_$time_encoded_file.mp3";
    410 
    411         $mp3_html = "<a class=\"mm\" href=\"$mp3_url\"><img border=1 src=\"_httpcimages_\/audio2.gif\"></a>";
     315        my $mp3_url = "javascript:audioplayerseek($hh,$mm,$ss)";
     316        $mp3_html = "<a class=\"mm\" href=\"$mp3_url\"><img border=1 src=\"_httpvideoimages_/iaudio.gif\"></a>";
    412317
    413318#       my $baseexcerpt_url = "_httpcollection_/index/assoc/{If}{[assocfilepath],[assocfilepath],[parent(Top):assocfilepath]}";
    414319       
    415 #####       $doc_obj->add_metadata ($section, "audioexcerpturl",$mp3_url);
    416        
    417        
    418320        }
    419         else {
    420         $mp3_html = "<img src=\"_httpcimages_\/audio2.gif\">";
    421        
    422         }
    423     }
    424321    }
    425322    else {
     
    457354    my $media_root = $self->{'media_root'};
    458355
    459     my $front_re = "<p class=Timing><span\\s+.*?>";
     356
     357
     358    ##my $front_re = "<p class=Timing>(?:<span\\s+.*?>)?";
     359    my $front_re = "<p[^>]+class=\"?Timing(?:-.*?)?\"?[^>]*>(?:<span\\s+.*?>)?";
    460360    my $tape_re  = "T\\d+:";
    461361    my $tt_re = "\\d\\d";
    462     my $back_re = ".*?<\\/span>";
     362    my $back_re = ".*?(?:<\\/span>\\s*)?(?:<\\/p>)";
    463363
    464364    my $time_match_re = "$front_re$tt_re:$tt_re:$tt_re$back_re(?:\:$tt_re)?";
     
    471371
    472372    my @time_seq = ($$textref =~ m/$time_match_re/sgi);
     373
     374    print STDERR "***** got ", scalar(@time_seq), " matches\n";
    473375
    474376    # artifically add tape information into all time indexes
     
    491393    $self->{'time_pos'} = 0;
    492394
    493     $$textref =~ s/(<p class=Timing><span\s+.*?>)(T\d+:)? ?(\d\d):(\d\d):(\d\d)(?:\:\d\d)?.*?(<\/span>)/$self->timed_event($1,$2,$3,$4,$5,$6)/sgie;
     395    # my $front_re = "<p[^>]+class=\"?Timing(?:-.*?)?\"?[^>]*>(?:<span\\s+.*?>)?";
     396
     397    $$textref =~ s/($front_re)(T\d+:)? ?(\d\d):(\d\d):(\d\d)(?:\:\d\d)?.*?((?:<\/span>)?\s*<\/p>)/$self->timed_event($1,$2,$3,$4,$5,$6)/sgie;
     398
     399    ##$$textref =~ s/(<p class=Timing><span\s+.*?>)(T\d+:)? ?(\d\d):(\d\d):(\d\d)(?:\:\d\d)?.*?(<\/span>)/$self->timed_event($1,$2,$3,$4,$5,$6)/sgie;
    494400
    495401
     
    693599    my $video_excerpt_duration = $self->{'video_excerpt_duration'};
    694600
    695     print STDERR "**** video duration (secs) = $total_dur_secs\n";
     601    print STDERR "**** video/audio duration (secs) = $total_dur_secs\n";
    696602
    697603
     
    781687    # FlowPlayerThermo.swf height+16 pixels
    782688    # FlowPlayerWhite.swf  height+26 pixels
    783     $doc_obj->add_metadata ($section, "flashwidth",    $video_width);
    784     $doc_obj->add_metadata ($section, "flashheight",   $video_height + 22 + 100);
     689    if ($media_type eq "audio") {
     690    $doc_obj->add_metadata ($section, "flashwidth",    $video_width);
     691    $doc_obj->add_metadata ($section, "flashheight",   22 + 100);
     692    }
     693    else {
     694    $doc_obj->add_metadata ($section, "flashwidth",    $video_width);
     695    $doc_obj->add_metadata ($section, "flashheight",   $video_height + 22 + 100);
     696    }
     697
    785698   
    786699    my $base_url = "_httpstreamserverprefix_/collect/[collection]/index/assoc/{If}{[assocfilepath],[assocfilepath],[parent(Top):assocfilepath]}/";
  • extensions/gsdl-video/trunk/perllib/plugins/VideoConverter.pm

    r18995 r19785  
    305305
    306306    my $s_opt = "";
     307
    307308    if ($video_width > $video_height) {
    308309    if ($video_width > $orig_size) {
     
    392393    my $oflash_filename = &util::filename_cat($output_dir,$oflash_file);
    393394
    394     my $s_opt = $self->optional_frame_scale($streaming_size,$video_width,$video_height);
     395    my $s_opt = "";
     396    if ($self->{'media_type'} ne "audio") {
     397    $s_opt = $self->optional_frame_scale($streaming_size,$video_width,$video_height);
     398    }
     399
    395400
    396401    my $exp_duration = $self->{'exp_duration'};
     
    529534
    530535    my $collect = $ENV{'GSDLCOLLECTION'};
    531     my $thumbloc = "$video_server$video_prefix/collect/$collect";
     536
     537    ## my $thumbloc = "$video_server$video_prefix/collect/$collect";
    532538
    533539
  • extensions/gsdl-video/trunk/perllib/plugins/VideoPlugin.pm

    r18995 r19785  
    3838use MultimediaPlugin;
    3939use VideoConverter;
     40use ReadXMLFile;
    4041
    4142sub BEGIN {
    42     @VideoPlugin::ISA = ('MultimediaPlugin', 'VideoConverter');
     43    @VideoPlugin::ISA = ('MultimediaPlugin', 'VideoConverter', 'ReadXMLFile');
    4344}
    4445
     
    138139                 'message' => "Extracting keyframes" };
    139140   
    140     $self->autorun_cached_general_cmd($keyframe_cmd,$okeyframe_filename,$keyframe_options);
     141    $self->run_cached_general_cmd($keyframe_cmd,$okeyframe_filename,$keyframe_options);
    141142    $self->parse_shot_xml();
    142143    $self->associate_keyframes($doc_obj,$section);
     
    524525
    525526    ($convertto_regenerated,$convertto_result,$convertto_error)
    526         = $self->autorun_cached_general_cmd($convertto_command,$filename,$convertto_options);
     527        = $self->run_cached_general_cmd($convertto_command,$filename,$convertto_options);
    527528                           
    528529    $type = $converttotype;
     
    979980    my ($expat) = @_;
    980981
    981     $self->close_document();
     982    # ****
     983    # $self->close_document();
    982984}
    983985
Note: See TracChangeset for help on using the changeset viewer.