Video Embed & Thumbnail Generator - Version 2.0.3

Version Description

  • February 24, 2012 =
  • When working with file formats that can't be embedded (WMV, AVI, etc) the option to embed the original file will be disabled if Mobile/H.264, WEBM, or OGV files are found.
  • Changed encoding bitrate flag back to -b instead of -b:v to retain compatibility with older versions of FFMPEG.
  • Cosmetic changes in encoding progress bar.
  • No longer deleting encoded files if progress can't be properly established.
  • Added "nice" to the encode commond (not on Windows) to prevent FFMPEG from overusing system resources.
  • Updated plugin settings panel generation function to require "Administrator" role instead of deprecated capability number system.
Download this release

Release Info

Developer kylegilman
Plugin Icon 128x128 Video Embed & Thumbnail Generator
Version 2.0.3
Comparing to
See all releases

Code changes from version 2.0.2 to 2.0.3

kg_callffmpeg.php CHANGED
@@ -45,7 +45,7 @@ class Process{
45
  } //exec this way if it's Windows
46
 
47
  else {
48
- $command = 'nohup '.$this->command;
49
  $this->OS = "linux";
50
  }
51
 
@@ -245,7 +245,7 @@ if ($action == "generate" || $action == "encode" ) {
245
 
246
  $ipodbitrate = $movie_height * 3;
247
 
248
- $ffmpeg_ipod_options = ' -acodec '.$aaclib.' -ab 128k -s '.$ipod_movie_width.'x'.$ipod_movie_height.' -vcodec libx264 -threads 1 '.$movie_rotate.' -b:v '.$ipodbitrate.'k -bt 800k -f ipod "'.$encodevideo_info['mobilefilepath'].'"';
249
  $encode_anything = "true";
250
  $embed_display .= "<strong> Encoding Mobile M4V. </strong>";
251
  }//if the proper FFMPEG libraries are enabled
@@ -258,7 +258,7 @@ if ($action == "generate" || $action == "encode" ) {
258
  if ( ! $encodevideo_info['webm_exists'] || ($encodevideo_info['sameserver'] && filesize($encodevideo_info['webmfilepath']) < 24576) ) {
259
  if ( strpos($movie_info['configuration'], 'enable-libvorbis') && strpos($movie_info['configuration'], 'enable-libvpx') ) {
260
  $webmbitrate = $movie_height * 3;
261
- $ffmpeg_webm_options = ' -ab 128k -b:v '.$webmbitrate.'k '.$movie_rotate.' -threads 1 "'.$encodevideo_info['webmfilepath'].'"';
262
  $encode_anything = "true";
263
  $embed_display .= "<strong> Encoding WEBM. </strong>";
264
  }//if the proper FFMPEG libraries are enabled
@@ -272,7 +272,7 @@ if ($action == "generate" || $action == "encode" ) {
272
 
273
  if ( strpos($movie_info['configuration'], 'enable-libvorbis') && strpos($movie_info['configuration'], 'enable-libtheora') ) {
274
  $ogvbitrate = $movie_height * 3;
275
- $ffmpeg_ogv_options = ' -acodec libvorbis -ab 128k -vcodec libtheora -b:v '.$ogvbitrate.'k '.$movie_rotate.' -threads 1 "'.$encodevideo_info['oggfilepath'].'"';
276
  $encode_anything = "true";
277
  $embed_display .= "<strong> Encoding OGV. </strong>";
278
  }//if the proper FFMPEG libraries are enabled
@@ -309,11 +309,15 @@ if ($action == "generate" || $action == "encode" ) {
309
  }//if any HTML5 videos don't already exist
310
 
311
  $replaceoptions = "";
 
 
 
 
312
  if ( $encodevideo_info['mobile_exists'] ) { $replaceoptions .= '<option value="'.$encodevideo_info['mobileurl'].'">Mobile/H.264</option>'; }
313
  if ( $encodevideo_info['webm_exists'] ) { $replaceoptions .= '<option value="'.$encodevideo_info['webmurl'].'">WEBM</option>'; }
314
  if ( $encodevideo_info['ogg_exists'] ) { $replaceoptions .= '<option value="'.$encodevideo_info['oggurl'].'">OGV</option>'; }
315
 
316
- $altembedselect = '<span class="kg_embedselect">Embed <select name="attachments['.$postID.'][kgflashmediaplayer-altembed]" id="attachments['.$postID.'][kgflashmediaplayer-altembed]"><option value="'.$movieurl.'">original</option>'.$replaceoptions.'</select></span>';
317
 
318
  //$encodevideo_info_map = array_map(create_function('$key, $value', 'return $key.":".$value." # ";'), array_keys($encodevideo_info), array_values($encodevideo_info));
319
  //$encodevideo_info_implode = implode($encodevideo_info_map);
45
  } //exec this way if it's Windows
46
 
47
  else {
48
+ $command = 'nohup nice '.$this->command;
49
  $this->OS = "linux";
50
  }
51
 
245
 
246
  $ipodbitrate = $movie_height * 3;
247
 
248
+ $ffmpeg_ipod_options = ' -acodec '.$aaclib.' -ab 128k -s '.$ipod_movie_width.'x'.$ipod_movie_height.' -vcodec libx264 -threads 1 '.$movie_rotate.' -b '.$ipodbitrate.'k -bt 800k -f ipod "'.$encodevideo_info['mobilefilepath'].'"';
249
  $encode_anything = "true";
250
  $embed_display .= "<strong> Encoding Mobile M4V. </strong>";
251
  }//if the proper FFMPEG libraries are enabled
258
  if ( ! $encodevideo_info['webm_exists'] || ($encodevideo_info['sameserver'] && filesize($encodevideo_info['webmfilepath']) < 24576) ) {
259
  if ( strpos($movie_info['configuration'], 'enable-libvorbis') && strpos($movie_info['configuration'], 'enable-libvpx') ) {
260
  $webmbitrate = $movie_height * 3;
261
+ $ffmpeg_webm_options = ' -ab 128k -b '.$webmbitrate.'k '.$movie_rotate.' -threads 1 "'.$encodevideo_info['webmfilepath'].'"';
262
  $encode_anything = "true";
263
  $embed_display .= "<strong> Encoding WEBM. </strong>";
264
  }//if the proper FFMPEG libraries are enabled
272
 
273
  if ( strpos($movie_info['configuration'], 'enable-libvorbis') && strpos($movie_info['configuration'], 'enable-libtheora') ) {
274
  $ogvbitrate = $movie_height * 3;
275
+ $ffmpeg_ogv_options = ' -acodec libvorbis -ab 128k -vcodec libtheora -b '.$ogvbitrate.'k '.$movie_rotate.' -threads 1 "'.$encodevideo_info['oggfilepath'].'"';
276
  $encode_anything = "true";
277
  $embed_display .= "<strong> Encoding OGV. </strong>";
278
  }//if the proper FFMPEG libraries are enabled
309
  }//if any HTML5 videos don't already exist
310
 
311
  $replaceoptions = "";
312
+ $originalselect = "";
313
+ $original_extension = pathinfo($movieurl, PATHINFO_EXTENSION);
314
+ $embeddable = array("flv", "f4v", "mp4", "mov", "m4v", "ogv", "ogg", "webm");
315
+ if ( in_array($original_extension, $embeddable) ) { $originalselect = '<option value="'.$movieurl.'">original</option>'; }
316
  if ( $encodevideo_info['mobile_exists'] ) { $replaceoptions .= '<option value="'.$encodevideo_info['mobileurl'].'">Mobile/H.264</option>'; }
317
  if ( $encodevideo_info['webm_exists'] ) { $replaceoptions .= '<option value="'.$encodevideo_info['webmurl'].'">WEBM</option>'; }
318
  if ( $encodevideo_info['ogg_exists'] ) { $replaceoptions .= '<option value="'.$encodevideo_info['oggurl'].'">OGV</option>'; }
319
 
320
+ $altembedselect = '<span class="kg_embedselect">Embed <select name="attachments['.$postID.'][kgflashmediaplayer-altembed]" id="attachments['.$postID.'][kgflashmediaplayer-altembed]">'.$originalselect.$replaceoptions.'</select></span>';
321
 
322
  //$encodevideo_info_map = array_map(create_function('$key, $value', 'return $key.":".$value." # ";'), array_keys($encodevideo_info), array_values($encodevideo_info));
323
  //$encodevideo_info_implode = implode($encodevideo_info_map);
kg_video_plugin.js CHANGED
@@ -172,16 +172,22 @@ function kg_check_encode_progress(postID, kg_pid, kg_logfile, kg_movie_duration,
172
  else { kg_time_elapsed_display = kg_time_elapsed+' seconds'; }
173
 
174
  if ( data.percent_done != "" && data.percent_done != "100" ) {
175
- var kg_time_remaining = Math.floor( (kg_time_elapsed / (data.percent_done/100) ) - kg_time_elapsed);
176
- if ( kg_time_remaining >= 60 ) {
177
- kg_time_remaining_minutes = Math.round(kg_time_remaining/60);
178
- kg_time_remaining_seconds = kg_time_remaining%60;
179
- kg_time_remaining_seconds = (kg_time_remaining_seconds < 10) ? ("0" + kg_time_remaining_seconds) : kg_time_remaining_seconds;
180
- kg_time_remaining_display = kg_time_remaining_minutes+':'+kg_time_remaining_seconds;
 
 
 
 
 
 
 
 
 
181
  }
182
- else { kg_time_remaining_display = kg_time_remaining+' seconds'; }
183
- jQuery(encodeprogressplaceholderid).empty();
184
- jQuery(encodeprogressplaceholderid).append('<div class="meter"><span style="width:'+data.percent_done+'%;">'+display_percent+'</span></div><div class="kg_cancel_button"><input type="button" id="attachments_'+postID+'_kgflashmediaplayer-cancelencode" class="button-secondary" value="Cancel" name="attachments_'+postID+'_cancelencode" onclick="kg_cancel_encode('+kg_pid+', \''+postID+'\');"></div><div style="display:block;"><small>Elapsed: '+kg_time_elapsed_display+'. Estimated Remaining: '+kg_time_remaining_display+'. FPS:'+data.fps+'</small></div>');
185
  }
186
 
187
  if (data.other_message != "") {
@@ -198,7 +204,7 @@ function kg_check_encode_progress(postID, kg_pid, kg_logfile, kg_movie_duration,
198
  stopChecking = true;
199
  //delete window.kg_start_time_over;
200
  jQuery(encodeprogressplaceholderid).empty();
201
- jQuery(encodeprogressplaceholderid).append('<div class="meter_finished"><span style="width:100%;">100%</span></div><div style="display:block;"><small>Elapsed: '+kg_time_elapsed+' seconds. Estimated Remaining: 0 seconds.</small></div>');
202
  jQuery(encodeplaceholderid).empty();
203
  jQuery(encodeplaceholderid).append('<strong>Encoding Complete</strong>');
204
  }
172
  else { kg_time_elapsed_display = kg_time_elapsed+' seconds'; }
173
 
174
  if ( data.percent_done != "" && data.percent_done != "100" ) {
175
+ if ( parseInt(data.percent_done) < 100 ) {
176
+ var kg_time_remaining = Math.floor( (kg_time_elapsed / (data.percent_done/100) ) - kg_time_elapsed);
177
+ if ( kg_time_remaining >= 60 ) {
178
+ kg_time_remaining_minutes = Math.round(kg_time_remaining/60);
179
+ kg_time_remaining_seconds = kg_time_remaining%60;
180
+ kg_time_remaining_seconds = (kg_time_remaining_seconds < 10) ? ("0" + kg_time_remaining_seconds) : kg_time_remaining_seconds;
181
+ kg_time_remaining_display = kg_time_remaining_minutes+':'+kg_time_remaining_seconds;
182
+ }
183
+ else { kg_time_remaining_display = kg_time_remaining+' seconds'; }
184
+ jQuery(encodeprogressplaceholderid).empty();
185
+ jQuery(encodeprogressplaceholderid).append('<div class="meter"><span style="width:'+data.percent_done+'%;">'+display_percent+'</span></div><div class="kg_cancel_button"><input type="button" id="attachments_'+postID+'_kgflashmediaplayer-cancelencode" class="button-secondary" value="Cancel" name="attachments_'+postID+'_cancelencode" onclick="kg_cancel_encode('+kg_pid+', \''+postID+'\');"></div><div style="display:block;"><small>Elapsed: '+kg_time_elapsed_display+'. Estimated Remaining: '+kg_time_remaining_display+'. FPS:'+data.fps+'</small></div>');
186
+ }
187
+ else {
188
+ jQuery(encodeprogressplaceholderid).empty();
189
+ jQuery(encodeprogressplaceholderid).append('<div class="kg_cancel_button"><input type="button" id="attachments_'+postID+'_kgflashmediaplayer-cancelencode" class="button-secondary" value="Cancel" name="attachments_'+postID+'_cancelencode" onclick="kg_cancel_encode('+kg_pid+', \''+postID+'\');"></div><div style="display:block;"><small>Elapsed: '+kg_time_elapsed_display+'. FPS:'+data.fps+'</small></div>');
190
  }
 
 
 
191
  }
192
 
193
  if (data.other_message != "") {
204
  stopChecking = true;
205
  //delete window.kg_start_time_over;
206
  jQuery(encodeprogressplaceholderid).empty();
207
+ jQuery(encodeprogressplaceholderid).append('<div class="meter_finished"><span style="width:100%;">100%</span></div><div style="display:block;"><small>Elapsed: '+kg_time_elapsed_display+'. Estimated Remaining: 0 seconds.</small></div>');
208
  jQuery(encodeplaceholderid).empty();
209
  jQuery(encodeplaceholderid).append('<strong>Encoding Complete</strong>');
210
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kyleg
4
  Tags: video, html5, shortcode, thumbnail, ffmpeg, embed, mobile, webm, ogg, h.264
5
  Requires at least: 3.0
6
  Tested up to: 3.3.1
7
- Stable tag: 2.0.2
8
 
9
  Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes.
10
 
@@ -101,6 +101,14 @@ Because I can't figure out how to do it. Windows works a little differently from
101
 
102
  == Changelog ==
103
 
 
 
 
 
 
 
 
 
104
  = 2.0.2 - February 21, 2012 =
105
  * Fixed check for FFMPEG again, to work with Windows.
106
 
4
  Tags: video, html5, shortcode, thumbnail, ffmpeg, embed, mobile, webm, ogg, h.264
5
  Requires at least: 3.0
6
  Tested up to: 3.3.1
7
+ Stable tag: 2.0.3
8
 
9
  Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes.
10
 
101
 
102
  == Changelog ==
103
 
104
+ = 2.0.3 - February 24, 2012 =
105
+ * When working with file formats that can't be embedded (WMV, AVI, etc) the option to embed the original file will be disabled if Mobile/H.264, WEBM, or OGV files are found.
106
+ * Changed encoding bitrate flag back to -b instead of -b:v to retain compatibility with older versions of FFMPEG.
107
+ * Cosmetic changes in encoding progress bar.
108
+ * No longer deleting encoded files if progress can't be properly established.
109
+ * Added "nice" to the encode commond (not on Windows) to prevent FFMPEG from overusing system resources.
110
+ * Updated plugin settings panel generation function to require "Administrator" role instead of deprecated capability number system.
111
+
112
  = 2.0.2 - February 21, 2012 =
113
  * Fixed check for FFMPEG again, to work with Windows.
114
 
video-embed-thumbnail-generator.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Video Embed & Thumbnail Generator
4
  Plugin URI: http://www.kylegilman.net/2011/01/18/video-embed-thumbnail-generator-wordpress-plugin/
5
  Description: Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes. <a href="options-general.php?page=video-embed-thumbnail-generator.php">Settings</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kylegilman@gmail.com&item_name=Video%20Embed%20And%20Thumbnail%20Generator%20Plugin%20Donation/">Donate</a>
6
- Version: 2.0.2
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
 
@@ -425,7 +425,7 @@ function FMP_shortcode($atts, $content = ''){
425
  add_shortcode('FMP', 'FMP_shortcode');
426
 
427
  function addFMPOptionsPage() {
428
- add_options_page('Video Embed & Thumbnail Generator', 'Video Embed & Thumbnail Generator', 8, basename(__FILE__), 'FMPOptionsPage');
429
  }
430
 
431
  function FMPOptionsPage() {
@@ -1138,10 +1138,14 @@ add_action('save_post', 'kg_addPostSave');
1138
  $encodevideo_info = kg_encodevideo_info($movieurl, $post->ID);
1139
 
1140
  $altembedselect = "";
 
1141
  $selected = ' selected="selected" ';
1142
  $mobileselected = "";
1143
  $oggselected = "";
1144
  $webmselected = "";
 
 
 
1145
  if ($altembedset == $encodevideo_info['mobileurl']) { $mobileselected = $selected; }
1146
  if ($altembedset == $encodevideo_info['oggurl']) { $oggselected = $selected; }
1147
  if ($altembedset == $encodevideo_info['webmurl']) { $webmselected = $selected; }
@@ -1149,7 +1153,7 @@ add_action('save_post', 'kg_addPostSave');
1149
  if ( $encodevideo_info['mobile_exists'] ) { $replaceoptions .= '<option '.$mobileselected.' value="'.$encodevideo_info['mobileurl'].'">Mobile/H.264</option>'; }
1150
  if ( $encodevideo_info['webm_exists'] ) { $replaceoptions .= '<option '.$webmselected.' value="'.$encodevideo_info['webmurl'].'">WEBM</option>'; }
1151
  if ( $encodevideo_info['ogg_exists'] ) { $replaceoptions .= '<option '.$oggselected.' value="'.$encodevideo_info['oggurl'].'">OGV</option>'; }
1152
- if ( $encodevideo_info['mobile_exists'] || $encodevideo_info['webm_exists'] || $encodevideo_info['ogg_exists'] ) { $altembedselect ='<span class="kg_embedselect">Embed <select name="attachments['.$post->ID.'][kgflashmediaplayer-altembed]" id="attachments['.$post->ID.'][kgflashmediaplayer-altembed]"><option value="'.$movieurl.'">original</option>'.$replaceoptions.'</select></span>'; }
1153
 
1154
  $form_fields["kgflashmediaplayer-encode"]["label"] = __("HTML5 & Mobile");
1155
  $form_fields["kgflashmediaplayer-encode"]["input"] = "html";
@@ -1510,18 +1514,20 @@ function kg_check_encode_progress() {
1510
  $other_message = $lastline;
1511
  $basename = substr($logfile, 0, -16);
1512
  if ( is_file($basename."-ipod.m4v") ) {
1513
- if ( (time() - filemtime($basename."-ipod.m4v")) < 30 ) { unlink($basename."-ipod.m4v"); }
 
1514
  }
1515
  if ( is_file($basename.".ogv") ) {
1516
- if ( (time() - filemtime($basename.".ogv")) < 30 ) { unlink($basename.".ogv"); }
 
1517
  }
1518
  if ( is_file($basename.".webm") ) {
1519
  if ( (time() - filemtime($basename.".webm")) < 30 ) { //unlink($basename.".webm");
1520
- }
1521
  }
1522
  }
1523
 
1524
- if ( $percent_done == "100" || $other_message != "" ) { if ( file_exists($logfile) ) { unlink($logfile); } }
1525
 
1526
  $embed_display .= $lastline;
1527
  $arr = array ( "embed_display"=>$embed_display, "percent_done"=>$percent_done, "other_message"=>$other_message, "fps"=>$fps_match );
3
  Plugin Name: Video Embed & Thumbnail Generator
4
  Plugin URI: http://www.kylegilman.net/2011/01/18/video-embed-thumbnail-generator-wordpress-plugin/
5
  Description: Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes. <a href="options-general.php?page=video-embed-thumbnail-generator.php">Settings</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kylegilman@gmail.com&item_name=Video%20Embed%20And%20Thumbnail%20Generator%20Plugin%20Donation/">Donate</a>
6
+ Version: 2.0.3
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
 
425
  add_shortcode('FMP', 'FMP_shortcode');
426
 
427
  function addFMPOptionsPage() {
428
+ add_options_page('Video Embed & Thumbnail Generator', 'Video Embed & Thumbnail Generator', 'administrator', basename(__FILE__), 'FMPOptionsPage');
429
  }
430
 
431
  function FMPOptionsPage() {
1138
  $encodevideo_info = kg_encodevideo_info($movieurl, $post->ID);
1139
 
1140
  $altembedselect = "";
1141
+ $originalselect = "";
1142
  $selected = ' selected="selected" ';
1143
  $mobileselected = "";
1144
  $oggselected = "";
1145
  $webmselected = "";
1146
+ $original_extension = pathinfo($movieurl, PATHINFO_EXTENSION);
1147
+ $embeddable = array("flv", "f4v", "mp4", "mov", "m4v", "ogv", "ogg", "webm");
1148
+ if ( in_array($original_extension, $embeddable) ) { $originalselect = '<option value="'.$movieurl.'">original</option>'; }
1149
  if ($altembedset == $encodevideo_info['mobileurl']) { $mobileselected = $selected; }
1150
  if ($altembedset == $encodevideo_info['oggurl']) { $oggselected = $selected; }
1151
  if ($altembedset == $encodevideo_info['webmurl']) { $webmselected = $selected; }
1153
  if ( $encodevideo_info['mobile_exists'] ) { $replaceoptions .= '<option '.$mobileselected.' value="'.$encodevideo_info['mobileurl'].'">Mobile/H.264</option>'; }
1154
  if ( $encodevideo_info['webm_exists'] ) { $replaceoptions .= '<option '.$webmselected.' value="'.$encodevideo_info['webmurl'].'">WEBM</option>'; }
1155
  if ( $encodevideo_info['ogg_exists'] ) { $replaceoptions .= '<option '.$oggselected.' value="'.$encodevideo_info['oggurl'].'">OGV</option>'; }
1156
+ if ( $encodevideo_info['mobile_exists'] || $encodevideo_info['webm_exists'] || $encodevideo_info['ogg_exists'] ) { $altembedselect ='<span class="kg_embedselect">Embed <select name="attachments['.$post->ID.'][kgflashmediaplayer-altembed]" id="attachments['.$post->ID.'][kgflashmediaplayer-altembed]">'.$originalselect.$replaceoptions.'</select></span>'; }
1157
 
1158
  $form_fields["kgflashmediaplayer-encode"]["label"] = __("HTML5 & Mobile");
1159
  $form_fields["kgflashmediaplayer-encode"]["input"] = "html";
1514
  $other_message = $lastline;
1515
  $basename = substr($logfile, 0, -16);
1516
  if ( is_file($basename."-ipod.m4v") ) {
1517
+ if ( (time() - filemtime($basename."-ipod.m4v")) < 30 ) { //unlink($basename."-ipod.m4v");
1518
+ }
1519
  }
1520
  if ( is_file($basename.".ogv") ) {
1521
+ if ( (time() - filemtime($basename.".ogv")) < 30 ) { //unlink($basename.".ogv");
1522
+ }
1523
  }
1524
  if ( is_file($basename.".webm") ) {
1525
  if ( (time() - filemtime($basename.".webm")) < 30 ) { //unlink($basename.".webm");
1526
+ }
1527
  }
1528
  }
1529
 
1530
+ //if ( $percent_done == "100" || $other_message != "" ) { if ( file_exists($logfile) ) { unlink($logfile); } }
1531
 
1532
  $embed_display .= $lastline;
1533
  $arr = array ( "embed_display"=>$embed_display, "percent_done"=>$percent_done, "other_message"=>$other_message, "fps"=>$fps_match );