Index: gs2-extensions/gsdl-video/trunk/perllib/plugins/VideoConverter.pm
===================================================================
--- gs2-extensions/gsdl-video/trunk/perllib/plugins/VideoConverter.pm	(revision 21012)
+++ gs2-extensions/gsdl-video/trunk/perllib/plugins/VideoConverter.pm	(revision 21335)
@@ -106,8 +106,13 @@
 	'deft' => "200k",
 	'reqd' => "no" },
-      { 'name' => "extractkeyframes",
+      { 'name' => "extract_keyframes",
 	'desc' => "{VideoPlugin.extractkeyframes}",
 	'type' => "flag",
 	'deft' => "0",
+	'reqd' => "no" },
+      { 'name' => "keep_keyframes",
+	'desc' => "{VideoPlugin.keep_keyframes}",
+	'type' => "string",
+	'deft' => "all",
 	'reqd' => "no" },
       { 'name' => "streamingsize",
@@ -590,7 +595,25 @@
     my $ivideo_root = $self->{'cached_file_root'};
 
+    ## my $cue_filename = &util::filename_cat($output_dir,"on_cue.xml");
+
+    my $flvtool_cmd = "flvtool2 -vUP \"$oflash_filename\"";
+
+    return ($flvtool_cmd,$oflash_filename);
+}
+
+
+sub streamkeyframes_cmd
+{
+    my $self = shift (@_);
+    my ($oflash_filename,$doc_obj,$section) = @_;
+
+    my $assocfilepath 
+	= $doc_obj->get_metadata_element($section,"assocfilepath");
+
+    my $output_dir = $self->{'cached_dir'};
+
     my $cue_filename = &util::filename_cat($output_dir,"on_cue.xml");
-
-    my $flvtool_cmd = "flvtool2 -vUP \"$oflash_filename\"";
+ 
+    my $flvtool_cmd = "flvtool2 -vAUtP \"$cue_filename\"  \"$oflash_filename\"";
 
     return ($flvtool_cmd,$oflash_filename);
@@ -598,5 +621,5 @@
 
 
-sub streamkeyframes_cmd
+sub streamkeyframes_cmd_old
 {
     my $self = shift (@_);
@@ -633,8 +656,8 @@
     my $cue_filename = &util::filename_cat($output_dir,"on_cue.xml");
 
-    my $video_server = $ENV{'GEXT_VIDEO_SERVER'}; 
-    my $video_prefix = $ENV{'GEXT_VIDEO_PREFIX'};
-
-    my $collect = $ENV{'GSDLCOLLECTION'};
+    ##my $video_server = $ENV{'GEXT_VIDEO_SERVER'}; 
+    ##my $video_prefix = $ENV{'GEXT_VIDEO_PREFIX'};
+
+    ## my $collect = $ENV{'GSDLCOLLECTION'};
 
     ## my $thumbloc = "$video_server$video_prefix/collect/$collect";
@@ -685,5 +708,5 @@
     }
     else {
-	# extractkeyframe has either not been switched on, or else had
+	# extract_keyframe has either not been switched on, or else had
 	# a problem when running
 	# => extract a from 
@@ -770,8 +793,7 @@
     my ($self) = shift(@_);
 
-    my ($doc_obj,$section) = @_;
-
-    my $output_dir = $self->{'cached_dir'};
-    my $timeline = $self->{'keyframe_timeline'};
+    my ($doc_obj,$section,$timeline) = @_;
+
+    my $output_dir = $self->{'cached_dir'};
     
     my $count = 1;
@@ -786,9 +808,12 @@
 				 $section);
 	$doc_obj->add_utf8_metadata($section,"KeyframeTimestamp",$timestamp);
+	$doc_obj->add_utf8_metadata($section,"KeyframeFrameNum",$t);
 
 	$count++;
     }
 
-    $doc_obj->add_utf8_metadata($section,"NumKeyframes",scalar(@{$self->{'keyframe_fnames'}}));
+    #### $doc_obj->add_utf8_metadata($section,"NumKeyframes",scalar(@{$self->{'keyframe_fnames'}}));
+
+    $doc_obj->add_utf8_metadata($section,"NumKeyframes",scalar(keys %$timeline));
 
 
@@ -933,5 +958,5 @@
     my $flashheight = $video_height + 22;
 
-    if ($self->{'extractkeyframes'}) {
+    if ($self->{'extract_keyframes'}) {
 	$flashheight += 100;
     }
@@ -1020,5 +1045,5 @@
     my $flashheight = $video_height + 22;
 
-    if ($self->{'extractkeyframes'}) {
+    if ($self->{'extract_keyframes'}) {
 	$flashheight += 100;
     }
Index: gs2-extensions/gsdl-video/trunk/perllib/plugins/VideoPlugin.pm
===================================================================
--- gs2-extensions/gsdl-video/trunk/perllib/plugins/VideoPlugin.pm	(revision 21012)
+++ gs2-extensions/gsdl-video/trunk/perllib/plugins/VideoPlugin.pm	(revision 21335)
@@ -141,5 +141,8 @@
     $self->run_cached_general_cmd($keyframe_cmd,$okeyframe_filename,$keyframe_options);
     $self->parse_shot_xml();
-    $self->associate_keyframes($doc_obj,$section);
+
+    my $keep_keyframe_timeline = $self->{'keep_keyframe_timeline'};
+    $self->associate_keyframes($doc_obj,$section,$keep_keyframe_timeline);
+
 }
 
@@ -520,5 +523,5 @@
 
 
-    if ($self->{'extractkeyframes'}) {
+    if ($self->{'extract_keyframes'}) {
 	$self->extract_keyframes($doc_obj,$originalfilename,$filename);
     }
@@ -573,5 +576,5 @@
 
 
-    if ($self->{'extractkeyframes'}) {
+    if ($self->{'extract_keyframes'}) {
 	$self->extract_keyframes_montage($doc_obj,$filename,$thumbnailtype);
     }
@@ -628,5 +631,9 @@
     }
 
-    if (($self->{'enablestreaming'}) && ($self->{'extractkeyframes'})) {
+    my $enable_streaming 
+	= ($self->{'enable_flv_streaming'} || $self->{'enable_mp4_streaming'})
+	? 1 : 0;
+
+    if (($enable_streaming) && ($self->{'extract_keyframes'})) {
 	my $section = $doc_obj->get_top_section();
 	my $oflash_filename = $self->{'oflash_filename'};
@@ -663,5 +670,13 @@
     my $num_total_frames = $self->{'num-total-frames'};
 
-    my $frame_delta = $num_total_frames/$num_dist_frames;
+    my $keep_timeline = {};
+
+    my $frame_delta;
+    if ($num_dist_frames eq "all") {
+	$frame_delta = undef;
+    }
+    else {
+	$frame_delta = $num_total_frames/$num_dist_frames;
+    }
 
     my $closest_to = $frame_delta;
@@ -670,4 +685,6 @@
 #    print STDERR "*** num total frames  = $num_total_frames\n";
 #    print STDERR "*** frame delta = $frame_delta\n";
+
+    my $keep_keyframe_num = 1;
 
     foreach my $curr_t (sort { $a <=> $b } keys %$timeline)
@@ -675,8 +692,12 @@
 #	print STDERR "*** curr_t = $curr_t\n";
 	
-	if ($curr_t>$closest_to) {
+	my $timeline_rec = undef;
+
+	if (!defined $closest_to) {
+	    $timeline_rec = $timeline->{$curr_t};
+	    $keep_timeline->{$curr_t} = $timeline_rec;
+	}
+	elsif ($curr_t>$closest_to) {
 	    # decide if previous t (prev_t_ or current t (curr_t) is closest
-
-	    my $timeline_rec;
 
 	    my $prev_t_dist = $closest_to - $prev_t;
@@ -685,14 +706,23 @@
 	    if ($curr_t_dist <= $prev_t_dist)
 	    {
-		$timeline_rec = $timeline->{$curr_t}
+		$timeline_rec = $timeline->{$curr_t};
+		$keep_timeline->{$curr_t} = $timeline_rec;
+
 	    }
 	    else
 	    {
-		$timeline_rec = $timeline->{$prev_t}
+		$timeline_rec = $timeline->{$prev_t};
+		$keep_timeline->{$prev_t} = $timeline_rec;
 	    }
+
+	    $closest_to += $frame_delta;
+	}
+
+	if (defined $timeline_rec) {
 
 	    my $name      = $timeline_rec->{'name'};
 	    my $timestamp = $timeline_rec->{'timestamp'};
 	    my $thumb     = $timeline_rec->{'thumb'};
+	    my $keyframe_num = $timeline_rec->{'keyframenum'};
 
 
@@ -702,4 +732,6 @@
 	    print CUEOUT "    <parameters>\n";
 	    print CUEOUT "      <thumb>$thumb</thumb>\n";
+	    print CUEOUT "      <keyframeNum>$keyframe_num</keyframeNum>\n";
+	    print CUEOUT "      <keepKeyframeNum>$keep_keyframe_num</keepKeyframeNum>\n";
 	    print CUEOUT "    </parameters>\n";
 	    print CUEOUT "    <type>navigation</type>\n";
@@ -718,8 +750,11 @@
 #	    print CUEOUT "  </metatag>\n";
 
-	    $closest_to += $frame_delta;
+	    $keep_keyframe_num++;
+
 	}
 	$prev_t = $curr_t;
     }
+
+    $self->{'keep_keyframe_timeline'} = $keep_timeline;
 }
 
@@ -839,8 +874,8 @@
 				 'keyframeindex' => $keyframe_index,
 				 'timestamp' => $time_msec,
-				 'thumb' => $thumb_file };
+				 'thumb' => $thumb_file,
+				 'keyframenum' => $keyframe_index};
 
 	    $self->{'keyframe_timeline'}->{$half_frame_num}=$timeline_rec;
-
 	}
 
@@ -867,8 +902,8 @@
 			     'keyframeindex' => $keyframe_index,
 			     'timestamp' => $time_msec,
-			     'thumb' => $thumb_file };
+			     'thumb' => $thumb_file,
+			     'keyframenum' => $keyframe_index};
 
 	$self->{'keyframe_timeline'}->{$avg_frame_num}=$timeline_rec;
-
 
 	# $self->{'flowplayer_thumblist'} .= "\\{ thumbNail: '$thumb_file', time: $time_sec \\},"; 
@@ -884,5 +919,5 @@
     if ($element eq "seg") {
 
-	$self->output_distributed_keyframes($self->{'keyframe_timeline'},6);
+	$self->output_distributed_keyframes($self->{'keyframe_timeline'},$self->{'keep_keyframes'});
 
 
