Changeset 22486


Ignore:
Timestamp:
2010-07-23T00:38:48+12:00 (12 years ago)
Author:
max
Message:

Increased the default resolution to SD quality,
Added options to enable/disable the deinterlacing filter of Handbrake and the extraction of additional metadata with MediaInfo.
Ignore some useless metadata extracted from the cache folder
Add some more comments

File:
1 edited

Legend:

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

    r22432 r22486  
    8282    'desc' => "{ImageConverter.screenviewsize}",
    8383    'type' => "int",
    84     'deft' => "576",
     84    'deft' => "720",
    8585    'range' => "1,",
    8686    'reqd' => "no" },
     
    136136    'desc' => "{VideoPlugin.streamingsize}",
    137137    'type' => "int",
    138     'deft' => "576",
     138    'deft' => "720",
    139139    'reqd' => "no" },
    140140    { 'name' => "streamingHQVideoBitrate",
    141141    'desc' => "{VideoPlugin.streamingbitrate}",
    142142    'type' => "int",
    143     'deft' => "432",
     143    'deft' => "496",
    144144    'reqd' => "no" },
    145145    { 'name' => "streamingHQAudioBitrate",
     
    147147    'type' => "int",
    148148    'deft' => "80",
     149    'reqd' => "no" },
     150    { 'name' => "videoDeinterlacingFilter",
     151    'desc' => "Activate a deinterlacing filter to increase the quality of TV footage",
     152    'type' => "enum",
     153    'list' => [{'name' => "true", 'desc' => "{common.true}"},
     154           {'name' => "false", 'desc' => "{common.false}"}],
     155    'deft' => "false",
     156    'reqd' => "no" },
     157    { 'name' => "getMaximumMetadata",
     158    'desc' => "Extract the maximum technical information of each video",
     159    'type' => "enum",
     160    'list' => [{'name' => "true", 'desc' => "{common.true}"},
     161           {'name' => "false", 'desc' => "{common.false}"}],
     162    'deft' => "false",
    149163    'reqd' => "no" },
    150164
     
    245259   
    246260    $metadata_table->{"mi.${type}Fields"}= join(",",@fieldlist);
    247    
    248261    }
    249262   
    250263    return $metadata_table;
     264
     265    while (@parts) {
     266        my $type = shift(@parts);
     267        my $vals = shift(@parts);
     268        my @fieldlist=();
     269        while ($vals =~ s/<(.*?)>(.*?)<\/\1>//) {
     270          my $metaname = $1;
     271          my $metaval  = $2;
     272          my $fullmetaname = "mi.$type\^$metaname";
     273          if($metaname ne "Complete_name") #ignore this field as it is pointing to the cache directory
     274              {
     275              $metadata_table->{$fullmetaname}= $metaval;
     276              push(@fieldlist,$fullmetaname);
     277              }
     278        }
     279        $metadata_table->{"mi.${type}Fields"}= join(",",@fieldlist);
     280    }
     281    return $metadata_table;
    251282
    252283}
     
    282313
    283314    my $xmlTxt =  mediaInfo_XML_Cmd ($video,$outhandle,0);
    284    
    285315    my $metadata_table = mediaInfo_parse_XML($xmlTxt,$outhandle,0);
    286316   
     
    537567}
    538568
     569# Generate the command to use with Handbrake to recompress a video using h264/aac compatible with Flash Player 10
    539570sub stream_mp4_video_cmd
    540571{
     
    543574     $streaming_HQ_AudioBitrate) = @_;
    544575
    545 
    546576    my $output_dir = $self->{'cached_dir'};
    547577    my $ivideo_root = $self->{'cached_file_root'};
     
    554584    #my $t_opt = (defined $exp_duration) ? "-t $exp_duration" : "";
    555585
    556 
    557    
    558     my $size;   
    559     # Looks for empty string as well as fullsize string
     586    my $deinterlace = $self->{'videoDeinterlacingFilter'};
     587    my $video_processing_parameters;   
     588    # Use specific resizing algorythms depending if we need to downsize the video resolution or not
    560589    if(!$streaming_HQ_size || $streaming_HQ_size eq "fullsize") {
    561         $size = "--strict-anamorphic";
     590        $video_processing_parameters = "--strict-anamorphic";
    562591    } else {
    563         $size = "-w $streaming_HQ_size --loose-anamorphic";
    564     }
    565    
     592        $video_processing_parameters = "-w $streaming_HQ_size --loose-anamorphic";
     593    }
     594    # Use the deinterlace video filter if enabled in the plugin
     595    if ($deinterlace eq "true")
     596    {
     597        $video_processing_parameters .= " --decomb";
     598    }
    566599
    567600    my $ivideo_filename_gsdlenv = $self->gsdlhome_independent($ivideo_filename);
    568601    my $omp4_filename_gsdlenv = $self->gsdlhome_independent($omp4_filename);
    569602   
    570     #my $pre_opts = "--decomb -t 1 -c 1";
    571     #my $post_opts = "-f mp4 $size -O -e x264 -b $streaming_HQ_VideoBitrate -a 1 -E faac -6 dpl2 -B $streaming_HQ_AudioBitrate -D 0.0 -x ref=2:bframes=2:me-umh -v 1";
    572    
     603    # Generate the pre and post video parameters for Handbrake v0.9.4
    573604    my $pre_opts = "-t 1 -c 1";
    574     my $post_opts = "-f mp4 -O $size --decomb -e x264 -b $streaming_HQ_VideoBitrate -a 1 -E faac -6 dpl2 -R Auto -B $streaming_HQ_AudioBitrate -D 0.0 -x ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0";
     605    my $post_opts = "-f mp4 -O $video_processing_parameters -e x264 -b $streaming_HQ_VideoBitrate -a 1 -E faac -6 dpl2 -R Auto -B $streaming_HQ_AudioBitrate -D 0.0 -x ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0";
    575606
    576607    my $handbrake_cmd = "HandbrakeCLI.exe -i \"$ivideo_filename_gsdlenv\" $pre_opts -o \"$omp4_filename_gsdlenv\" $post_opts";
    577608
    578 
     609    #print STDERR "****\nHandbrake command: $handbrake_cmd\n****\n";
     610   
    579611    return ($handbrake_cmd,$omp4_filename,$omp4_file);
    580612}
     
    11871219
    11881220    my ($vtype, $width, $height, $duration, $durationDisplay, $vsize,
    1189         $vcodec,$vrate,$fps,$atype,$afreq,$achan,$arate,$metadata_table) = identify($oflash_filename,$outhandle,0);
    1190        
     1221        $vcodec,$vrate,$fps,$atype,$afreq,$achan,$arate,$metadata_table) = identifyMI($oflash_filename,$outhandle,0);
     1222    #Add the most common metadata extracted by MediaInfo from the streamable video file
    11911223    $doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoFormat", $vtype);
    11921224    $doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoFileSize", $vsize);
     
    12011233    $doc_obj->add_utf8_metadata ($section, "tv.HQStreamingFileBitrate", $vrate + $arate);
    12021234   
    1203     foreach my $metaname(keys %$metadata_table)
    1204     {
    1205         my $metaval = $metadata_table->{$metaname};
    1206        
    1207         $doc_obj->add_utf8_metadata ($section, $metaname, $metaval);
     1235    my $get_max_metadata = $self->{'getMaximumMetadata'};
     1236    if ($get_max_metadata eq "true"){
     1237        foreach my $metaname(keys %$metadata_table)
     1238        {
     1239            my $metaval = $metadata_table->{$metaname};
     1240            $doc_obj->add_utf8_metadata ($section, $metaname, $metaval);
     1241        }
    12081242    }
    12091243   
Note: See TracChangeset for help on using the changeset viewer.