Index: /gs2-extensions/video/trunk/perllib/plugins/VideoConverter.pm
===================================================================
--- /gs2-extensions/video/trunk/perllib/plugins/VideoConverter.pm	(revision 22485)
+++ /gs2-extensions/video/trunk/perllib/plugins/VideoConverter.pm	(revision 22486)
@@ -82,5 +82,5 @@
 	'desc' => "{ImageConverter.screenviewsize}",
 	'type' => "int",
-	'deft' => "576",
+	'deft' => "720",
 	'range' => "1,",
 	'reqd' => "no" },
@@ -136,10 +136,10 @@
 	'desc' => "{VideoPlugin.streamingsize}",
 	'type' => "int",
-	'deft' => "576",
+	'deft' => "720",
 	'reqd' => "no" },
 	{ 'name' => "streamingHQVideoBitrate",
 	'desc' => "{VideoPlugin.streamingbitrate}",
 	'type' => "int",
-	'deft' => "432",
+	'deft' => "496",
 	'reqd' => "no" },
 	{ 'name' => "streamingHQAudioBitrate",
@@ -147,4 +147,18 @@
 	'type' => "int",
 	'deft' => "80",
+	'reqd' => "no" },
+	{ 'name' => "videoDeinterlacingFilter",
+	'desc' => "Activate a deinterlacing filter to increase the quality of TV footage",
+	'type' => "enum",
+	'list' => [{'name' => "true", 'desc' => "{common.true}"},
+		   {'name' => "false", 'desc' => "{common.false}"}],
+	'deft' => "false",
+	'reqd' => "no" },
+	{ 'name' => "getMaximumMetadata",
+	'desc' => "Extract the maximum technical information of each video",
+	'type' => "enum",
+	'list' => [{'name' => "true", 'desc' => "{common.true}"},
+		   {'name' => "false", 'desc' => "{common.false}"}],
+	'deft' => "false",
 	'reqd' => "no" },
 
@@ -245,8 +259,25 @@
 	
 	$metadata_table->{"mi.${type}Fields"}= join(",",@fieldlist);
-	
     }
     
     return $metadata_table;
+
+	while (@parts) {
+		my $type = shift(@parts);
+		my $vals = shift(@parts);
+		my @fieldlist=();
+		while ($vals =~ s/<(.*?)>(.*?)<\/\1>//) {
+		  my $metaname = $1;
+		  my $metaval  = $2;
+		  my $fullmetaname = "mi.$type\^$metaname";
+		  if($metaname ne "Complete_name") #ignore this field as it is pointing to the cache directory
+			  {
+			  $metadata_table->{$fullmetaname}= $metaval;
+			  push(@fieldlist,$fullmetaname);
+			  }
+		}
+		$metadata_table->{"mi.${type}Fields"}= join(",",@fieldlist);
+	}
+	return $metadata_table;
 
 }
@@ -282,5 +313,4 @@
 
 	my $xmlTxt =  mediaInfo_XML_Cmd ($video,$outhandle,0);
-	
 	my $metadata_table = mediaInfo_parse_XML($xmlTxt,$outhandle,0);
 	
@@ -537,4 +567,5 @@
 }
 
+# Generate the command to use with Handbrake to recompress a video using h264/aac compatible with Flash Player 10
 sub stream_mp4_video_cmd
 {
@@ -543,5 +574,4 @@
 	 $streaming_HQ_AudioBitrate) = @_;
 
-
     my $output_dir = $self->{'cached_dir'};
     my $ivideo_root = $self->{'cached_file_root'};
@@ -554,27 +584,29 @@
     #my $t_opt = (defined $exp_duration) ? "-t $exp_duration" : "";
 
-
-	
-	my $size;	
-	# Looks for empty string as well as fullsize string
+	my $deinterlace = $self->{'videoDeinterlacingFilter'};
+	my $video_processing_parameters;	
+	# Use specific resizing algorythms depending if we need to downsize the video resolution or not
 	if(!$streaming_HQ_size || $streaming_HQ_size eq "fullsize") { 
-		$size = "--strict-anamorphic";
+		$video_processing_parameters = "--strict-anamorphic";
 	} else {
-		$size = "-w $streaming_HQ_size --loose-anamorphic";
-	}
-	
+		$video_processing_parameters = "-w $streaming_HQ_size --loose-anamorphic";
+	}
+	# Use the deinterlace video filter if enabled in the plugin
+	if ($deinterlace eq "true")
+	{
+		$video_processing_parameters .= " --decomb";
+	}
 
     my $ivideo_filename_gsdlenv = $self->gsdlhome_independent($ivideo_filename);
     my $omp4_filename_gsdlenv = $self->gsdlhome_independent($omp4_filename);
 	
-	#my $pre_opts = "--decomb -t 1 -c 1";
-	#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";
-	
+	# Generate the pre and post video parameters for Handbrake v0.9.4
 	my $pre_opts = "-t 1 -c 1";
-	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";
+	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";
 
 	my $handbrake_cmd = "HandbrakeCLI.exe -i \"$ivideo_filename_gsdlenv\" $pre_opts -o \"$omp4_filename_gsdlenv\" $post_opts";
 
-
+    #print STDERR "****\nHandbrake command: $handbrake_cmd\n****\n";
+	
     return ($handbrake_cmd,$omp4_filename,$omp4_file);
 }
@@ -1187,6 +1219,6 @@
 
 	my ($vtype, $width, $height, $duration, $durationDisplay, $vsize,
-		$vcodec,$vrate,$fps,$atype,$afreq,$achan,$arate,$metadata_table) = identify($oflash_filename,$outhandle,0);
-		
+		$vcodec,$vrate,$fps,$atype,$afreq,$achan,$arate,$metadata_table) = identifyMI($oflash_filename,$outhandle,0);
+	#Add the most common metadata extracted by MediaInfo from the streamable video file
 	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoFormat", $vtype);
 	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoFileSize", $vsize);
@@ -1201,9 +1233,11 @@
 	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingFileBitrate", $vrate + $arate);
 	
-	foreach my $metaname(keys %$metadata_table)
-	{
-		my $metaval = $metadata_table->{$metaname};
-		
-		$doc_obj->add_utf8_metadata ($section, $metaname, $metaval);
+	my $get_max_metadata = $self->{'getMaximumMetadata'};
+	if ($get_max_metadata eq "true"){
+		foreach my $metaname(keys %$metadata_table)
+		{
+			my $metaval = $metadata_table->{$metaname};
+			$doc_obj->add_utf8_metadata ($section, $metaname, $metaval);
+		}
 	}
 	
