Index: /gs2-extensions/video-and-audio/trunk/src/perllib/plugins/SimpleVideoPlugin.pm
===================================================================
--- /gs2-extensions/video-and-audio/trunk/src/perllib/plugins/SimpleVideoPlugin.pm	(revision 29178)
+++ /gs2-extensions/video-and-audio/trunk/src/perllib/plugins/SimpleVideoPlugin.pm	(revision 29179)
@@ -99,8 +99,5 @@
                   { 'name' => "no_keyframes",
                     'desc' => "Disable keyframe extraction",
-                    'type' => "enum",
-                    'list' => [{'name' => "true", 'desc' => "{common.true}"},
-                               {'name' => "false", 'desc' => "{common.false}"}],
-                    'deft' => "false",
+                    'type' => "flag",
                     'reqd' => "no" },
                 ];
@@ -262,120 +259,146 @@
   # 2. Convert into FLV, reprocess to make seekable, and associate
   # - generate a path for our temporary converted video file
-  print STDERR " - Converting video to streamble format...\n";
   my $ovideo_path = &FileUtils::filenameConcatenate($tmp_dir, 'gsv.mp4');
-  if (&FileUtils::fileExists($ovideo_path))
-  {
-    print "   - Found existing converted video in cache!\n";
+  if ($self->{'streamingHQsize'} > 0)
+  {
+    print STDERR " - Converting video to streamble format...\n";
+    if (&FileUtils::fileExists($ovideo_path))
+    {
+      print "   - Found existing converted video in cache!\n";
+    }
+    else
+    {
+      # - first conversion pass
+      print "   - Convert using Handbrake\n";
+      my $streaming_HQ_size    = $self->{'streamingHQsize'};
+      my $streaming_HQ_VideoBitrate    = $self->{'streamingHQVideoBitrate'};
+      my $streaming_HQ_AudioBitrate    = $self->{'streamingHQAudioBitrate'};
+      my $deinterlace = $self->{'videoDeinterlacingFilter'};
+      my $video_processing_parameters;
+      if (!$streaming_HQ_size || $streaming_HQ_size eq "fullsize")
+      {
+        $video_processing_parameters = "--strict-anamorphic";
+      }
+      else
+      {
+        $video_processing_parameters = "-w $streaming_HQ_size --loose-anamorphic";
+      }
+      if ($deinterlace eq "true")
+      {
+        $video_processing_parameters .= " --decomb";
+      }
+      # Default MenCoder options for x264
+      my $mencoder_options = 'ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0';
+      my $is_cluster = $self->{'isCluster'};
+      my $is_parallel = $self->{'isParallel'};
+      # If we are parallel processing on a single (presumably) multicore computer
+      # then we need to limit the number of threads (and hence CPUs) HandBrake
+      # will utilize in order to emulate true parallel processing (otherwise the
+      # first thread to get to HandBrake conversion will take up most the CPUs
+      # causing all other threads to wait anyway). It will interesting to test
+      # whether parallel processing or serial processing (with HandBrake parallel
+      # processing) is faster. *update* threads=1 *only* controls the encoding and
+      # several other parts of Handbrake can run parallel (demuxing etc). I've
+      # had to include a 'taskset' command to truely make Handbrake serial
+      if ($is_parallel eq 'true'  && $is_cluster eq 'false')
+      {
+        $mencoder_options .= ':threads=1';
+      }
+      # Banish HandbrakeCLI to the (fixedCore-1)'th CPU if necessary
+      my $cmd = '';
+      if (defined $self->{'fixedCore'} && $self->{'fixedCore'} > 0)
+      {
+        $cmd .= 'taskset -c ' . ($self->{'fixedCore'} - 1) . ' ';
+      }
+      $cmd .= 'HandBrakeCLI -i "' . $ivideo_path . '" -t 1 -c 1 -f mp4 -O -o "' . $ovideo_path . '" ' . $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 ' . $mencoder_options . ' > "' . $convert_log_path . '" 2>&1';
+      my $attempt_count = 0;
+      do
+      {
+        $attempt_count++;
+        ###rint "[DEBUG: Video conversion attempt #" . $attempt_count . ": |" . $cmd . "|]\n";
+        `$cmd`;
+      }
+      while ($attempt_count < 5 && !&FileUtils::fileExists($ovideo_path))
+    }
+    if (!&FileUtils::fileExists($ovideo_path))
+    {
+      die("Fatal Error! Failed to convert video: " . $ovideo_path . "\nReason:" . $! . "\n");
+    }
+    # Extra check - ensure the converted video is approximately the same duration
+    # as the input video, given or take around 5 seconds
+    my $output_raw_video_duration = &getDuration($ovideo_path);
+    my $output_video_duration = &parseDurationAsSeconds($output_raw_video_duration);
+    if (abs($input_video_duration - $output_video_duration) > 5)
+    {
+      print STDERR "!Warning! Output video does not have same duration as input video.\n";
+    }
+    print STDERR " - conversion done!\n";
   }
   else
   {
-    # - first conversion pass
-    print "   - Convert using Handbrake\n";
-    my $streaming_HQ_size    = $self->{'streamingHQsize'};
-    my $streaming_HQ_VideoBitrate    = $self->{'streamingHQVideoBitrate'};
-    my $streaming_HQ_AudioBitrate    = $self->{'streamingHQAudioBitrate'};
-    my $deinterlace = $self->{'videoDeinterlacingFilter'};
-    my $video_processing_parameters;
-    if (!$streaming_HQ_size || $streaming_HQ_size eq "fullsize")
-    {
-      $video_processing_parameters = "--strict-anamorphic";
+    print "   - skipping web-streamable conversion\n";
+  }
+
+  # 3. Extract keyframes using hive
+  my $generate_keyframes = 1;
+  if (defined $self->{'no_keyframes'} && $self->{'no_keyframes'} == 1)
+  {
+    $generate_keyframes = 0;
+    print "   - skipping keyframe generation\n";
+  }
+  else
+  {
+    print STDERR " - extract keyframes...\n";
+    $tmp_dir = '/tmp/ramdrive';
+    my $oshots_path = &FileUtils::filenameConcatenate($tmp_dir, 'shots.xml');
+    if (&FileUtils::fileExists($oshots_path))
+    {
+      print "   - found existing keyframe images in cache\n";
     }
     else
     {
-      $video_processing_parameters = "-w $streaming_HQ_size --loose-anamorphic";
-    }
-    if ($deinterlace eq "true")
-    {
-      $video_processing_parameters .= " --decomb";
-    }
-    # Default MenCoder options for x264
-    my $mencoder_options = 'ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0';
-    my $is_cluster = $self->{'isCluster'};
-    my $is_parallel = $self->{'isParallel'};
-    # If we are parallel processing on a single (presumably) multicore computer
-    # then we need to limit the number of threads (and hence CPUs) HandBrake
-    # will utilize in order to emulate true parallel processing (otherwise the
-    # first thread to get to HandBrake conversion will take up most the CPUs
-    # causing all other threads to wait anyway). It will interesting to test
-    # whether parallel processing or serial processing (with HandBrake parallel
-    # processing) is faster. *update* threads=1 *only* controls the encoding and
-    # several other parts of Handbrake can run parallel (demuxing etc). I've
-    # had to include a 'taskset' command to truely make Handbrake serial
-    if ($is_parallel eq 'true'  && $is_cluster eq 'false')
-    {
-      $mencoder_options .= ':threads=1';
-    }
-    # Banish HandbrakeCLI to the (fixedCore-1)'th CPU if necessary
-    my $cmd = '';
-    if (defined $self->{'fixedCore'} && $self->{'fixedCore'} > 0)
-    {
-      $cmd .= 'taskset -c ' . ($self->{'fixedCore'} - 1) . ' ';
-    }
-    $cmd .= 'HandBrakeCLI -i "' . $ivideo_path . '" -t 1 -c 1 -f mp4 -O -o "' . $ovideo_path . '" ' . $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 ' . $mencoder_options . ' > "' . $convert_log_path . '" 2>&1';
-    my $attempt_count = 0;
-    do
-    {
-      $attempt_count++;
-      ###rint "[DEBUG: Video conversion attempt #" . $attempt_count . ": |" . $cmd . "|]\n";
+      print "   - generating keyframe images using Hive2\n";
+      my $cmd = 'hive2_ffmpegsvn -o "' . $oshots_path . '" -k "' . $tmp_dir . '" "' . $ovideo_path . '" >> "' . $convert_log_path . '" 2>&1';
+      ###print "[cmd: " . $cmd . "]\n";
       `$cmd`;
     }
-    while ($attempt_count < 5 && !&FileUtils::fileExists($ovideo_path))
-  }
-  if (!&FileUtils::fileExists($ovideo_path))
-  {
-    die("Fatal Error! Failed to convert video: " . $ovideo_path . "\nReason:" . $! . "\n");
-  }
-  # Extra check - ensure the converted video is approximately the same duration
-  # as the input video, given or take around 5 seconds
-  my $output_raw_video_duration = &getDuration($ovideo_path);
-  my $output_video_duration = &parseDurationAsSeconds($output_raw_video_duration);
-  if (abs($input_video_duration - $output_video_duration) > 5)
-  {
-    print STDERR "!Warning! Output video does not have same duration as input video.\n";
-  }
-  print STDERR " - conversion done!\n";
-
-  # 3. Extract keyframes using hive
-  print STDERR " - extract keyframes...\n";
-  my $oshots_path = &FileUtils::filenameConcatenate($tmp_dir, 'shots.xml');
-  if (&FileUtils::fileExists($oshots_path))
-  {
-    print "   - found existing keyframe images in cache\n";
-  }
-  else
-  {
-    print "   - generating keyframe images using Hive2\n";
-    my $cmd = 'hive2_ffmpegsvn -o "' . $oshots_path . '" -k "' . $tmp_dir . '" "' . $ovideo_path . '" >> "' . $convert_log_path . '" 2>&1';
-    ###print "[cmd: " . $cmd . "]\n";
-    `$cmd`;
-  }
-  if (!&FileUtils::fileExists($oshots_path))
-  {
-    die("Fatal Error! Failed to extract keyframe images: " . $oshots_path . "\nReason:" . $! . "\n");
-  }
-  print STDERR "  - keyframes extracted!\n";
-
+    if (!&FileUtils::fileExists($oshots_path))
+    {
+      die("Fatal Error! Failed to extract keyframe images: " . $oshots_path . "\nReason:" . $! . "\n");
+    }
+    print STDERR "  - keyframes extracted!\n";
+  }
 
   # 4. Associate files (copies back to shared space if IO separated)
   print STDERR " - Associate derived files to doc_obj... ";
   # - associate streamable video
-  $doc_obj->associate_file($ovideo_path,'gsv.mp4','video/mp4',$topsection);
+  if (-f $ovideo_path)
+  {
+    $doc_obj->associate_file($ovideo_path, 'gsv.mp4', 'video/mp4', $topsection);
+  }
+  else
+  {
+    $doc_obj->associate_file($ivideo_path, 'gsv.ts', 'video/ts', $topsection);
+  }
   # - associate all of the JPGs found in the temp directory
-  opendir(my $dh, $tmp_dir);
-  my @shots = readdir($dh);
-  closedir($dh);
-  my $thumbnail = 0;
-  foreach my $shot (sort @shots)
-  {
-    my $shot_path = &FileUtils::filenameConcatenate($tmp_dir, $shot);
-    if ($shot =~ /.jpg$/)
-    {
-      if (!$thumbnail)
-      {
-        $doc_obj->add_utf8_metadata($topsection,"Thumbnail",$shot);
-        $thumbnail = 1;
-      }
-      $doc_obj->add_utf8_metadata($topsection,"Keyframe",$shot);
-      $doc_obj->associate_file($shot_path,$shot,"image/jpeg",$topsection);
+  if ($generate_keyframes)
+  {
+    opendir(my $dh, $tmp_dir);
+    my @shots = readdir($dh);
+    closedir($dh);
+    my $thumbnail = 0;
+    foreach my $shot (sort @shots)
+    {
+      my $shot_path = &FileUtils::filenameConcatenate($tmp_dir, $shot);
+      if ($shot =~ /.jpg$/)
+      {
+        if (!$thumbnail)
+        {
+          $doc_obj->add_utf8_metadata($topsection,"Thumbnail",$shot);
+          $thumbnail = 1;
+        }
+        $doc_obj->add_utf8_metadata($topsection,"Keyframe",$shot);
+        #$doc_obj->associate_file($shot_path,$shot,"image/jpeg",$topsection);
+      }
     }
   }
