Ignore:
Timestamp:
2009-02-10T13:31:55+13:00 (15 years ago)
Author:
davidb
Message:

Mods to cached_convert so the $GSDLHOME is used rather then explicit directory name. That way the collection can be moved to another computer with Greenstone installed in a different place and the caching mechanism still works

Location:
extensions/gsdl-video/trunk/perllib
Files:
2 edited

Legend:

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

    r18476 r18490  
    362362
    363363
    364     my $convertto_command = "ffmpeg $main_opts -i \"$originalfilename\"";
     364    my $originalfilename_gsdlenv = $self->gsdlhome_independent($originalfilename);
     365    my $filename_gsdlenv = $self->gsdlhome_independent($filename);
     366
     367
     368    my $convertto_command = "ffmpeg $main_opts -i \"$originalfilename_gsdlenv\"";
    365369    $convertto_command .= " -ar 22050" if ($converttotype eq "flv");
    366     $convertto_command .= " -y \"$filename\"";
     370    $convertto_command .= " -y \"$filename_gsdlenv\"";
    367371
    368372    my $convertto_result;
     
    540544    my $thumbnailsize = $self->{'thumbnailsize'} || 100;
    541545    my $thumbnailtype = $self->{'thumbnailtype'} || 'jpg';
    542    
     546
     547    my $thumbnailwidth;
     548    my $thumbnailheight;
     549
     550    if ($video_width>$video_height) {
     551    my $scale_ratio = $video_height / $video_width;
     552    $thumbnailwidth = $thumbnailsize;
     553    $thumbnailheight = int($thumbnailsize * $scale_ratio);
     554    }
     555    else {
     556    my $scale_ratio = $video_width / $video_height;
     557    $thumbnailwidth = int($thumbnailsize * $scale_ratio);
     558    $thumbnailheight = $thumbnailsize;
     559    }
     560
    543561
    544562    my $thumbnailfile = &util::filename_cat($output_dir,"$ivideo_root.$thumbnailtype");
     
    548566    # Generate the thumbnail with convert, a la ImagePlug
    549567    my ($thumb_cmd ,$othumb_filename)
    550         = $videoconvert->keyframe_thumbnail_cmd($filename,$thumbnailfile,$thumbnailsize);
     568        = $videoconvert->keyframe_thumbnail_cmd($filename,$thumbnailfile,$thumbnailwidth,$thumbnailheight);
    551569
    552570    my $thumb_options = { 'verbosity' => $verbosity,
     
    626644    my $screenviewfilename = &util::filename_cat($output_dir,"$ivideo_root.$screenviewtype");
    627645
     646    my $screenviewwidth;
     647    my $screenviewheight;
     648   
     649    if ($video_width>$video_height) {
     650        my $scale_ratio = $video_height / $video_width;
     651        $screenviewwidth = $screenviewsize;
     652        $screenviewheight = int($screenviewsize * $scale_ratio);
     653    }
     654    else {
     655        my $scale_ratio = $video_width / $video_height;
     656        $screenviewwidth = int($screenviewsize * $scale_ratio);
     657        $screenviewheight = $screenviewsize;
     658    }
     659
     660
    628661    # make the screenview image
    629662
    630663    my ($screenview_cmd,$oscreenview_filename)
    631         = $videoconvert->keyframe_thumbnail_cmd($filename,$screenviewfilename,$screenviewsize);
     664        = $videoconvert->keyframe_thumbnail_cmd($filename,$screenviewfilename,$screenviewwidth,$screenviewheight);
    632665
    633666    my $screenview_options = { 'message_prefix' => "Screenview",
  • extensions/gsdl-video/trunk/perllib/videoconvert.pm

    r18425 r18490  
    242242
    243243
     244sub gsdlhome_independent
     245{
     246    my $self = shift @_;
     247    my ($filename) = @_;
     248
     249    my $gsdlhome = $ENV{'GSDLHOME'};
     250    my $filename_gsdlenv = $filename;
     251    $filename_gsdlenv =~ s@^$gsdlhome@\$GSDLHOME@;
     252
     253    return $filename_gsdlenv;
     254}
     255
    244256
    245257
     
    307319    my $vhook_opts = "$hive  -o $oshot_filename -k $output_dir $ivideo_filename";
    308320
    309     my $ffmpeg_cmd = "ffkeyframe  $main_opts -vhook \"$vhook_opts\"   -i \"$ivideo_filename\" -an -y \"$oflash_filename\"";
     321    my $ivideo_filename_gsdlenv = $self->gsdlhome_independent($ivideo_filename);
     322    my $oflash_filename_gsdlenv = $self->gsdlhome_independent($oflash_filename);
     323
     324    my $ffmpeg_cmd = "ffkeyframe  $main_opts -vhook \"$vhook_opts\"   -i \"$ivideo_filename_gsdlenv\" -an -y \"$oflash_filename_gsdlenv\"";
    310325
    311326
     
    351366    my $ffmpeg_cmd;
    352367
     368    my $ivideo_filename_gsdlenv = $self->gsdlhome_independent($ivideo_filename);
     369    my $oflash_filename_gsdlenv = $self->gsdlhome_independent($oflash_filename);
     370
    353371    if ($streaming_quality eq "high") {
    354372
     
    358376    }
    359377
    360     $all_opts .= " -passlogfile \"$pass_log_file\"";
    361 
    362     my $ffmpeg_cmd_pass1 = "ffmpeg -pass 1 -i \"$ivideo_filename\" $all_opts -y \"$oflash_filename\"";
    363 
    364     my $ffmpeg_cmd_pass2 = "ffmpeg -pass 2 -i \"$ivideo_filename\" $all_opts $bitrate_opt -y \"$oflash_filename\"";
     378    my $pass_log_file_gsdlenv = $self->gsdlhome_independent($pass_log_file);
     379
     380    $all_opts .= " -passlogfile \"$pass_log_file_gsdlenv\"";
     381
     382    my $ffmpeg_cmd_pass1 = "ffmpeg -pass 1 -i \"$ivideo_filename_gsdlenv\" $all_opts -y \"$oflash_filename_gsdlenv\"";
     383
     384    my $ffmpeg_cmd_pass2 = "ffmpeg -pass 2 -i \"$ivideo_filename_gsdlenv\" $all_opts $bitrate_opt -y \"$oflash_filename_gsdlenv\"";
    365385    $ffmpeg_cmd = "( $ffmpeg_cmd_pass1 ; $ffmpeg_cmd_pass2 )";
    366386    }
     
    368388    # single pass
    369389
    370     $ffmpeg_cmd = "ffmpeg -i \"$ivideo_filename\" $all_opts -y \"$oflash_filename\"";
     390    $ffmpeg_cmd = "ffmpeg -i \"$ivideo_filename_gsdlenv\" $all_opts -y \"$oflash_filename_gsdlenv\"";
    371391    }
    372392
     
    400420
    401421
    402     my $ffmpeg_cmd = "ffmpeg -i \"$ivoa_filename\" $all_opts  \"$omp3_filename\"";
     422    my $ivoa_filename_gsdlenv = $self->gsdlhome_independent($ivoa_filename);
     423    my $omp3_filename_gsdlenv = $self->gsdlhome_independent($omp3_filename);
     424
     425
     426    my $ffmpeg_cmd = "ffmpeg -i \"$ivoa_filename_gsdlenv\" $all_opts  \"$omp3_filename_gsdlenv\"";
    403427
    404428    return ($ffmpeg_cmd,$omp3_filename,$omp3_file);
     
    485509{
    486510    my $self = shift (@_);
    487     my ($ivideo_filename,$thumbnailfile,$thumbnailsize) = @_;
     511    my ($ivideo_filename,$thumbnailfile,$thumbnailwidth,$thumbnailheight) = @_;
    488512
    489513    my $output_dir = $self->{'cached_dir'};
     
    497521    $key_filename = "${key_filename_prefix}_0000.jpg" if (!-e $key_filename);
    498522
     523    my $key_filename_gsdlenv = $self->gsdlhome_independent($key_filename);
     524    my $thumbnailfile_gsdlenv = $self->gsdlhome_independent($thumbnailfile);
     525
    499526    my $command;
    500527
    501528    if (-e $key_filename) {
    502     $command = "convert -interlace plane -verbose -geometry $thumbnailsize"
    503         . "x$thumbnailsize \"$key_filename\" \"$thumbnailfile\"";
     529    $command = "convert -interlace plane -verbose -geometry $thumbnailwidth"
     530        . "x$thumbnailheight \"$key_filename_gsdlenv\" \"$thumbnailfile_gsdlenv\"";
    504531    }
    505532    else {
     
    508535    # => extract a from
    509536    # my $frame_rate = 1.0 / 60.0;
    510 
    511 
    512     $command = "ffmpeg -i \"$ivideo_filename\"  -ss 5.5 -vframes 1 -f image2 -s ${thumbnailsize}x${thumbnailsize} -y \"$thumbnailfile\"";
     537   
     538    my $ivideo_filename_gsdlenv = $self->gsdlhome_independent($ivideo_filename);
     539
     540
     541
     542    $command = "ffmpeg -i \"$ivideo_filename_gsdlenv\"  -ss 125 -vframes 1 -f image2 -s ${thumbnailwidth}x${thumbnailheight} -y \"$thumbnailfile_gsdlenv\"";
    513543
    514544    # fmpeg -i input.dv -r 1 -f image2 -s 120x96 images%05d.png
Note: See TracChangeset for help on using the changeset viewer.