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-05-03 19:44: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);
@@ -156,6 +156,7 @@ class Transcoder {
       $transcodingsuccess = FALSE;
     }
     else {
+	  $starttime = time();
       foreach ($presets as $name => $preset) {
         // override the widthXheight if enabled
         $preset['settings']['wxh'] = (variable_get('video_use_preset_wxh', FALSE)) ? $preset['settings']['wxh'] : $video->dimensions;
@@ -175,6 +176,121 @@ class Transcoder {
         $output_name = file_munge_filename(str_replace(' ', '_', pathinfo($video->filename, PATHINFO_FILENAME) . ' ' . strtolower($name)) . '_' . time() . '.' . $preset['settings']['video_extension'], '');
         $this->transcoder->setOutput($output_directory, $output_name);
         if ($output_file = $this->transcoder->execute()) {
+		  //Collect .ts streams 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;
+			  $streams_dir = $output_directory . '/streams';
+			  $new_path = $streams_dir . '/' . $line;
+		      if (!file_prepare_directory($streams_dir, FILE_CREATE_DIRECTORY)) {
+		        watchdog('transcoder', 'Video conversion failed. Could not create the streams directory: %dir', array('%dir' => $streams_dir), WATCHDOG_ERROR);
+		        $transcodingsuccess = FALSE;
+		      }
+			  if (!file_unmanaged_move($old_path, $new_path, FILE_EXISTS_REPLACE)) {
+  		        watchdog('transcoder', 'Video conversion failed. Could not move stream segment to streams directory: %dir', array('%dir' => $old_path), WATCHDOG_ERROR);
+  		        $transcodingsuccess = FALSE;
+  		      }
+			  $output[] = (object) array('filename' => $line, 'uri' => $new_path, 'filesize' => filesize($new_path), 'timestamp' => time()); 
+			}
+		  }
+		  //Add to master m3u8 index (if applicable)
+		  if ($preset['settings']['master_index']) {
+			$m3u8 = ($preset['settings']['video_extension'] == 'm3u8');
+			$master_extension = ($m3u8) ? '.m3u8' : '_' . $preset['settings']['video_extension'] . '.smil';
+			$master_name = file_munge_filename(str_replace(' ', '_', pathinfo($video->filename, PATHINFO_FILENAME)) . '_master_' . $starttime . $master_extension, '');
+			$master_path = $output_directory . '/' . $master_name;
+			
+			$codecs = array(
+			  'audio' => array(
+			    'mp4a.40.2' => array('audio_codec' => 'aac'),
+			    'mp4a.40.5' => array('audio_codec' => 'libfdk_aac'),
+			    'mp4a.40.34' => array('audio_codec' => 'mp3'),
+			  ),
+			  'video' => array(
+			    'avc1.66.30' => array('video_codec' => 'h264', 'h264_profile' => 'baseline', 'custom_options' => '-level 3.0'),
+			    'avc1.42001f' => array('video_codec' => 'h264', 'h264_profile' => 'baseline', 'custom_options' => '-level 3.1'),
+			    'avc1.77.30' => array('video_codec' => 'h264', 'h264_profile' => 'main', 'custom_options' => '-level 3.0'),
+			    'avc1.4d001f' => array('video_codec' => 'h264', 'h264_profile' => 'main', 'custom_options' => '-level 3.1'),
+			    'avc1.100.30' => array('video_codec' => 'h264', 'h264_profile' => 'high', 'custom_options' => '-level 3.0'),
+			    'avc1.100.31' => array('video_codec' => 'h264', 'h264_profile' => 'high', 'custom_options' => '-level 3.1'),
+			  ),
+			);
+			$codecs_this = array();
+			foreach ($codecs as $type => $codecs_arr) {
+			  if ($preset['settings']["skip_$type"]) continue;
+			  foreach($codecs_arr as $codec => $cond_arr) {
+			    foreach ($cond_arr as $key => $val) {
+				  if ($key != 'custom_options') {
+				    if ($preset['settings'][$key] != $val) continue 2;
+				  }
+				  else {
+				    if (!stristr($preset['settings'][$key], $val)) continue 2;
+				  }
+			    }
+			    $codecs_this[] = $codec;
+			  }
+			}
+			
+			$master_contents = '';
+			if (file_exists($master_path)) {
+			  $master_contents = file_get_contents($master_path);
+			} 
+
+			if ($m3u8) {
+			  if (empty($master_contents)) $master_contents = "#EXTM3U\n"; 
+  			  $master_contents .= '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=' . (((int) $preset['settings']['video_bitrate'] + (int) $preset['settings']['audio_bitrate']) * 1000);
+			  if (!$preset['settings']['skip_video']) $master_contents .= ',RESOLUTION=' . trim($preset['settings']['wxh']);
+	 		  if (!empty($codecs_this)) $master_contents .= ',CODECS="' . implode(',', $codecs_this) . '"';
+  			  $master_contents .= "\n" . file_create_url($streams_dir . '/' . $output_file->filename) . "\n";
+			} else {
+		 	  $rtmp_app = $preset['settings']['master_rtmp_app'];
+			  list($width, $height) = explode('x', $preset['settings']['wxh']);
+  			  if (empty($master_contents)) $master_contents = "
+<smil>
+  <head>
+    <meta base='$rtmp_app' />
+  </head>
+  <body>
+    <switch></switch>
+  </body>
+</smil>";
+			  $master_bits = explode('</switch>', $master_contents); 
+			  $master_contents = $master_bits[0] . "
+      <video src='" . substr($output_directory, strpos($output_directory, '://') + 3) . '/' . $output_name . "' system-bitrate='" . (((int) $preset['settings']['video_bitrate'] + (int) $preset['settings']['audio_bitrate']) * 1000) . "' height='" . $height . "' width='" . $width . "'>";
+		  	  $master_contents .= "
+	    <param name='audioBitrate' value='" . $preset['settings']['audio_bitrate'] * 1000 . "' valuetype='data'/>";
+  	  		  $master_contents .= "
+	    <param name='videoBitrate' value='" . $preset['settings']['video_bitrate'] * 1000 . "' valuetype='data'/>";
+	  		  if (!empty($codecs_this)) {
+			    foreach ($codecs_this as $codec) {
+				  $codec_type = (substr($codec, 0, 3) == 'avc') ? 'videoCodecId' : 'audioCodecId';
+				  $master_contents .= "
+	    <param name='$codec_type' value='$codec' valuetype='data'/>";
+				}
+			  }
+			  $master_contents .= "</video>
+    </switch>" . $master_bits[1];
+			}
+
+			if (!file_unmanaged_save_data($master_contents, $master_path, FILE_EXISTS_REPLACE)) {
+   			  watchdog('transcoder', 'Video conversion failed. Could not save master master index file: %dir', array('%dir' => $master_path), WATCHDOG_ERROR);
+    	      $transcodingsuccess = FALSE;
+    		}
+			$output[$master_extension] = (object) array('filename' => $master_name, 'uri' => $master_path, 'filesize' => filesize($master_path), 'timestamp' => time(), 'duration' => $output_file->duration);
+
+		    if ($m3u8) {
+			  //Move $output_file to /streams dir to enable hiding in player template files
+			  $old_path = $output_file->uri;
+			  $new_path = $streams_dir . '/' . $output_file->filename;
+			  if (!file_unmanaged_move($old_path, $new_path, FILE_EXISTS_REPLACE)) {
+  		        watchdog('transcoder', 'Video conversion failed. Could not move m3u8 file to streams directory: %dir', array('%dir' => $old_path), WATCHDOG_ERROR);
+  		        $transcodingsuccess = FALSE;
+  		      }
+			  else $output_file->uri = $new_path;
+		    }
+		  }
           $output[] = $output_file;
         }
         else {
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-30 20:02:39.000000000 +0000
@@ -65,16 +65,16 @@ class PHPVideoToolkit {
     'streamFLV_no_input' => 'Input file has not been set so the FLV cannot be streamed.',
     'streamFLV_passed_eof' => 'You have tried to stream to a point in the file that does not exit.',
     'setInputFile_file_existence' => 'Input file "#file" does not exist',
-    'extractAudio_valid_format' => 'Value "#format" set from $toolkit->extractAudio, is not a valid audio format. Valid values ffmpeg self::FORMAT_AAC, PHPVideoToolkit::FORMAT_AIFF, PHPVideoToolkit::FORMAT_MP2, PHPVideoToolkit::FORMAT_MP3, PHPVideoToolkit::FORMAT_MP4, PHPVideoToolkit::FORMAT_MPEG4, PHPVideoToolkit::FORMAT_M4A or PHPVideoToolkit::FORMAT_WAV. If you wish to specifically try to set another format you should use the advanced function $toolkit->addCommand. Set $command to "-f" and $argument to your required value.',
+    'extractAudio_valid_format' => 'Value "#format" set from $toolkit->extractAudio, is not a valid audio format. Valid values ffmpeg self::FORMAT_AAC, PHPVideoToolkit::FORMAT_LIBFDK_AAC,  PHPVideoToolkit::FORMAT_AIFF, PHPVideoToolkit::FORMAT_MP2, PHPVideoToolkit::FORMAT_MP3, PHPVideoToolkit::FORMAT_MP4, PHPVideoToolkit::FORMAT_MPEG4, PHPVideoToolkit::FORMAT_M4A or PHPVideoToolkit::FORMAT_WAV. If you wish to specifically try to set another format you should use the advanced function $toolkit->addCommand. Set $command to "-f" and $argument to your required value.',
     'extractFrame_video_frame_rate_404' => 'You have attempted to extract a thumbnail from a video while automagically guessing the framerate of the video, but the framerate could not be accessed. You can remove this error by manually setting the frame rate of the video.',
     'extractFrame_video_info_404' => 'You have attempted to extract a thumbnail from a video and check to see if the thumbnail exists, however it was not possible to access the video information. Please check your temporary directory permissions for read/write access by the webserver.',
     'extractFrame_video_frame_count' => 'You have attempted to extract a thumbnail from a video but the thumbnail you are trying to extract does not exist in the video.',
     'extractFrames_video_begin_frame_count' => 'You have attempted to extract thumbnails from a video but the thumbnail you are trying to start the extraction from does not exist in the video.',
     'extractFrames_video_end_frame_count' => 'You have attempted to extract thumbnails from a video but the thumbnail you are trying to end the extraction at does not exist in the video.',
-    'setFormat_valid_format' => 'Value "#format" set from $toolkit->setFormat, is not a valid format. Valid values are PHPVideoToolkit::FORMAT_3GP2, PHPVideoToolkit::FORMAT_3GP, PHPVideoToolkit::FORMAT_AAC, PHPVideoToolkit::FORMAT_AIFF, PHPVideoToolkit::FORMAT_AMR, PHPVideoToolkit::FORMAT_ASF, PHPVideoToolkit::FORMAT_AVI, PHPVideoToolkit::FORMAT_FLV, PHPVideoToolkit::FORMAT_GIF, PHPVideoToolkit::FORMAT_MJ2, PHPVideoToolkit::FORMAT_MP2, PHPVideoToolkit::FORMAT_MP3, PHPVideoToolkit::FORMAT_MP4, PHPVideoToolkit::FORMAT_MPEG4, PHPVideoToolkit::FORMAT_M4A, PHPVideoToolkit::FORMAT_MPEG, PHPVideoToolkit::FORMAT_MPEG1, PHPVideoToolkit::FORMAT_MPEG2, PHPVideoToolkit::FORMAT_MPEGVIDEO, PHPVideoToolkit::FORMAT_PSP, PHPVideoToolkit::FORMAT_RM, PHPVideoToolkit::FORMAT_SWF, PHPVideoToolkit::FORMAT_VOB, PHPVideoToolkit::FORMAT_WAV, PHPVideoToolkit::FORMAT_JPG. If you wish to specifically try to set another format you should use the advanced function $toolkit->addCommand. Set $command to "-f" and $argument to your required value.',
+    'setFormat_valid_format' => 'Value "#format" set from $toolkit->setFormat, is not a valid format. Valid values are PHPVideoToolkit::FORMAT_3GP2, PHPVideoToolkit::FORMAT_3GP, PHPVideoToolkit::FORMAT_AAC, PHPVideoToolkit::FORMAT_LIBFDK_AAC, PHPVideoToolkit::FORMAT_AIFF, PHPVideoToolkit::FORMAT_AMR, PHPVideoToolkit::FORMAT_ASF, PHPVideoToolkit::FORMAT_AVI, PHPVideoToolkit::FORMAT_FLV, PHPVideoToolkit::FORMAT_GIF, PHPVideoToolkit::FORMAT_MJ2, PHPVideoToolkit::FORMAT_MP2, PHPVideoToolkit::FORMAT_MP3, PHPVideoToolkit::FORMAT_MP4, PHPVideoToolkit::FORMAT_MPEG4, PHPVideoToolkit::FORMAT_M4A, PHPVideoToolkit::FORMAT_MPEG, PHPVideoToolkit::FORMAT_MPEG1, PHPVideoToolkit::FORMAT_MPEG2, PHPVideoToolkit::FORMAT_MPEGVIDEO, PHPVideoToolkit::FORMAT_PSP, PHPVideoToolkit::FORMAT_RM, PHPVideoToolkit::FORMAT_SWF, PHPVideoToolkit::FORMAT_VOB, PHPVideoToolkit::FORMAT_WAV, PHPVideoToolkit::FORMAT_JPG. If you wish to specifically try to set another format you should use the advanced function $toolkit->addCommand. Set $command to "-f" and $argument to your required value.',
     'setAudioChannels_valid_channels' => 'Value "#channels" set from $toolkit->setAudioChannels, is not a valid integer. Valid values are 1, or 2. If you wish to specifically try to set another channels value you should use the advanced function $toolkit->addCommand. Set $command to "-ac" and $argument to your required value.',
     'setAudioSampleFrequency_valid_frequency' => 'Value "#frequency" set from $toolkit->setAudioSampleFrequency, is not a valid integer. Valid values are 11025, 22050, 44100. If you wish to specifically try to set another frequency you should use the advanced function $toolkit->addCommand. Set $command to "-ar" and $argument to your required value.',
-    'setAudioFormat_valid_format' => 'Value "#format" set from $toolkit->setAudioCodec, is not a valid format. Valid values are PHPVideoToolkit::FORMAT_AAC, PHPVideoToolkit::FORMAT_AIFF, PHPVideoToolkit::FORMAT_AMR, PHPVideoToolkit::FORMAT_ASF, PHPVideoToolkit::FORMAT_MP2, PHPVideoToolkit::FORMAT_MP3, PHPVideoToolkit::FORMAT_MP4, PHPVideoToolkit::FORMAT_MPEG2, PHPVideoToolkit::FORMAT_RM, PHPVideoToolkit::FORMAT_WAV. If you wish to specifically try to set another format you should use the advanced function $toolkit->addCommand. Set $command to "-acodec" and $argument to your required value.',
+    'setAudioFormat_valid_format' => 'Value "#format" set from $toolkit->setAudioCodec, is not a valid format. Valid values are PHPVideoToolkit::FORMAT_AAC, PHPVideoToolkit::FORMAT_LIBFDK_AAC, PHPVideoToolkit::FORMAT_AIFF, PHPVideoToolkit::FORMAT_AMR, PHPVideoToolkit::FORMAT_ASF, PHPVideoToolkit::FORMAT_MP2, PHPVideoToolkit::FORMAT_MP3, PHPVideoToolkit::FORMAT_MP4, PHPVideoToolkit::FORMAT_MPEG2, PHPVideoToolkit::FORMAT_RM, PHPVideoToolkit::FORMAT_WAV. If you wish to specifically try to set another format you should use the advanced function $toolkit->addCommand. Set $command to "-acodec" and $argument to your required value.',
     'setAudioFormat_cannnot_encode' => 'Value "#codec" set from $toolkit->setAudioCodec, can not be used to encode the output as the version of FFmpeg that you are using does not have the capability to encode audio with this codec.',
     'setVideoFormat_valid_format' => 'Value "#format" set from $toolkit->setVideoCodec, is not a valid format. Valid values are PHPVideoToolkit::FORMAT_3GP2, PHPVideoToolkit::FORMAT_3GP, PHPVideoToolkit::FORMAT_AVI, PHPVideoToolkit::FORMAT_FLV, PHPVideoToolkit::FORMAT_GIF, PHPVideoToolkit::FORMAT_MJ2, PHPVideoToolkit::FORMAT_MP4, PHPVideoToolkit::FORMAT_MPEG4, PHPVideoToolkit::FORMAT_M4A, PHPVideoToolkit::FORMAT_MPEG, PHPVideoToolkit::FORMAT_MPEG1, PHPVideoToolkit::FORMAT_MPEG2, PHPVideoToolkit::FORMAT_MPEGVIDEO. If you wish to specifically try to set another format you should use the advanced function $toolkit->addCommand. Set $command to "-vcodec" and $argument to your required value.',
     'setVideoFormat_cannnot_encode' => 'Value "#codec" set from $toolkit->setVideoCodec, can not be used to encode the output as the version of FFmpeg that you are using does not have the capability to encode video with this codec.',
@@ -145,6 +145,7 @@ class PHPVideoToolkit {
    * 3g2             3gp2 format
    * 3gp             3gp format
    * aac             ADTS AAC
+   * libfdk_aac             FDK AAC
    * aiff            Audio IFF
    * amr             3gpp amr file format
    * asf             asf format
@@ -171,6 +172,7 @@ class PHPVideoToolkit {
   const FORMAT_3GP2 = '3g2';
   const FORMAT_3GP = '3gp';
   const FORMAT_AAC = 'aac';
+  const FORMAT_LIBFDK_AAC = 'libfdk_aac';
   const FORMAT_AIFF = 'aiff';
   const FORMAT_AMR = 'amr';
   const FORMAT_ASF = 'asf';
@@ -840,6 +842,7 @@ class PHPVideoToolkit {
   public function hasCodecSupport($codec, $support=PHPVideoToolkit::ENCODE) {
     $codec = strtolower($codec);
     $data = $this->getFFmpegInfo();
+	if ($codec == 'libfdk_aac') $codec = 'aac';
     return isset($data['formats'][$codec]) === TRUE ? $data['formats'][$codec][$support] : FALSE;
   }
 
@@ -1305,7 +1308,7 @@ class PHPVideoToolkit {
    * */
   public function extractAudio($format=PHPVideoToolkit::FORMAT_MP3, $audio_sample_frequency=44100, $audio_bitrate=64) {
 // 			check the format is one of the audio formats
-    if (!in_array($format, array(self::FORMAT_AAC, self::FORMAT_AIFF, self::FORMAT_MP2, self::FORMAT_MP3, self::FORMAT_MP4, self::FORMAT_MPEG4, self::FORMAT_M4A, self::FORMAT_WAV))) {
+    if (!in_array($format, array(self::FORMAT_AAC, self::FORMAT_LIBFDK_AAC, self::FORMAT_AIFF, self::FORMAT_MP2, self::FORMAT_MP3, self::FORMAT_MP4, self::FORMAT_MPEG4, self::FORMAT_M4A, self::FORMAT_WAV))) {
       return $this->_raiseError('extractAudio_valid_format', array('format' => $format));
 // <-			exits
     }
@@ -1324,6 +1327,7 @@ class PHPVideoToolkit {
    * 		PHPVideoToolkit::FORMAT_3GP2 - 3g2
    * 		PHPVideoToolkit::FORMAT_3GP - 3gp
    * 		PHPVideoToolkit::FORMAT_AAC - aac
+   * 		PHPVideoToolkit::FORMAT_LIBFDK_AAC - libfdk_aac
    * 		PHPVideoToolkit::FORMAT_AIFF - aiff
    * 		PHPVideoToolkit::FORMAT_AMR - amr
    * 		PHPVideoToolkit::FORMAT_ASF - asf
@@ -1350,7 +1354,7 @@ class PHPVideoToolkit {
    */
   public function setFormat($format) {
 //			validate input
-    if (!in_array($format, array(self::FORMAT_3GP2, self::FORMAT_3GP, self::FORMAT_AAC, self::FORMAT_AIFF, self::FORMAT_AMR, self::FORMAT_ASF, self::FORMAT_AVI, self::FORMAT_FLV, self::FORMAT_GIF, self::FORMAT_MJ2, self::FORMAT_MP2, self::FORMAT_MP3, self::FORMAT_MP4, self::FORMAT_MPEG4, self::FORMAT_M4A, self::FORMAT_MPEG, self::FORMAT_MPEG1, self::FORMAT_MPEG2, self::FORMAT_MPEGVIDEO, self::FORMAT_PSP, self::FORMAT_RM, self::FORMAT_SWF, self::FORMAT_VOB, self::FORMAT_WAV, self::FORMAT_JPG))) {
+    if (!in_array($format, array(self::FORMAT_3GP2, self::FORMAT_3GP, self::FORMAT_AAC, self::FORMAT_LIBFDK_AAC, self::FORMAT_AIFF, self::FORMAT_AMR, self::FORMAT_ASF, self::FORMAT_AVI, self::FORMAT_FLV, self::FORMAT_GIF, self::FORMAT_MJ2, self::FORMAT_MP2, self::FORMAT_MP3, self::FORMAT_MP4, self::FORMAT_MPEG4, self::FORMAT_M4A, self::FORMAT_MPEG, self::FORMAT_MPEG1, self::FORMAT_MPEG2, self::FORMAT_MPEGVIDEO, self::FORMAT_PSP, self::FORMAT_RM, self::FORMAT_SWF, self::FORMAT_VOB, self::FORMAT_WAV, self::FORMAT_JPG))) {
       // return $this->_raiseError('setFormat_valid_format', array('format'=>$format));
 // <-			exits
     }
@@ -1385,13 +1389,13 @@ class PHPVideoToolkit {
    * Sets the audio format for audio outputs
    *
    * @access public
-   * @param integer $audio_codec Valid values are PHPVideoToolkit::FORMAT_AAC, PHPVideoToolkit::FORMAT_AIFF, PHPVideoToolkit::FORMAT_AMR, PHPVideoToolkit::FORMAT_ASF, PHPVideoToolkit::FORMAT_MP2, PHPVideoToolkit::FORMAT_MP3, PHPVideoToolkit::FORMAT_MP4, PHPVideoToolkit::FORMAT_MPEG2, PHPVideoToolkit::FORMAT_RM, PHPVideoToolkit::FORMAT_WAV
+   * @param integer $audio_codec Valid values are PHPVideoToolkit::FORMAT_AAC, PHPVideoToolkit::FORMAT_LIBFDK_AAC, PHPVideoToolkit::FORMAT_AIFF, PHPVideoToolkit::FORMAT_AMR, PHPVideoToolkit::FORMAT_ASF, PHPVideoToolkit::FORMAT_MP2, PHPVideoToolkit::FORMAT_MP3, PHPVideoToolkit::FORMAT_MP4, PHPVideoToolkit::FORMAT_MPEG2, PHPVideoToolkit::FORMAT_RM, PHPVideoToolkit::FORMAT_WAV
    * @param boolean $validate_codec Queries ffmpeg to see if this codec is available to use.
    * @return boolean FALSE on error encountered, TRUE otherwise
    */
   public function setAudioCodec($audio_codec, $validate_codec=TRUE) {
 //			validate input
-    if (!in_array($audio_codec, array(self::FORMAT_AAC, self::FORMAT_AIFF, self::FORMAT_AMR, self::FORMAT_ASF, self::FORMAT_MP2, self::FORMAT_MP3, self::FORMAT_MP4, self::FORMAT_MPEG2, self::FORMAT_RM, self::FORMAT_WAV))) {
+    if (!in_array($audio_codec, array(self::FORMAT_AAC, self::FORMAT_LIBFDK_AAC, self::FORMAT_AIFF, self::FORMAT_AMR, self::FORMAT_ASF, self::FORMAT_MP2, self::FORMAT_MP3, self::FORMAT_MP4, self::FORMAT_MPEG2, self::FORMAT_RM, self::FORMAT_WAV))) {
       // return $this->_raiseError('setAudioFormat_valid_format', array('format'=>$audio_codec));
 // <-			exits
     }
@@ -1482,7 +1486,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 +1565,7 @@ class PHPVideoToolkit {
    */
   public function setVideoBitRate($bitrate) {
     $bitrate = intval($bitrate);
-    return $this->addCommand('-b', $bitrate . 'k');
+    return $this->addCommand('-b:v', $bitrate . 'k');
   }
 
   /**
@@ -2571,6 +2575,7 @@ class PHPVideoToolkit {
    */
   public function validateCodec($codec, $type, $method) {
     $info = $this->getFFmpegInfo();
+	if ($codec == 'libfdk_aac') $codec = 'aac';
     return isset($info['codecs'][$type]) === TRUE && isset($info['codecs'][$type][$codec]) === TRUE && isset($info['codecs'][$type][$codec][$method]) === TRUE ? $info['codecs'][$type][$codec][$method] : FALSE;
   }
 
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-05-01 18:47:25.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,7 +531,27 @@ 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'] : ''
+    );
+    $form['settings']['master_index'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Add to master index'),
+      '#description' => t('Add entry to master smil/m3u8 index for this video (eg. for adaptive bitrate streaming)'),
+      '#default_value' => !empty($settings['master_index']) ? $settings['master_index'] : 1,
+    );
+    $form['settings']['master_rtmp_app'] = array(
+      '#type' => 'textfield',
+      '#title' => t('RTMP App URL'),
+      '#description' => t('If using a master smil index (for RTMP streaming), provide the URL of the RTMP app eg. rtmp://example.com/application'),
+      '#default_value' => !empty($settings['master_rtmp_app']) ? $settings['master_rtmp_app'] : '',
+    );
+  }
+  
   // Buttons
   $form['actions'] = array(
       '#type' => 'actions',
@@ -591,7 +611,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/modules/zencoderapi/zencoderapi.info b/modules/zencoderapi/zencoderapi.info
--- a/modules/zencoderapi/zencoderapi.info	2013-04-23 05:05:16.000000000 +0000
+++ b/modules/zencoderapi/zencoderapi.info	2013-04-30 17:38:45.000000000 +0000
@@ -2,7 +2,7 @@ name = Zencoder API
 description = This module provides the Zencoder API. Only enable this module when another module needs it.
 package = Media
 core = 7.x
-dependencies[] = libraries (2.x)
+dependencies[] = libraries
 
 ; Information added by drupal.org packaging script on 2013-04-23
 version = "7.x-2.10"
Only in b/theme: .DS_Store
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 22:14:33.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 (basename(dirname($file->uri)) == 'streams') {
+	continue;
+  }
 
   $filepath = check_plain(file_create_url($file->uri));
 
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-05-03 17:15:58.000000000 +0000
@@ -149,6 +149,15 @@ class TranscoderAbstractionFactoryFfmpeg
         case 'skip_audio':
           $result = $this->transcoder->addCommand('-an');
           break;
+        case 'custom_options':
+		  foreach (explode(' -', ' '.trim($value)) as $arg) {
+			$opt_val = explode(' ', trim($arg));
+			if (is_array($opt_val) && !empty($opt_val[1])) {
+			  list($opt, $val) = $opt_val;
+              $result = $this->transcoder->addCommand('-'.$opt, $val);
+		    }
+		  }
+          break;  
       }
 
       if ($cliplength !== NULL && $clipstart !== NULL) {
@@ -345,6 +354,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);
@@ -393,6 +414,7 @@ class TranscoderAbstractionFactoryFfmpeg
             $codecs['decode'][$key][$codec_key] = $codec['fullname'];
           }
         }
+		$codecs['encode']['audio']['libfdk_aac'] = 'HE-AAC (encoder: libfdk_aac)';
         uasort($codecs['encode'][$key], 'strnatcasecmp');
         uasort($codecs['encode'][$key], 'strnatcasecmp');
       }
@@ -424,6 +446,7 @@ class TranscoderAbstractionFactoryFfmpeg
             $formats[$id] = $data['fullname'];
           }
         }
+  	    $formats['m3u8'] = 'Apple HTTP Live Streaming playlist';
         break;
       case 'demuxing' :
         foreach ($info['formats'] as $id => $data) {
@@ -685,11 +708,11 @@ class TranscoderAbstractionFactoryFfmpeg
           // Decrease the height.
           $factor = $targetdimensions[0] < $sourcedimensions[0] ? $targetdimensions[0] / $sourcedimensions[0] : $sourcedimensions[0] / $targetdimensions[0];
           $width = $targetdimensions[0];
-          $height = round($sourcedimensions[1] * $factor);
+          $height = round($sourcedimensions[1] * $factor / 2) * 2;
         }
         else {
           $factor = $targetdimensions[1] < $sourcedimensions[1] ? $targetdimensions[1] / $sourcedimensions[1] : $sourcedimensions[1] / $targetdimensions[1];
-          $width = round($sourcedimensions[0] * $factor);
+          $width = round($sourcedimensions[0] * $factor / 2) * 2;
           $height = $targetdimensions[1];
         }
 
diff -upr a/video.field.inc b/video.field.inc
--- a/video.field.inc	2013-04-22 07:31:05.000000000 +0000
+++ b/video.field.inc	2013-05-01 05:15:08.000000000 +0000
@@ -723,14 +723,17 @@ function video_field_widget_process($ele
     }
 
     // Dimensions dropdown.
-    $element['dimensions'] = array(
-      '#type' => 'select',
-      '#title' => t('Output video dimensions'),
-      '#default_value' => $file['dimensions'],
-      '#description' => $description,
-      '#options' => $options,
-      '#access' => user_access('override player dimensions'),
-    );
+	$use_preset_wxh = variable_get('video_use_preset_wxh', FALSE);
+	if (!$use_preset_wxh) {
+      $element['dimensions'] = array(
+        '#type' => 'select',
+        '#title' => t('Output video dimensions'),
+        '#default_value' => $file['dimensions'],
+        '#description' => $description,
+        '#options' => $options,
+        '#access' => user_access('override player dimensions'),
+      );
+	}
 
     if (!empty($file['conversionstatus']) && ($file['conversionstatus'] == VIDEO_RENDERING_COMPLETE || $file['conversionstatus'] == VIDEO_RENDERING_FAILED)) {
       $status = array(VIDEO_RENDERING_COMPLETE => 'was successful', VIDEO_RENDERING_FAILED => 'failed');
diff -upr a/video.theme.inc b/video.theme.inc
--- a/video.theme.inc	2013-04-22 07:31:05.000000000 +0000
+++ b/video.theme.inc	2013-05-02 18:46:06.000000000 +0000
@@ -88,6 +88,7 @@ function theme_video_formatter_player(ar
   $defaults = video_utility::getVideoExtensions();
   foreach ($item['playablefiles'] as $playablefile) {
     $extension = video_utility::getExtension($playablefile->uri);
+	if ($extension == 'ts') continue;
     $theme_function = variable_get('video_extension_' . $extension, $defaults[$extension]);
     if ($theme_function == 'video_play_html5') {
       $theme_function = 'video_html5';
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-05-02 18:47:22.000000000 +0000
@@ -253,6 +253,8 @@ class video_utility {
       'ogv' => 'video_play_html5',
       'webm' => 'video_play_html5',
       'mp3' => 'video_play_html5',
+	  'm3u8' => 'video_play_html5',
+	  'smil' => 'video_play_flv',	  
     );
   }
 
