Only in b: .DS_Store
diff -upr a/includes/Transcoder.inc b/includes/Transcoder.inc
--- a/includes/Transcoder.inc	2013-04-22 07:31:05.000000000 +0000
+++ b/includes/Transcoder.inc	2013-04-29 21:34:12.000000000 +0000
@@ -144,7 +144,7 @@ class Transcoder {
     $transcodingsuccess = TRUE;
     $output = array();
     $output_directory = str_replace('original', 'converted', drupal_dirname($video->uri)) . '/' . $video->fid;
-    $output_directory = $converted_scheme . '://' . file_uri_target($output_directory);
+    $output_directory = $converted_scheme . '://' . file_uri_target($output_directory);	
 
     if (!file_prepare_directory($output_directory, FILE_CREATE_DIRECTORY)) {
       watchdog('transcoder', 'Video conversion failed. Could not create the directory: %dir', array('%dir' => $output_directory), WATCHDOG_ERROR);
@@ -176,6 +176,17 @@ class Transcoder {
         $this->transcoder->setOutput($output_directory, $output_name);
         if ($output_file = $this->transcoder->execute()) {
           $output[] = $output_file;
+		  //Also collect segments for m3u8 playlists
+		  if ($preset['settings']['video_extension'] == 'm3u8') {
+		 	foreach (file($output_file->uri) as $line) {			
+			  if (substr($line, 0, 1) == '#') continue;
+			  $line = trim($line);
+			  $old_path = file_directory_temp() . '/'. $line;
+			  $new_path = $output_directory. '/'. $line;
+			  file_unmanaged_move($old_path, $new_path);
+			  $output[] = (object) array('filename' => $line, 'uri' => $new_path, 'filesize' => filesize($new_path), 'timestamp' => time(), 'duration' => $output_file->duration); 
+			}
+		  }
         }
         else {
           $transcodingsuccess = FALSE;
Only in b/libraries: .DS_Store
diff -upr a/libraries/phpvideotoolkit/phpvideotoolkit.php5.php b/libraries/phpvideotoolkit/phpvideotoolkit.php5.php
--- a/libraries/phpvideotoolkit/phpvideotoolkit.php5.php	2013-04-22 07:31:05.000000000 +0000
+++ b/libraries/phpvideotoolkit/phpvideotoolkit.php5.php	2013-04-29 01:30:43.000000000 +0000
@@ -1482,7 +1482,7 @@ class PHPVideoToolkit {
    * @return boolean FALSE on error encountered, TRUE otherwise
    */
   public function setAudioBitRate($bitrate) {
-    return $this->addCommand('-ab', $bitrate);
+    return $this->addCommand('-b:a', $bitrate);
   }
 
   /**
@@ -1561,7 +1561,7 @@ class PHPVideoToolkit {
    */
   public function setVideoBitRate($bitrate) {
     $bitrate = intval($bitrate);
-    return $this->addCommand('-b', $bitrate . 'k');
+    return $this->addCommand('-b:v', $bitrate . 'k');
   }
 
   /**
Only in b/modules: .DS_Store
diff -upr a/modules/video_ui/video.preset.inc b/modules/video_ui/video.preset.inc
--- a/modules/video_ui/video.preset.inc	2013-04-22 07:31:05.000000000 +0000
+++ b/modules/video_ui/video.preset.inc	2013-04-29 17:38:31.000000000 +0000
@@ -16,7 +16,7 @@ function video_preset_form($form, &$form
   $formats = $transcoder->getAvailableFormats('muxing');
   $pixelformats = $transcoder->getPixelFormats();
   $settings = $preset['settings'];
-
+  
   if (empty($formats)) {
     drupal_set_message(t('No video output extensions are available. Please reconfigure your <a href="@transcoder-url">video transcoder</a>.', array('@transcoder-url' => url('admin/config/media/video/transcoders'))), 'warning');
   }
@@ -325,7 +325,7 @@ function video_preset_form($form, &$form
     '#options' => $profiles,
     '#default_value' => !empty($settings['h264_profile']) ? $settings['h264_profile'] : '',
   );
-
+  
   // advanced audio settings
   $form['settings']['adv_audio'] = array(
     '#type' => 'fieldset',
@@ -531,6 +531,14 @@ function video_preset_form($form, &$form
     '#default_value' => !empty($settings['clip_length']) ? $settings['clip_length'] : '',
   );
 
+  if (get_class($transcoder) == 'TranscoderAbstractionFactoryFfmpeg') {
+    $form['settings']['custom_options'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Custom options'),
+      '#description' => t('Custom options to pass to FFmpeg (in command-line format), either adding to or overriding above settings.'),
+      '#default_value' => !empty($settings['custom_options']) ? $settings['custom_options'] : ''
+    );
+  }
 
   // Buttons
   $form['actions'] = array(
@@ -591,7 +599,7 @@ function video_preset_validate($form, &$
   // Silently uncheck the checkbox if there is no watermark file
   if (!empty($v['video_watermark_enabled']) && empty($v['video_watermark_fid'])) {
     $v['video_watermark_enabled'] = 0;
-  }
+  }  
 }
 
 /**
diff -upr a/theme/video-play-html5.tpl.php b/theme/video-play-html5.tpl.php
--- a/theme/video-play-html5.tpl.php	2013-04-22 07:31:05.000000000 +0000
+++ b/theme/video-play-html5.tpl.php	2013-04-30 14:34:58.000000000 +0000
@@ -32,9 +32,13 @@ $codecs = array(
 <video width="<?php echo $width; ?>" height="<?php echo $height; ?>" preload="<?php echo $preload; ?>" controls="controls" poster="<?php echo $poster; ?>"<?php echo $autoplayattr; ?>>
 <?php
 foreach ($files as $index => $file) {
-  if (strncmp($file->filemime, 'video/', 6) !== 0) {
+  if (strncmp($file->filemime, 'video/', 6) !== 0 && strncmp($file->filemime, 'application/', 12) !== 0) {
     continue;
   }
+  
+  if ($file->filemime == 'video/MP2T') {
+	continue;
+  }
 
   $filepath = check_plain(file_create_url($file->uri));
 
Only in b/theme: video-play-m3u8.tpl.php
diff -upr a/transcoders/TranscoderAbstractionFactoryFfmpeg.inc b/transcoders/TranscoderAbstractionFactoryFfmpeg.inc
--- a/transcoders/TranscoderAbstractionFactoryFfmpeg.inc	2013-04-22 07:31:05.000000000 +0000
+++ b/transcoders/TranscoderAbstractionFactoryFfmpeg.inc	2013-04-30 14:40:02.000000000 +0000
@@ -149,6 +149,12 @@ class TranscoderAbstractionFactoryFfmpeg
         case 'skip_audio':
           $result = $this->transcoder->addCommand('-an');
           break;
+        case 'custom_options':
+		  foreach (explode(' -', ' '.trim($value)) as $arg) {
+			list($opt, $val) = explode(' ', trim($arg));
+            if ($opt) $result = $this->transcoder->addCommand('-'.$opt, $val);
+		  }
+          break;  
       }
 
       if ($cliplength !== NULL && $clipstart !== NULL) {
@@ -345,6 +351,18 @@ class TranscoderAbstractionFactoryFfmpeg
       }
     }
 
+    // Post-process the file with custom command
+    $cmd = variable_get('video_ffmpeg_flvtool2_path');
+    if ($cmd != NULL && is_file($cmd) && $this->outputextension == 'flv') {
+      $output = array();
+      $retval = 0;
+      exec($cmd . ' -U ' . escapeshellarg($tmpoutputpath) . ' 2>&1', $output, $retval);
+
+      if ($retval != 0) {
+        watchdog('transcoder', 'Error while executing @cmdname on video @filename: @output', array('@cmdname' => 'flvtool2', '@filename' => $this->realoutputname, '@output' => implode("\n", $output)), WATCHDOG_ERROR);
+      }
+    }
+	
     $file_info = $this->getFileInfo();
     $realoutputuri = $this->realoutputdir . '/' . $this->realoutputname;
     copy($tmpoutputpath, $realoutputuri);
@@ -424,6 +442,7 @@ class TranscoderAbstractionFactoryFfmpeg
             $formats[$id] = $data['fullname'];
           }
         }
+  	    $formats['m3u8'] = 'Apple HTTP Live Streaming playlist';
         break;
       case 'demuxing' :
         foreach ($info['formats'] as $id => $data) {
diff -upr a/video.utility.inc b/video.utility.inc
--- a/video.utility.inc	2013-04-22 07:31:05.000000000 +0000
+++ b/video.utility.inc	2013-04-29 21:19:10.000000000 +0000
@@ -253,6 +253,7 @@ class video_utility {
       'ogv' => 'video_play_html5',
       'webm' => 'video_play_html5',
       'mp3' => 'video_play_html5',
+	  'm3u8' => 'video_play_html5',
     );
   }
 
