Changeset 22432 for gs2-extensions


Ignore:
Timestamp:
2010-07-19T14:00:53+12:00 (14 years ago)
Author:
davidb
Message:

Adjustment of calling BaseMediaConverter to pass in additional input file parameter

Location:
gs2-extensions/video/trunk/perllib/plugins
Files:
2 edited

Legend:

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

    r21824 r22432  
    208208# Here we use mediaInfo to get all the possible metadata in XML form that could then be parsed
    209209#the result will vary depending on the file type and how it was encoded
    210 sub mediaInfo_XML_Cmd   {
    211     my ($video, $outhandle, $verbosity) = @_;
    212    
    213     # Use MediaInfo CLI to get the file spec according to the requested parameter
     210sub mediaInfo_XML_Cmd {
     211    my ($video, $outhandle, $verbosity) = @_;
     212   
     213    # Use MediaInfo CLI to get the file spec according to the requested parameter
    214214    my $command = "mediainfo --Output=XML \"$video\"";
    215 
     215   
    216216    print $outhandle "  $command\n" if ($verbosity > 2);
    217217    my $result = '';
    218218    $result = `$command 2>&1`;
    219219    print $outhandle "  $result\n" if ($verbosity > 4);
    220    
     220   
    221221    # Return the asked spec
    222222    return ($result);
     
    224224
    225225#Here we parse the video specs contained in the XML text in order to create a metadata entry for each field
    226 sub mediaInfo_parse_XML     {
    227     my ($xmlTxt, $outhandle, $verbosity) = @_;
    228    
    229     my @parts = split(/<track\s+type=\"(.*?)\">/is,$xmlTxt);
    230    
    231     shift @parts; # Skip preamble
    232     my $metadata_table = {};
    233 
    234     while (@parts) {
    235         my $type = shift(@parts);
    236         my $vals = shift(@parts);
    237         my @fieldlist=();
    238         while ($vals =~ s/<(.*?)>(.*?)<\/\1>//) {
    239           my $metaname = $1;
    240           my $metaval  = $2;
    241           my $fullmetaname = "mi.$type\^$metaname";
    242           $metadata_table->{$fullmetaname}= $metaval;
    243           push(@fieldlist,$fullmetaname);
    244         }
    245        
    246         $metadata_table->{"mi.${type}Fields"}= join(",",@fieldlist);
    247        
     226sub mediaInfo_parse_XML {
     227    my ($xmlTxt, $outhandle, $verbosity) = @_;
     228   
     229    my @parts = split(/<track\s+type=\"(.*?)\">/is,$xmlTxt);
     230   
     231    shift @parts; # Skip preamble
     232    my $metadata_table = {};
     233   
     234    while (@parts) {
     235    my $type = shift(@parts);
     236    my $vals = shift(@parts);
     237    my @fieldlist=();
     238    while ($vals =~ s/<(.*?)>(.*?)<\/\1>//) {
     239        my $metaname = $1;
     240        my $metaval  = $2;
     241        my $fullmetaname = "mi.$type\^$metaname";
     242        $metadata_table->{$fullmetaname}= $metaval;
     243        push(@fieldlist,$fullmetaname);
    248244    }
    249245   
    250     return $metadata_table;
    251 
    252 }
    253 
    254 sub identify {
     246    $metadata_table->{"mi.${type}Fields"}= join(",",@fieldlist);
     247   
     248    }
     249   
     250    return $metadata_table;
     251
     252}
     253
     254sub identifyMI {
    255255    my ($video, $outhandle, $verbosity) = @_;
    256256
     
    291291
    292292
    293 sub identify2 {
     293sub identify {
    294294    my ($video, $outhandle, $verbosity) = @_;
    295295
     
    10011001
    10021002   
     1003    my $ifilename = $originalfilename || $filename;
     1004
    10031005    my ($stream_cmd,$ofla_filename,$ofla_file)
    1004     = $self->stream_flv_audio_cmd($originalfilename || $filename);
     1006    = $self->stream_flv_audio_cmd($ifilename);
    10051007   
    10061008   
     
    10111013
    10121014    my ($streamable_regenerated,$streamable_result,$streamable_had_error)
    1013     = $self->$optionally_run_general_cmd($stream_cmd,$ofla_filename,
     1015    = $self->$optionally_run_general_cmd($stream_cmd,
     1016                         $ifilename,$ofla_filename,
    10141017                         $streamable_options);
    10151018
     
    10721075    my $streaming_quality = "high";
    10731076   
     1077    my $ifilename = $originalfilename || $filename;
     1078
    10741079    my ($stream_cmd,$oflash_filename,$oflash_file)
    1075     = $self->stream_flv_video_cmd($originalfilename || $filename,
     1080    = $self->stream_flv_video_cmd($ifilename,
    10761081                     $video_width,$video_height,
    10771082                     $streaming_quality,
     
    10851090
    10861091    my ($streamable_regenerated,$streamable_result,$streamable_had_error)
    1087     = $self->$optionally_run_general_cmd($stream_cmd,$oflash_filename,$streamable_options);
     1092    = $self->$optionally_run_general_cmd($stream_cmd,
     1093                         $ifilename,$oflash_filename,
     1094                         $streamable_options);
    10881095   
    10891096    if (!$streamable_had_error) {
     
    11311138sub enable_h264_streaming
    11321139{
    1133     my $self = shift (@_);
     1140    my $self = shift (@_);
    11341141    my ($doc_obj,$originalfilename,$filename,$convertto_regenerated,
    11351142    $video_width,$video_height) = @_;
    1136    
     1143   
    11371144
    11381145    my $section = $doc_obj->get_top_section();
     
    11531160    my $streaming_HQ_AudioBitrate    = $self->{'streamingHQAudioBitrate'};
    11541161
     1162    my $ifilename = $originalfilename || $filename;
    11551163    my ($stream_cmd,$oflash_filename,$oflash_file)
    1156     = $self->stream_mp4_video_cmd($originalfilename || $filename,
     1164    = $self->stream_mp4_video_cmd($ifilename,
    11571165                     $streaming_HQ_size,
    11581166                     $streaming_HQ_VideoBitrate,
     
    11611169   
    11621170    my $streamable_options = { @{$self->{'handbrake_monitor'}},
    1163                                'message_prefix' => "MP4 Stream",
    1164                                'message' => "Generating streamable MP4 video: $oflash_file" };
     1171                   'message_prefix' => "MP4 Stream",
     1172                   'message' => "Generating streamable MP4 video: $oflash_file" };
    11651173   
    11661174
    11671175    my ($streamable_regenerated,$streamable_result,$streamable_had_error)
    1168     = $self->$optionally_run_general_cmd($stream_cmd,$oflash_filename,$streamable_options);
     1176    = $self->$optionally_run_general_cmd($stream_cmd,
     1177                         $ifilename,$oflash_filename,
     1178                         $streamable_options);
    11691179   
    11701180    if (!$streamable_had_error) {
  • gs2-extensions/video/trunk/perllib/plugins/VideoPlugin.pm

    r21825 r22432  
    133133
    134134    # Generate the keyframes with ffmpeg and hive
    135     my ($keyframe_cmd,$okeyframe_filename) = $self->keyframe_cmd($originalfilename || $filename);
     135    my $ifilename = $originalfilename || $filename;
     136    my ($keyframe_cmd,$okeyframe_filename) = $self->keyframe_cmd($ifilename);
    136137   
    137138    my $keyframe_options = { @{$self->{'ffmpeg_monitor'}},
     
    139140                 'message' => "Extracting keyframes" };
    140141   
    141     $self->run_cached_general_cmd($keyframe_cmd,$okeyframe_filename,$keyframe_options);
     142    $self->run_cached_general_cmd($keyframe_cmd,
     143                  $ifilename,$okeyframe_filename,
     144                  $keyframe_options);
    142145    $self->parse_shot_xml();
    143146
     
    164167
    165168
    166     # Generate the thumbnail with convert, a la ImagePlug
     169    # Generate the thumbnail with convert, a la ImagePlugin
    167170
    168171    my $thumbnailfile = &util::filename_cat($output_dir,"$ivideo_root-thumbnail.$thumbnailtype");
    169    
    170172   
    171173    my $optionally_run_general_cmd = "run_uncached_general_cmd";
     
    176178   
    177179###    print STDERR "**** creating thumbnail: $thumbnail_width x $thumbnail_height\n";
    178     my $ofilename = $self->get_ovideo_filename($self->{'enable_streaming'});
     180    my $ofilename = $self->get_ovideo_filename($self->{'enable_streaming'});
    179181    my ($thumb_cmd ,$othumb_filename)
    180182    = $self->keyframe_thumbnail_cmd($ofilename,$thumbnailfile,$thumbnail_width,$thumbnail_height);
     
    186188   
    187189    my ($thumb_regenerated,$thumb_result,$thumb_had_error)
    188     = $self->$optionally_run_general_cmd($thumb_cmd,$thumbnailfile,$thumb_options);
     190    = $self->$optionally_run_general_cmd($thumb_cmd,$ofilename,$thumbnailfile,$thumb_options);
    189191   
    190192    # Add the thumbnail as an associated file ...
     
    209211    #   2.thumbnail was cached, so imagemagick convert was not run
    210212    # Either way, the solution is the same:
    211     # => run "identify $thumbnailfile" and parse result
    212    
    213     $thumb_result = `identify \"$thumbnailfile\"`;
     213    # => run "identify $thumbnailfile" and parse result
     214    $thumb_result = `identify \"$thumbnailfile\" 2>&1`;
    214215   
    215216    if ($thumb_result =~ m/([0-9]+)x([0-9]+)/) {
     
    285286                   
    286287    my ($screenview_regenerated,$screenview_result,$screenview_had_error)
    287     = $self->$optionally_run_general_cmd($screenview_cmd,$screenviewfilename,$screenview_options);
     288    = $self->$optionally_run_general_cmd($screenview_cmd,
     289                         $filename,$screenviewfilename,
     290                         $screenview_options);
    288291   
    289292
     
    341344    = &VideoConverter::identify($filename, $outhandle, $verbosity);
    342345
     346    if ($video_duration =~ m/^(\d\d):(\d\d):(\d\d)\.(\d)$/) {
     347    $video_duration = $1*3600 + $2*60 + $3 + ($4/10.0);
     348    }
     349
    343350    #if ($vfps eq "unknown") {
    344351    #print $outhandle "Unknown framerate, defaulting to 25 frames per second.\n";
     
    350357    #my $total_dur_secs = $dur_hour*3600 + $dur_min*60 + $dur_sec;
    351358   
    352     my $total_dur_secs = $video_duration / 1000;
     359    my $total_dur_secs = $video_duration / 1000;
    353360
    354361    $self->{'video-fps'} = $vfps;
     
    448455
    449456    ($convertto_regenerated,$convertto_result,$convertto_error)
    450         = $self->run_cached_general_cmd($convertto_command,$filename,$convertto_options);
     457        = $self->run_cached_general_cmd($convertto_command,
     458                        $originalfilename,$filename,
     459                        $convertto_options);
    451460                           
    452461    $type = $converttotype;
     
    580589                 $thumbnail_width,$thumbnail_height);
    581590    }
    582 
    583591
    584592    if ($self->{'extract_keyframes'}) {
Note: See TracChangeset for help on using the changeset viewer.