Index: /gs2-extensions/video-and-audio/trunk/src/perllib/plugins/VideoConverter.pm
===================================================================
--- /gs2-extensions/video-and-audio/trunk/src/perllib/plugins/VideoConverter.pm	(revision 23406)
+++ /gs2-extensions/video-and-audio/trunk/src/perllib/plugins/VideoConverter.pm	(revision 23407)
@@ -194,14 +194,5 @@
 
 
-
-
-# Discover the characteristics of a video file.
-
-#  Equivalent step to that in ImagePlugin that uses ImageMagicks's
-#  'indentify' utility
-
-#  Here we use 'MediaInfo' for video but for consistency keep the Perl
-#  method name the same as before
-
+#  Here we use 'MediaInfo' for video and ask for a specific specification
 sub mediaInfo_Inform_Cmd {
 	my ($video, $parameter, $outhandle, $verbosity) = @_;
@@ -221,5 +212,5 @@
 
 # Here we use mediaInfo to get all the possible metadata in XML form that could then be parsed
-#the result will vary depending on the file type and how it was encoded
+# the result will vary depending on the file type and how it was encoded
 sub mediaInfo_XML_Cmd {
     my ($video, $outhandle, $verbosity) = @_;
@@ -237,5 +228,6 @@
 }
 
-#Here we parse the video specs contained in the XML text in order to create a metadata entry for each field
+# Here we parse the video specs contained in the XML text in order to create a metadata entry for each field
+# that mediainfo is giving back, this can vary from media file to media file.
 sub mediaInfo_parse_XML {
     my ($xmlTxt, $outhandle, $verbosity) = @_;
@@ -286,6 +278,6 @@
     my ($video, $outhandle, $verbosity) = @_;
 
-    # Use the ffmpeg command to get the file specs
-    my $command = "ffmpeg -i \"$video\"";
+    # Use the MediaInfo command to get the file specs
+    my $command = "MediaInfo \"$video\"";
 
     print $outhandle "  $command\n" if ($verbosity > 2);
@@ -294,21 +286,31 @@
     print $outhandle "  $result\n" if ($verbosity > 4);
 
-    # Read the type, width, and height etc.
-	# This could be done in a more efficient way by only calling the application mediainfo once and
-	# giving all the parameters then parsing the results, however on most operating system
-	# once the application is called once it is then cached for subsequent calls.
-    my $vtype =  mediaInfo_Inform_Cmd($video,"General;%Format%",$outhandle,0);
-	my $duration = mediaInfo_Inform_Cmd($video,"General;%Duration%",$outhandle,0);
-	my $durationDisplay = mediaInfo_Inform_Cmd($video,"General;%Duration/String1%",$outhandle,0);
-	my $filesize = mediaInfo_Inform_Cmd($video,"General;%FileSize/String%",$outhandle,0);
-    my $vcodec = mediaInfo_Inform_Cmd($video,"Video;%Format%",$outhandle,0);
-	my $vrate = mediaInfo_Inform_Cmd($video,"Video;%BitRate%",$outhandle,0);
-    my $width =  mediaInfo_Inform_Cmd($video,"Video;%Width%",$outhandle,0);
-    my $height = mediaInfo_Inform_Cmd($video,"Video;%Height%",$outhandle,0);
-    my $fps    = mediaInfo_Inform_Cmd($video,"Video;%FrameRate%",$outhandle,0);
-    my $atype =  mediaInfo_Inform_Cmd($video,"Audio;%Format%",$outhandle,0);
-    my $afreq =  mediaInfo_Inform_Cmd($video,"Audio;%SamplingRate/String%",$outhandle,0);
-    my $achan =  mediaInfo_Inform_Cmd($video,"Audio;%Channel(s)%",$outhandle,0);
-    my $arate =  mediaInfo_Inform_Cmd($video,"Audio;%BitRate%",$outhandle,0);
+    # Read the type, width, and height etc. from media file
+	# This could be done in a more efficient way by only calling the application MediaInfo once and
+	# giving all the parameters inside a special macro file then parsing the results, however
+	# on most operating system when the application is called once it is then cached for subsequent calls.
+	# General info
+    my $vtype			= mediaInfo_Inform_Cmd($video,"General;%Format%",$outhandle,0); #Container of the video e.g. MPEG-TS
+	my $duration		= mediaInfo_Inform_Cmd($video,"General;%Duration%",$outhandle,0); #Duration of the video in ms e.g. 5545841
+	my $durationDisplay	= mediaInfo_Inform_Cmd($video,"General;%Duration/String%",$outhandle,0); #Duration of the video in minutes and secs or hours and minutes e.g. 25m 12s or 2h 26m
+	my $filesize		= mediaInfo_Inform_Cmd($video,"General;%FileSize%",$outhandle,0); #File size in bytes e.g. 1024
+	my $filesizeDisplay	= mediaInfo_Inform_Cmd($video,"General;%FileSize/String%",$outhandle,0); #File size with measure e.g. 25.6 MiB
+	my $orateDisplay	= mediaInfo_Inform_Cmd($video,"General;%OverallBitRate/String%",$outhandle,0); #General file bitrate with measure e.g. 7 538 Kbps
+	# Video info
+    my $vcodec			= mediaInfo_Inform_Cmd($video,"Video;%Format%",$outhandle,0); #Codec used for the video compression e.g. AVC
+	my $vrate			= mediaInfo_Inform_Cmd($video,"Video;%BitRate%",$outhandle,0); #Bitrate used for the video stream in bps e.g. 546165
+    my $width			= mediaInfo_Inform_Cmd($video,"Video;%Width%",$outhandle,0); #Width of the video in pixels e.g. 1920
+    my $height			= mediaInfo_Inform_Cmd($video,"Video;%Height%",$outhandle,0); #Height of the video in pixels e.g. 1080
+    my $fps				= mediaInfo_Inform_Cmd($video,"Video;%FrameRate%",$outhandle,0); #Video frames per second e.g. 30
+	# Audio info
+    my $acodec			= mediaInfo_Inform_Cmd($video,"Audio;%Format%",$outhandle,0); # Audio codec used for the compression e.g. AAC
+    my $afreq			= mediaInfo_Inform_Cmd($video,"Audio;%SamplingRate/String%",$outhandle,0); #Sampling rate used for audio encoding e.g. 48000
+    my $achan			= mediaInfo_Inform_Cmd($video,"Audio;%Channel(s)%",$outhandle,0); #Number of channels e.g. 2
+    my $arate			= mediaInfo_Inform_Cmd($video,"Audio;%BitRate%",$outhandle,0); #Audio bitrate for the audio stream in bps e.g. 65436
+	my $atracks			= mediaInfo_Inform_Cmd($video,"Audio;%StreamCount%",$outhandle,0); #number of audio tracks in this video file e.g. 1
+	# Subtitles info
+	my $stype			= mediaInfo_Inform_Cmd($video,"Text;%Format%",$outhandle,0); # Format used for the subtitles e.g. DVB Subtitle
+	my $slang			= mediaInfo_Inform_Cmd($video,"Text;%Language/String%",$outhandle,0); # Language used for the subtitles e.g. English
+		
 
 	my $xmlTxt =  mediaInfo_XML_Cmd ($video,$outhandle,0);
@@ -316,9 +318,13 @@
 	
     # Return the specs
-    return ($vtype,$width,$height,$duration,$durationDisplay,$filesize,
-	    $vcodec,$vrate,$fps,$atype,$afreq,$achan,$arate,$metadata_table);
-}
-
-
+	my $identify_vals = { "vtype" => $vtype, "width" => $width, "height" => $height, "duration" => $duration, "filesize" => $filesize, "vcodec" => $vcodec,
+	"fps" => $fps, "acodec" => $acodec, "afreq" => $afreq, "achan" => $achan, "arate" => $arate, "metadata_table" => $metadata_table, "durationDisplay" => $durationDisplay,
+	"filesizeDisplay" => $filesizeDisplay, "orateDisplay" => $orateDisplay, "vrate" => $vrate, "stype" => $stype, "slang" => $slang, "atracks" => $atracks	};
+
+	return $identify_vals;
+}
+
+# Here we use 'ffmpeg' for video and ask for a specific specification
+# This is now deprecated this will be replaced by identifyMI in the future
 sub identify { 
     my ($video, $outhandle, $verbosity) = @_;
@@ -420,6 +426,6 @@
 	    my $full_v = &util::filename_cat($media_base_dir,$v);
 
-	    my ($vtype, $width, $height, $duration, $durationDisplay, $vsize,
-		$vcodec,$vrate,$fps,$atype,$afreq,$achan,$arate) = identify($full_v,$outhandle,0);
+	    my ($vtype, $width, $height, $duration, $vsize,
+			$vcodec ,$fps ,$atype ,$afreq ,$achan ,$arate) = identify($full_v,$outhandle,0);
 
 	    my ($vob_num) = ($v =~ m/^VTS_\d\d_(\d)\.VOB$/);
@@ -894,5 +900,5 @@
 	my $ivideo_filename_gsdlenv = $self->gsdlhome_independent($ivideo_filename);
 
-	$command = "ffmpeg -i \"$ivideo_filename_gsdlenv\"  -ss 3.5 -vframes 1 -f image2 -s ${thumbnailwidth}x${thumbnailheight} -y \"$thumbnailfile_gsdlenv\"";
+	$command = "ffmpeg -i \"$ivideo_filename_gsdlenv\"  -ss 4.5 -vframes 1 -f image2 -s ${thumbnailwidth}x${thumbnailheight} -deinterlace -y \"$thumbnailfile_gsdlenv\"";
 
 	# fmpeg -i input.dv -r 1 -f image2 -s 120x96 images%05d.png
@@ -1187,24 +1193,29 @@
 	my $outhandle = $self->{'outhandle'};
 
-	my ($vtype, $width, $height, $duration, $durationDisplay, $vsize,
-		$vcodec,$vrate,$fps,$atype,$afreq,$achan,$arate,$metadata_table) = identifyMI($ifilename,$outhandle,0);
+	my $identify_vals = identifyMI($ifilename,$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);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingWidth", $width);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingHeight", $height);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingDuration", $durationDisplay);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingFPS", $fps);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoCodec", $vcodec);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoBitrate", $vrate);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingAudioCodec", $atype);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingAudioBitrate", $arate);
-	#$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingFileBitrate", $vrate + $arate);
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoFormat", $identify_vals->{'vtype'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoFileSize", $identify_vals->{'filesizeDisplay'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoFileSizeBytes", $identify_vals->{'filesize'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingWidth", $identify_vals->{'width'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingHeight", $identify_vals->{'height'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingDuration", $identify_vals->{'durationDisplay'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingFPS", $identify_vals->{'fps'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoCodec", $identify_vals->{'vcodec'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoBitrate", $identify_vals->{'vrate'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingAudioCodec", $identify_vals->{'acodec'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingAudioBitrate", $identify_vals->{'arate'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingAudioTracks", $identify_vals->{'atracks'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingOverallBitrate", $identify_vals->{'orateDisplay'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingSubtitleType", $identify_vals->{'stype'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingSubtitleLanguage", $identify_vals->{'slang'});
 	
 	my $get_max_metadata = $self->{'getMaximumMetadata'};
 	if ($get_max_metadata eq "true"){
+		my $metadata_table = $identify_vals->{'metadata_table'};
 		foreach my $metaname(keys %$metadata_table)
 		{
-			my $metaval = $metadata_table->{$metaname};
+			my $metaval = $identify_vals->{'metadata_table'}->{$metaname};
 			$doc_obj->add_utf8_metadata ($section, $metaname, $metaval);
 		}
@@ -1281,24 +1292,27 @@
 	my $outhandle = $self->{'outhandle'};
 
-	my ($vtype, $width, $height, $duration, $durationDisplay, $vsize,
-		$vcodec,$vrate,$fps,$atype,$afreq,$achan,$arate,$metadata_table) = identifyMI($oflash_filename,$outhandle,0);
+	my $identify_vals = 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);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingWidth", $width);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingHeight", $height);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingDuration", $durationDisplay);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingFPS", $fps);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoCodec", $vcodec);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoBitrate", $vrate);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingAudioCodec", $atype);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingAudioBitrate", $arate);
-	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingFileBitrate", $vrate + $arate);
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoFormat", $identify_vals->{'vtype'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoFileSize", $identify_vals->{'filesizeDisplay'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingWidth", $identify_vals->{'width'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingHeight", $identify_vals->{'height'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingDuration", $identify_vals->{'durationDisplay'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingFPS", $identify_vals->{'fps'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoCodec", $identify_vals->{'vcodec'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingVideoBitrate", $identify_vals->{'vrate'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingAudioCodec", $identify_vals->{'acodec'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingAudioBitrate", $identify_vals->{'arate'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingOverallBitrate", $identify_vals->{'orateDisplay'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingSubtitleType", $identify_vals->{'stype'});
+	$doc_obj->add_utf8_metadata ($section, "tv.HQStreamingSubtitleLangue", $identify_vals->{'slang'});
 	
 	my $get_max_metadata = $self->{'getMaximumMetadata'};
 	if ($get_max_metadata eq "true"){
+		my $metadata_table = $identify_vals->{'metadata_table'};
 		foreach my $metaname(keys %$metadata_table)
 		{
-			my $metaval = $metadata_table->{$metaname};
+			my $metaval = $identify_vals->{'metadata_table'}->{$metaname};
 			$doc_obj->add_utf8_metadata ($section, $metaname, $metaval);
 		}
@@ -1310,7 +1324,4 @@
 				 $section);
     }
-
-
-
 
     my $flashwidth = $video_width;
