Video Embed & Thumbnail Generator - Version 4.2.3

Version Description

  • October 8, 2013 =
  • Fixed bug that caused encoding on Windows servers to hang and not show progress.
  • Fixed bug that only disabled right-clicking when using the Video.js player.
  • Fixed bug that prevented encoding videos from the External URL tab.
  • Fixed bug that showed an empty "Replace original with H.264" checkbox if the filename changed.
  • Better error reporting when encoding or auto thumbnail creation fails.
  • Modified method for determining video's dimensions from FFMPEG/LIBAV output. This will cause videos with single-digit resolutions to fail.
  • Adjusted video gallery CSS.
Download this release

Release Info

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

Code changes from version 4.2.2 to 4.2.3

css/kgvid_styles.css CHANGED
@@ -3,6 +3,10 @@
3
  position: relative;
4
  }
5
 
 
 
 
 
6
  .kgvid_videodiv {
7
  position: relative;
8
  }
@@ -54,8 +58,8 @@ img.kgvid_ios_novideo {
54
  background-color: rgba(40, 40, 40, 0.95);
55
  visibility: hidden;
56
  opacity: 0;
57
- -webkit-transition: visibility 1s linear, opacity 1s linear;
58
- -moz-transition: visibility 1s linear, opacity 1s linear;
59
  -o-transition: visibility 1s linear, opacity 1s linear;
60
  }
61
 
@@ -114,42 +118,42 @@ img.kgvid_ios_novideo {
114
  }
115
 
116
  .kgvid_video_gallery_thumb {
117
- position: relative;
118
  float: left;
119
- display:inline-block;
120
- margin:10px;
121
  cursor: pointer; !important
122
  }
123
 
124
- .kgvid_video_gallery_thumb img {
125
  width: 100%;
126
  max-width:none !important;
127
- padding:0px;
128
- margin:0px;
129
  }
130
 
131
- .kgvid_video_gallery_thumb .titlebackground {
132
- position:absolute;
133
- bottom:10px;
134
- left:0px;
135
- width:100%;
136
- padding:0px;
137
- background-color: rgba(0,0,0,0.4);
138
  overflow:hidden;
139
  z-index: 3;
140
  }
141
 
142
  .kgvid_video_gallery_thumb:hover .titlebackground {
143
- background-color: rgba(0,0,0,0.8);
144
  }
145
 
146
  .kgvid_video_gallery_thumb .videotitle {
147
  color:white;
148
- letter-spacing:0.05em;
149
  font-size:14px;
150
  line-height: 1.5em;
151
  text-align:center;
152
- padding:4px;
153
  }
154
 
155
  #kgvid_GalleryVideo {
@@ -169,7 +173,7 @@ img.kgvid_ios_novideo {
169
  */
170
  .kgvid_gallery .ui-dialog { position: absolute; width: 300px; background-color:black; z-index:10001; }
171
  .kgvid_gallery .ui-dialog .ui-dialog-titlebar { position: relative; float:right; }
172
- .kgvid_gallery .ui-dialog .ui-dialog-title { float: left; }
173
  .kgvid_gallery .ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; left:10px; top:-10px; background: none; border: none; text-indent: -9999999px; }
174
  .kgvid_gallery .ui-dialog .ui-dialog-titlebar-close span { display: block; }
175
  .kgvid_gallery .ui-dialog .ui-dialog-titlebar-close span:focus { }
@@ -220,4 +224,4 @@ img.kgvid_ios_novideo {
220
  .kgvid_gallery .ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; }
221
  .kgvid_gallery .ui-button-text-icon-primary .ui-button-icon-primary, .kgvid_gallery .ui-button-text-icons .ui-button-icon-primary, .kgvid_gallery .ui-button-icons-only .ui-button-icon-primary { left: .5em; }
222
  .kgvid_gallery .ui-button-text-icon-secondary .ui-button-icon-secondary, .kgvid_gallery .ui-button-text-icons .ui-button-icon-secondary, .kgvid_gallery .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
223
- .kgvid_gallery .ui-button-text-icons .ui-button-icon-secondary, .kgvid_gallery .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
3
  position: relative;
4
  }
5
 
6
+ .kgvid_gallerywrapper {
7
+ display: inline-block;
8
+ }
9
+
10
  .kgvid_videodiv {
11
  position: relative;
12
  }
58
  background-color: rgba(40, 40, 40, 0.95);
59
  visibility: hidden;
60
  opacity: 0;
61
+ -webkit-transition: visibility 1s linear, opacity 1s linear;
62
+ -moz-transition: visibility 1s linear, opacity 1s linear;
63
  -o-transition: visibility 1s linear, opacity 1s linear;
64
  }
65
 
118
  }
119
 
120
  .kgvid_video_gallery_thumb {
121
+ position: relative;
122
  float: left;
123
+ display:inline-block;
124
+ margin: 3px 7px;
125
  cursor: pointer; !important
126
  }
127
 
128
+ .kgvid_video_gallery_thumb img {
129
  width: 100%;
130
  max-width:none !important;
131
+ padding:0px;
132
+ margin:0px;
133
  }
134
 
135
+ .kgvid_video_gallery_thumb .titlebackground {
136
+ position:absolute;
137
+ bottom:10px;
138
+ left:0px;
139
+ width:100%;
140
+ padding:0px;
141
+ background-color: rgba(0,0,0,0.4);
142
  overflow:hidden;
143
  z-index: 3;
144
  }
145
 
146
  .kgvid_video_gallery_thumb:hover .titlebackground {
147
+ background-color: rgba(0,0,0,0.8);
148
  }
149
 
150
  .kgvid_video_gallery_thumb .videotitle {
151
  color:white;
152
+ letter-spacing:0.05em;
153
  font-size:14px;
154
  line-height: 1.5em;
155
  text-align:center;
156
+ padding:4px;
157
  }
158
 
159
  #kgvid_GalleryVideo {
173
  */
174
  .kgvid_gallery .ui-dialog { position: absolute; width: 300px; background-color:black; z-index:10001; }
175
  .kgvid_gallery .ui-dialog .ui-dialog-titlebar { position: relative; float:right; }
176
+ .kgvid_gallery .ui-dialog .ui-dialog-title { float: left; }
177
  .kgvid_gallery .ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; left:10px; top:-10px; background: none; border: none; text-indent: -9999999px; }
178
  .kgvid_gallery .ui-dialog .ui-dialog-titlebar-close span { display: block; }
179
  .kgvid_gallery .ui-dialog .ui-dialog-titlebar-close span:focus { }
224
  .kgvid_gallery .ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; }
225
  .kgvid_gallery .ui-button-text-icon-primary .ui-button-icon-primary, .kgvid_gallery .ui-button-text-icons .ui-button-icon-primary, .kgvid_gallery .ui-button-icons-only .ui-button-icon-primary { left: .5em; }
226
  .kgvid_gallery .ui-button-text-icon-secondary .ui-button-icon-secondary, .kgvid_gallery .ui-button-text-icons .ui-button-icon-secondary, .kgvid_gallery .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
227
+ .kgvid_gallery .ui-button-text-icons .ui-button-icon-secondary, .kgvid_gallery .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
js/kgvid_video_plugin_admin.js CHANGED
@@ -519,13 +519,6 @@ function kgvid_change_singleurl(url, basename, oldbasename) {
519
  }
520
  });
521
  jQuery('#kgflashmediaplayer-table').data("kgvid_attachment_id", basename);
522
- /* document.getElementById('thumb-video-'+oldbasename).setAttribute("onloadedmetadata", "kgvid_thumb_video_loaded('"+basename+"')");
523
- document.getElementById('thumb-video-'+oldbasename).id = 'thumb-video-'+basename;
524
- document.getElementById('manual-thumbnail').setAttribute("onclick", "kgvid_thumb_video_manual('"+basename+"');");
525
- document.getElementById('thumb-video-'+oldbasename+'-container').id = 'thumb-video-'+basename+'-container';
526
- document.getElementById('show-thumb-video-'+oldbasename).setAttribute("onclick", "kgvid_reveal_thumb_video('"+basename+"');");
527
- document.getElementById('show-thumb-video-'+oldbasename).id = 'show-thumb-video-'+basename;
528
- document.getElementById('thumb-video-'+oldbasename+'-player').id = 'thumb-video-'+basename+'-player'; */
529
  jQuery('#attachments-'+oldbasename+'-kgflashmediaplayer-encodeboxes').attr('id', 'attachments-'+basename+'-kgflashmediaplayer-encodeboxes');
530
  document.getElementById('attachments-'+oldbasename+'-thumbnailplaceholder').id = 'attachments-'+basename+'-thumbnailplaceholder';
531
  document.getElementById('attachments-'+basename+'-thumbnailplaceholder').setAttribute("onchange", "document.getElementById('attachments-"+basename+"-thumbtime').value='';");
@@ -730,14 +723,23 @@ function kgvid_redraw_thumbnail_box(postID) {
730
 
731
  if ( kgflashmediaplayersecurity ) {
732
 
733
- jQuery.post(ajaxurl, { action:"kgvid_redraw_thumbnail_box", security: kgflashmediaplayersecurity, post_id: postID }, function(thumbnail_url) {
734
- if ( thumbnail_url ) {
735
- jQuery('#attachments-'+postID+'-thumbnailplaceholder').html('<div class="kgvid_thumbnail_box kgvid_chosen_thumbnail_box"><img width="200" src="'+thumbnail_url+'"></div>');
 
 
 
 
 
 
 
 
 
736
  }
737
-
738
  else { setTimeout(function(){ kgvid_redraw_thumbnail_box(postID) }, 5000); }
739
 
740
- }, "text" );
741
 
742
  }
743
  }
519
  }
520
  });
521
  jQuery('#kgflashmediaplayer-table').data("kgvid_attachment_id", basename);
 
 
 
 
 
 
 
522
  jQuery('#attachments-'+oldbasename+'-kgflashmediaplayer-encodeboxes').attr('id', 'attachments-'+basename+'-kgflashmediaplayer-encodeboxes');
523
  document.getElementById('attachments-'+oldbasename+'-thumbnailplaceholder').id = 'attachments-'+basename+'-thumbnailplaceholder';
524
  document.getElementById('attachments-'+basename+'-thumbnailplaceholder').setAttribute("onchange", "document.getElementById('attachments-"+basename+"-thumbtime').value='';");
723
 
724
  if ( kgflashmediaplayersecurity ) {
725
 
726
+ jQuery.post(ajaxurl, { action:"kgvid_redraw_thumbnail_box", security: kgflashmediaplayersecurity, post_id: postID }, function(data) {
727
+ if ( data.thumb_url ) {
728
+ jQuery('#attachments-'+postID+'-thumbnailplaceholder').html('<div class="kgvid_thumbnail_box kgvid_chosen_thumbnail_box"><img width="200" src="'+data.thumb_url+'"></div>');
729
+ jQuery('#attachments-'+postID+'-kgflashmediaplayer-poster').val(data.thumb_url);
730
+ if ( data.thumbnail_size_url ) {
731
+ basename = data.thumb_url.substring(data.thumb_url.lastIndexOf('/')+1, data.thumb_url.indexOf('_thumb'))
732
+ jQuery('.attachment-preview.type-video:contains('+basename+')').parent().find('img')
733
+ .attr('src', data.thumbnail_size_url)
734
+ .css('width', '100%')
735
+ .css('height', '100%')
736
+ .css('padding-top', '0');
737
+ }
738
  }
739
+ else if ( data.thumb_error ) { jQuery('#attachments-'+postID+'-thumbnailplaceholder').html('<div class="kgvid_thumbnail_box kgvid_chosen_thumbnail_box"><span>'+data.thumb_error+'</span></div>'); }
740
  else { setTimeout(function(){ kgvid_redraw_thumbnail_box(postID) }, 5000); }
741
 
742
+ }, "json" );
743
 
744
  }
745
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kyleg
4
  Tags: video, video player, video gallery, html5, shortcode, thumbnail, poster, ffmpeg, libav, embed, mobile, webm, ogg, h.264, h264, responsive, mp4
5
  Requires at least: 3.5
6
  Tested up to: 3.7
7
- Stable tag: 4.2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -153,6 +153,15 @@ Enter the username & password in the plugin settings "FFMPEG Settings" tab, or u
153
 
154
  == Changelog ==
155
 
 
 
 
 
 
 
 
 
 
156
  = 4.2.2 - October 7, 2013 =
157
  * Fixed bug that was setting the global $content_width to 2048 on every page.
158
 
4
  Tags: video, video player, video gallery, html5, shortcode, thumbnail, poster, ffmpeg, libav, embed, mobile, webm, ogg, h.264, h264, responsive, mp4
5
  Requires at least: 3.5
6
  Tested up to: 3.7
7
+ Stable tag: 4.2.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
153
 
154
  == Changelog ==
155
 
156
+ = 4.2.3 - October 8, 2013 =
157
+ * Fixed bug that caused encoding on Windows servers to hang and not show progress.
158
+ * Fixed bug that only disabled right-clicking when using the Video.js player.
159
+ * Fixed bug that prevented encoding videos from the External URL tab.
160
+ * Fixed bug that showed an empty "Replace original with H.264" checkbox if the filename changed.
161
+ * Better error reporting when encoding or auto thumbnail creation fails.
162
+ * Modified method for determining video's dimensions from FFMPEG/LIBAV output. This will cause videos with single-digit resolutions to fail.
163
+ * Adjusted video gallery CSS.
164
+
165
  = 4.2.2 - October 7, 2013 =
166
  * Fixed bug that was setting the global $content_width to 2048 on every page.
167
 
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 or LIBAV for encoding. <a href="options-general.php?page=video-embed-thumbnail-generator/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: 4.2.2
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
 
@@ -517,6 +517,7 @@ function kgvid_encodevideo_info($movieurl, $postID) {
517
  function kgvid_get_video_dimensions($video = false) {
518
  $options = get_option('kgvid_video_embed_options');
519
  $ffmpegPath = $options['app_path']."/".$options['video_app'];
 
520
 
521
  $video = str_replace("https://", "http://", $video);
522
 
@@ -529,16 +530,16 @@ function kgvid_get_video_dimensions($video = false) {
529
  exec ( $command, $output );
530
  $lastline = end($output);
531
  $lastline = prev($output)."<br />".$lastline;
 
532
  $output = implode("\n", $output);
533
-
534
- $regex = "/Video: ([^,]*), ([^,]*), ([0-9]{1,4})x([0-9]{1,4})/";
535
  if (preg_match($regex, $output, $regs)) { $result = $regs[0]; }
536
  else { $result = ""; }
537
 
538
  if ( !empty($result) ) {
539
  $movie_info['worked'] = true;
540
- $movie_info['width'] = $regs [3] ? $regs [3] : null;
541
- $movie_info['height'] = $regs [4] ? $regs [4] : null;
542
  preg_match('/Duration: (.*?),/', $output, $matches);
543
  $duration = $matches[1];
544
  $movie_duration_hours = intval(substr($duration, -11, 2));
@@ -570,12 +571,14 @@ function kgvid_get_video_dimensions($video = false) {
570
  else { $movie_info['configuration'][$lib] = "false"; }
571
  }
572
 
573
- return $movie_info;
574
 
575
- } else {
576
- return array ('output'=>$lastline, 'worked'=>false);
 
 
577
  }
578
 
 
579
  }
580
 
581
  function kgvid_generate_encode_string($input, $output, $libraries, $format, $width, $height, $rotate) {
@@ -686,9 +689,14 @@ class kgvid_Process{
686
  else { $this->OS = "linux"; }
687
 
688
  $command = $this->command;
689
- exec($command ,$op);
690
- $this->output = $op;
691
- if(substr($sys,0,3) != "WIN") { $this->pid = (int)$op[0]; }
 
 
 
 
 
692
  }
693
 
694
  public function setPid($pid){
@@ -1182,7 +1190,7 @@ function KGVID_shortcode($atts, $content = ''){
1182
  $code .= "\n\t\t\t"."jQuery(document).ready(function(){ kgvid_setup_video('".$div_suffix."'); });";
1183
  }
1184
 
1185
- if ( $query_atts["right_click"] != "on" ) { $code .= "\n\t\t\t"."jQuery('#video_".$div_suffix."').bind('contextmenu',function() { return false; });"; }
1186
  $code .= "\n\t\t"."</script>"."\n";
1187
 
1188
  } //end id_array loop
@@ -1372,7 +1380,9 @@ function kgvid_generate_encode_checkboxes($movieurl, $post_id, $page) {
1372
  foreach ($video_embed_queue as $video_key => $video_entry) {
1373
  if ( $video_entry['movieurl'] == $movieurl ) {
1374
  foreach ( $video_entry['encode_formats'] as $format => $value ) {
1375
- $video_formats[$format]['status'] = $value['status'];
 
 
1376
  }
1377
  $video_queued = true;
1378
  break;
@@ -1381,6 +1391,7 @@ function kgvid_generate_encode_checkboxes($movieurl, $post_id, $page) {
1381
  }
1382
 
1383
  $checkboxes = '<div id="attachments-'.$post_id.'-kgflashmediaplayer-encodeboxes">';
 
1384
  foreach ( $video_formats as $format => $format_stats ) {
1385
  if ( strpos($post_mime_type, $format) !== false ) { continue; } //skip webm or ogv checkbox if the video is webm or ogv
1386
  $encodeset[$format] = "";
@@ -1420,7 +1431,11 @@ function kgvid_generate_encode_checkboxes($movieurl, $post_id, $page) {
1420
  if ( $format_stats['status'] == "notchecked" ) { $meta[$format] = ' <strong>Encoded</strong>'; }
1421
  if ( $format_stats['status'] != "canceling" ) {
1422
  if ( array_key_exists($format.'id', $encodevideo_info) ) { $child_id[$format] = $encodevideo_info[$format.'id']; }
1423
- if ( $encodevideo_info[$format.'_writable'] && current_user_can('encode_videos') ) { $meta[$format] .= '<a id="delete-'.$post_id.'-'.$format.'" class="kgvid_delete-format" onclick="kgvid_delete_video(\''.$movieurl.'\', \''.$post_id.'\', \''.$format.'\', \''.$child_id[$format].'\');" href="javascript:void(0)">Delete Permanently</a>'; }
 
 
 
 
1424
  }
1425
  $disabled[$format] = ' disabled title="Format already exists"';
1426
  $checked[$format] = '';
@@ -1943,7 +1958,7 @@ add_action('admin_init', 'kgvid_video_embed_options_init' );
1943
 
1944
  function kgvid_app_path_callback() {
1945
  $options = get_option('kgvid_video_embed_options');
1946
- echo "<input class='affects_ffmpeg regular-text code' id='app_path' name='kgvid_video_embed_options[app_path]' type='text' value='".stripslashes($options['app_path'])."' /><a class='kgvid_tooltip' href='javascript:void(0);'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>Don't include trailing slash. Example: <code>/usr/local/bin</code>. On Windows servers, use / instead of C:\\"."\n\t";
1947
  }
1948
 
1949
  function kgvid_video_app_callback() {
@@ -2441,9 +2456,14 @@ function kgvid_cron_new_attachment_handler($post_id) {
2441
  }
2442
 
2443
  $thumb_output = kgvid_make_thumbs($post_id, $movieurl, $numberofthumbs, 1, $iincreaser, $thumbtimecode, $dofirstframe, 'generate');
2444
- $thumb_id = kgvid_save_thumb($post_id, $post->post_title, $thumb_output['thumb_url']);
2445
- update_post_meta($post_id, '_kgflashmediaplayer-poster', $thumb_output['thumb_url']);
2446
- update_post_meta($post_id, '_kgflashmediaplayer-poster-id', $thumb_id);
 
 
 
 
 
2447
  if( $options['featured'] == "on" ) {
2448
  if ( !empty($thumb_id) && $post->post_parent ) { set_post_thumbnail($post->post_parent, $thumb_id); }
2449
  }
@@ -2582,9 +2602,9 @@ function kgvid_image_attachment_fields_to_edit($form_fields, $post) {
2582
  if ( $options['ffmpeg_exists'] == "on" && $options['auto_encode'] == "on" ) {
2583
  $update_script .= 'percent_timeout = setTimeout(function(){ kgvid_redraw_encode_checkboxes("'.$movieurl.'", "'.$post->ID.'", "attachment") }, 5000); jQuery(\'#wpwrap\').data("KGVIDCheckboxTimeout", percent_timeout);';
2584
  }
2585
- if ( $options['ffmpeg_exists'] == "on" && $options['auto_thumb'] == "on" ) {
2586
- if ( !$thumbnail_url ) { $thumbnail_html = '<div class="kgvid_thumbnail_box kgvid_chosen_thumbnail_box" style="height:112px;"><span style="margin-top: 45px;
2587
- display: inline-block;">Loading thumbnail...</span></div>'; }
2588
  $update_script .= ' setTimeout(function(){ kgvid_redraw_thumbnail_box("'.$post->ID.'") }, 5000);';
2589
  }
2590
  $update_script .= '});</script>';
@@ -2985,8 +3005,15 @@ function kgvid_ajax_redraw_thumbnail_box() {
2985
  check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
2986
 
2987
  $post_id = $_POST['post_id'];
2988
- $thumb_url = get_post_meta($post_id, "_kgflashmediaplayer-poster", true);
2989
- echo $thumb_url;
 
 
 
 
 
 
 
2990
  die();
2991
 
2992
  }
@@ -3228,7 +3255,7 @@ function media_embedurl_process() {
3228
  </div>
3229
  </div>
3230
 
3231
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-security]' id='attachments-kgflashmediaplayer-security' value='<?php echo wp_create_nonce('video-embed-thumbnail-generator-nonce'); ?>' />
3232
  <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-maxwidth]' id='attachments-singleurl-kgflashmediaplayer-maxwidth' value='<?php echo($maxwidth); ?>' />
3233
  <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-maxheight]' id='attachments-singleurl-kgflashmediaplayer-maxheight' value='<?php echo($maxheight); ?>' />
3234
  <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-aspect]' id='attachments-singleurl-kgflashmediaplayer-aspect' value='<?php echo(round($maxheight/$maxwidth, 3)); ?>' />
@@ -3412,10 +3439,10 @@ function kgvid_make_thumbs($postID, $movieurl, $numberofthumbs, $i, $iincreaser,
3412
  $movie_width = get_post_meta($postID, '_kgflashmediaplayer-actualwidth');
3413
  if ( empty($movie_width) ) {
3414
  $movie_info = kgvid_get_video_dimensions($moviefilepath);
3415
- update_post_meta($postID, '_kgflashmediaplayer-actualwidth', $movie_info['width']);
3416
- update_post_meta($postID, '_kgflashmediaplayer-actualheight', $movie_info['height']);
3417
- update_post_meta($postID, '_kgflashmediaplayer-duration', $movie_info['duration']);
3418
- if ( !empty($movie_info['rotate']) ) { update_post_meta($postID, '_kgflashmediaplayer-rotate', $movie_info['rotate']); }
3419
  }
3420
  else {
3421
  $movie_info = array (
@@ -3488,11 +3515,12 @@ function kgvid_make_thumbs($postID, $movieurl, $numberofthumbs, $i, $iincreaser,
3488
  }
3489
 
3490
  $ffmpeg_options = '-y -ss '.round($movieoffset).' -i "'.$moviefilepath.'"'.$movie_info['rotate'].' -qscale 1 -vframes 1 -f mjpeg "'.$thumbnailfilename[$i].'"';
 
3491
  $thumbnailurl = $thumbnailfilebase."_thumb".round($movieoffset).'.jpg';
3492
  $thumbnailurl = str_replace(" ", "_", $thumbnailurl);
3493
 
3494
  exec(escapeshellcmd($ffmpegPath." ".$ffmpeg_options));
3495
-
3496
  kgvid_schedule_cleanup_generated_files('thumbs');
3497
 
3498
  if (floatval($movieoffset) > 60) {
@@ -3827,6 +3855,7 @@ function kgvid_encode_videos() {
3827
  $cmd = escapeshellcmd($encode_string);
3828
 
3829
  if ( !empty($cmd) ) { $cmd = $cmd." > ".$logfile." 2>&1 & echo $!"; }
 
3830
  else {
3831
  $arr = array ( "embed_display"=>"<span style='color:red;'>Error: Command 'escapeshellcmd' is disabled on your server.</span>" );
3832
  return $arr;
@@ -3844,8 +3873,6 @@ function kgvid_encode_videos() {
3844
  wp_schedule_event( time()+86400, 'daily', 'kgvid_cleanup_queue', array ( 'scheduled' ) );
3845
  }
3846
 
3847
- //update_post_meta($video['attachmentID'], '_kgflashmediaplayer-encode'.$format, 'on');
3848
-
3849
  $video['encode_formats'][$queued_format] = array (
3850
  'name' => $video_formats[$queued_format]['name'],
3851
  'status' => 'encoding',
@@ -3871,10 +3898,6 @@ function kgvid_encode_videos() {
3871
 
3872
  } //end if there's stuff to encode
3873
 
3874
- //$output_map = array_map(create_function('$key, $value', 'return $key.":".$value." # ";'), array_keys($process->output), array_values($process->output));
3875
- //$output_implode = implode($output_map);
3876
- //$embed_display .= "Command: ".$cmd." Output: ".$output_implode;
3877
-
3878
  update_option('kgvid_video_embed_queue', $video_embed_queue);
3879
  kgvid_encode_progress($video_key, $queued_format, "attachment");
3880
 
@@ -4015,7 +4038,7 @@ function kgvid_encode_progress($video_key, $format, $page) {
4015
 
4016
  $embed_display = '<strong>'.ucwords($video_entry['encode_formats'][$format]['status']).'</strong> <div class="kgvid_meter"><div class="kgvid_meter_bar" style="width:'.$percent_done.'%;"><div class="kgvid_meter_text">'.$percent_done_text.'</div></div></div>';
4017
 
4018
- if ( current_user_can('encode_videos') ) {
4019
  $embed_display .= '<a href="javascript:void(0);" class="kgvid_cancel_button" id="attachments-'.$video_entry["attachmentID"].'-kgflashmediaplayer-cancelencode" onclick="kgvid_cancel_encode('.$pid.', \''.$video_entry["attachmentID"].'\', \''.$video_key.'\', \''.$format.'\');">Cancel</a>';
4020
  }
4021
 
@@ -4090,7 +4113,8 @@ function kgvid_encode_progress($video_key, $format, $page) {
4090
  }
4091
  elseif ( $video_embed_queue[$video_key]['encode_formats']['fullres']['status'] == "Encoding Complete" ) { //if there's nothing left to encode and we're replacing the original
4092
 
4093
- kgvid_replace_video( $video_key, 'fullres' );
 
4094
 
4095
  if ( $video_embed_queue[$video_key]['movie_info']['rotate'] != "" ) { //if the video needed rotating
4096
  $video_embed_queue[$video_key]['movie_info']['rotate'] = ""; //clear rotation because we've just fixed that problem
@@ -4108,6 +4132,9 @@ function kgvid_encode_progress($video_key, $format, $page) {
4108
  }
4109
  update_option('kgvid_video_embed_queue', $video_embed_queue);
4110
  }
 
 
 
4111
  }
4112
 
4113
  }
@@ -4117,22 +4144,29 @@ function kgvid_encode_progress($video_key, $format, $page) {
4117
  $lastline = "Encoding was canceled.";
4118
  }
4119
  $video_embed_queue[$video_key]['encode_formats'][$format]['status'] = "error";
4120
- $video_embed_queue[$video_key]['encode_formats'][$format]['lastline'] = $lastline;
4121
- update_option('kgvid_video_embed_queue', $video_embed_queue);
4122
- $other_message = $lastline;
4123
- $embed_display = '<strong>Error: </strong><span style="color:red;">'.$lastline.'.</span>';
4124
- $next_video = kgvid_encode_videos(); //start the next queued video
4125
- if ( !empty($next_video['format']) ) {
4126
- $embed_display .= '<script type="text/javascript">percent_timeout = setTimeout(function(){'.$script_function.'}, 1000);</script>';
4127
- $args = array($next_video['video_key'], $next_video['format'], $page);
4128
- wp_schedule_single_event(time()+60, 'kgvid_cron_queue_check', $args);
4129
- }
4130
  }
4131
 
4132
- //$embed_display .= $lastline;
4133
  $arr = array ( "embed_display"=>$embed_display );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4134
  }
4135
- else { $arr = array ( "embed_display"=>"<strong>No log file</strong>" ); }
4136
 
4137
  }//if not completed
4138
  else { $arr = array ( "embed_display"=>"<strong>".ucwords($video_embed_queue[$video_key]['encode_formats'][$format]['status'])."</strong>" ); }
@@ -4210,6 +4244,8 @@ function kgvid_replace_video ( $video_key, $format ) {
4210
  $post->guid = str_replace( $path_parts['extension'], $new_mime['ext'], $post->guid );
4211
  $post->post_mime_type = $new_mime['type'];
4212
  wp_update_post($post);
 
 
4213
  }
4214
 
4215
  function kgvid_clear_completed_queue($type) {
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 or LIBAV for encoding. <a href="options-general.php?page=video-embed-thumbnail-generator/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: 4.2.3
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
 
517
  function kgvid_get_video_dimensions($video = false) {
518
  $options = get_option('kgvid_video_embed_options');
519
  $ffmpegPath = $options['app_path']."/".$options['video_app'];
520
+ $movie_info = array();
521
 
522
  $video = str_replace("https://", "http://", $video);
523
 
530
  exec ( $command, $output );
531
  $lastline = end($output);
532
  $lastline = prev($output)."<br />".$lastline;
533
+ $movie_info['output'] = $lastline;
534
  $output = implode("\n", $output);
535
+ $regex = "/([0-9]{2,4})x([0-9]{2,4})/";
 
536
  if (preg_match($regex, $output, $regs)) { $result = $regs[0]; }
537
  else { $result = ""; }
538
 
539
  if ( !empty($result) ) {
540
  $movie_info['worked'] = true;
541
+ $movie_info['width'] = $regs [1] ? $regs [1] : null;
542
+ $movie_info['height'] = $regs [2] ? $regs [2] : null;
543
  preg_match('/Duration: (.*?),/', $output, $matches);
544
  $duration = $matches[1];
545
  $movie_duration_hours = intval(substr($duration, -11, 2));
571
  else { $movie_info['configuration'][$lib] = "false"; }
572
  }
573
 
 
574
 
575
+
576
+ }
577
+ else {
578
+ $movie_info['worked'] = false;
579
  }
580
 
581
+ return $movie_info;
582
  }
583
 
584
  function kgvid_generate_encode_string($input, $output, $libraries, $format, $width, $height, $rotate) {
689
  else { $this->OS = "linux"; }
690
 
691
  $command = $this->command;
692
+ if ($this->OS != "windows") {
693
+ exec($command ,$op);
694
+ $this->output = $op;
695
+ $this->pid = (int)$op[0];
696
+ }
697
+ else {
698
+ proc_close(proc_open ('start /B '.$command, array(), $foo));
699
+ }
700
  }
701
 
702
  public function setPid($pid){
1190
  $code .= "\n\t\t\t"."jQuery(document).ready(function(){ kgvid_setup_video('".$div_suffix."'); });";
1191
  }
1192
 
1193
+ if ( $query_atts["right_click"] != "on" ) { $code .= "\n\t\t\t"."jQuery('#video_".$div_suffix."_div').bind('contextmenu',function() { return false; });"; }
1194
  $code .= "\n\t\t"."</script>"."\n";
1195
 
1196
  } //end id_array loop
1380
  foreach ($video_embed_queue as $video_key => $video_entry) {
1381
  if ( $video_entry['movieurl'] == $movieurl ) {
1382
  foreach ( $video_entry['encode_formats'] as $format => $value ) {
1383
+ if ( array_key_exists($format, $video_formats) ) { //don't recreate any formats that were previously unset
1384
+ $video_formats[$format]['status'] = $value['status'];
1385
+ }
1386
  }
1387
  $video_queued = true;
1388
  break;
1391
  }
1392
 
1393
  $checkboxes = '<div id="attachments-'.$post_id.'-kgflashmediaplayer-encodeboxes">';
1394
+
1395
  foreach ( $video_formats as $format => $format_stats ) {
1396
  if ( strpos($post_mime_type, $format) !== false ) { continue; } //skip webm or ogv checkbox if the video is webm or ogv
1397
  $encodeset[$format] = "";
1431
  if ( $format_stats['status'] == "notchecked" ) { $meta[$format] = ' <strong>Encoded</strong>'; }
1432
  if ( $format_stats['status'] != "canceling" ) {
1433
  if ( array_key_exists($format.'id', $encodevideo_info) ) { $child_id[$format] = $encodevideo_info[$format.'id']; }
1434
+ if ( $encodevideo_info[$format.'_writable']
1435
+ && current_user_can('encode_videos')
1436
+ && $format != "fullres" ) {
1437
+ $meta[$format] .= '<a id="delete-'.$post_id.'-'.$format.'" class="kgvid_delete-format" onclick="kgvid_delete_video(\''.$movieurl.'\', \''.$post_id.'\', \''.$format.'\', \''.$child_id[$format].'\');" href="javascript:void(0)">Delete Permanently</a>';
1438
+ }
1439
  }
1440
  $disabled[$format] = ' disabled title="Format already exists"';
1441
  $checked[$format] = '';
1958
 
1959
  function kgvid_app_path_callback() {
1960
  $options = get_option('kgvid_video_embed_options');
1961
+ echo "<input class='affects_ffmpeg regular-text code' id='app_path' name='kgvid_video_embed_options[app_path]' type='text' value='".$options['app_path']."' /><a class='kgvid_tooltip' href='javascript:void(0);'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>Don't include trailing slash. Example: <code>/usr/local/bin</code>. On Windows servers, use / instead of C:\\"."\n\t";
1962
  }
1963
 
1964
  function kgvid_video_app_callback() {
2456
  }
2457
 
2458
  $thumb_output = kgvid_make_thumbs($post_id, $movieurl, $numberofthumbs, 1, $iincreaser, $thumbtimecode, $dofirstframe, 'generate');
2459
+
2460
+ if ( $thumb_output['lastthumbnumber'] != 'break' ) {
2461
+ $thumb_id = kgvid_save_thumb($post_id, $post->post_title, $thumb_output['thumb_url']);
2462
+ update_post_meta($post_id, '_kgflashmediaplayer-poster', $thumb_output['thumb_url']);
2463
+ update_post_meta($post_id, '_kgflashmediaplayer-poster-id', $thumb_id);
2464
+ }
2465
+ else { update_post_meta($post_id, '_kgflashmediaplayer-autothumb-error', $thumb_output['embed_display']); }
2466
+
2467
  if( $options['featured'] == "on" ) {
2468
  if ( !empty($thumb_id) && $post->post_parent ) { set_post_thumbnail($post->post_parent, $thumb_id); }
2469
  }
2602
  if ( $options['ffmpeg_exists'] == "on" && $options['auto_encode'] == "on" ) {
2603
  $update_script .= 'percent_timeout = setTimeout(function(){ kgvid_redraw_encode_checkboxes("'.$movieurl.'", "'.$post->ID.'", "attachment") }, 5000); jQuery(\'#wpwrap\').data("KGVIDCheckboxTimeout", percent_timeout);';
2604
  }
2605
+ if ( $options['ffmpeg_exists'] == "on" && $options['auto_thumb'] == "on" && !$thumbnail_url ) {
2606
+ $thumbnail_html = '<div class="kgvid_thumbnail_box kgvid_chosen_thumbnail_box" style="height:112px;"><span style="margin-top: 45px;
2607
+ display: inline-block;">Loading thumbnail...</span></div>';
2608
  $update_script .= ' setTimeout(function(){ kgvid_redraw_thumbnail_box("'.$post->ID.'") }, 5000);';
2609
  }
2610
  $update_script .= '});</script>';
3005
  check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
3006
 
3007
  $post_id = $_POST['post_id'];
3008
+ $poster_id = get_post_meta($post_id, "_kgflashmediaplayer-poster-id", true);
3009
+ $thumbnail_size_url = "";
3010
+ if ( $poster_id ) {
3011
+ $thumbnail_size_url = wp_get_attachment_image_src($poster_id, 'thumbnail');
3012
+ }
3013
+ $response['thumb_url'] = get_post_meta($post_id, "_kgflashmediaplayer-poster", true);
3014
+ $response['thumbnail_size_url'] = $thumbnail_size_url[0];
3015
+ $response['thumb_error'] = get_post_meta($post_id, "_kgflashmediaplayer-autothumb-error", true);
3016
+ echo json_encode($response);
3017
  die();
3018
 
3019
  }
3255
  </div>
3256
  </div>
3257
 
3258
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-security]' id='attachments-singleurl-kgflashmediaplayer-security' value='<?php echo wp_create_nonce('video-embed-thumbnail-generator-nonce'); ?>' />
3259
  <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-maxwidth]' id='attachments-singleurl-kgflashmediaplayer-maxwidth' value='<?php echo($maxwidth); ?>' />
3260
  <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-maxheight]' id='attachments-singleurl-kgflashmediaplayer-maxheight' value='<?php echo($maxheight); ?>' />
3261
  <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-aspect]' id='attachments-singleurl-kgflashmediaplayer-aspect' value='<?php echo(round($maxheight/$maxwidth, 3)); ?>' />
3439
  $movie_width = get_post_meta($postID, '_kgflashmediaplayer-actualwidth');
3440
  if ( empty($movie_width) ) {
3441
  $movie_info = kgvid_get_video_dimensions($moviefilepath);
3442
+ if ( !empty($movie_info['width']) ) { update_post_meta($postID, '_kgflashmediaplayer-actualwidth', $movie_info['width']); }
3443
+ if ( !empty($movie_info['height']) ) { update_post_meta($postID, '_kgflashmediaplayer-actualheight', $movie_info['height']); }
3444
+ if ( !empty($movie_info['duration']) ) { update_post_meta($postID, '_kgflashmediaplayer-duration', $movie_info['duration']); }
3445
+ if ( !empty($movie_info['rotate']) ) { update_post_meta($postID, '_kgflashmediaplayer-rotate', $movie_info['rotate']); }
3446
  }
3447
  else {
3448
  $movie_info = array (
3515
  }
3516
 
3517
  $ffmpeg_options = '-y -ss '.round($movieoffset).' -i "'.$moviefilepath.'"'.$movie_info['rotate'].' -qscale 1 -vframes 1 -f mjpeg "'.$thumbnailfilename[$i].'"';
3518
+
3519
  $thumbnailurl = $thumbnailfilebase."_thumb".round($movieoffset).'.jpg';
3520
  $thumbnailurl = str_replace(" ", "_", $thumbnailurl);
3521
 
3522
  exec(escapeshellcmd($ffmpegPath." ".$ffmpeg_options));
3523
+ if ( is_file($thumbnailfilename[$i]) )
3524
  kgvid_schedule_cleanup_generated_files('thumbs');
3525
 
3526
  if (floatval($movieoffset) > 60) {
3855
  $cmd = escapeshellcmd($encode_string);
3856
 
3857
  if ( !empty($cmd) ) { $cmd = $cmd." > ".$logfile." 2>&1 & echo $!"; }
3858
+
3859
  else {
3860
  $arr = array ( "embed_display"=>"<span style='color:red;'>Error: Command 'escapeshellcmd' is disabled on your server.</span>" );
3861
  return $arr;
3873
  wp_schedule_event( time()+86400, 'daily', 'kgvid_cleanup_queue', array ( 'scheduled' ) );
3874
  }
3875
 
 
 
3876
  $video['encode_formats'][$queued_format] = array (
3877
  'name' => $video_formats[$queued_format]['name'],
3878
  'status' => 'encoding',
3898
 
3899
  } //end if there's stuff to encode
3900
 
 
 
 
 
3901
  update_option('kgvid_video_embed_queue', $video_embed_queue);
3902
  kgvid_encode_progress($video_key, $queued_format, "attachment");
3903
 
4038
 
4039
  $embed_display = '<strong>'.ucwords($video_entry['encode_formats'][$format]['status']).'</strong> <div class="kgvid_meter"><div class="kgvid_meter_bar" style="width:'.$percent_done.'%;"><div class="kgvid_meter_text">'.$percent_done_text.'</div></div></div>';
4040
 
4041
+ if ( current_user_can('encode_videos') && $pid ) {
4042
  $embed_display .= '<a href="javascript:void(0);" class="kgvid_cancel_button" id="attachments-'.$video_entry["attachmentID"].'-kgflashmediaplayer-cancelencode" onclick="kgvid_cancel_encode('.$pid.', \''.$video_entry["attachmentID"].'\', \''.$video_key.'\', \''.$format.'\');">Cancel</a>';
4043
  }
4044
 
4113
  }
4114
  elseif ( $video_embed_queue[$video_key]['encode_formats']['fullres']['status'] == "Encoding Complete" ) { //if there's nothing left to encode and we're replacing the original
4115
 
4116
+ $new_movie_url = kgvid_replace_video( $video_key, 'fullres' );
4117
+ $script_function = 'kgvid_redraw_encode_checkboxes("'.$new_movie_url.'", "'.$video_entry['attachmentID'].'", "'.$page.'")';
4118
 
4119
  if ( $video_embed_queue[$video_key]['movie_info']['rotate'] != "" ) { //if the video needed rotating
4120
  $video_embed_queue[$video_key]['movie_info']['rotate'] = ""; //clear rotation because we've just fixed that problem
4132
  }
4133
  update_option('kgvid_video_embed_queue', $video_embed_queue);
4134
  }
4135
+
4136
+ $embed_display = '<strong>Encoding Complete</strong> <script type="text/javascript">percent_timeout = setTimeout(function(){'.$script_function.'}, 1000);</script>';
4137
+
4138
  }
4139
 
4140
  }
4144
  $lastline = "Encoding was canceled.";
4145
  }
4146
  $video_embed_queue[$video_key]['encode_formats'][$format]['status'] = "error";
4147
+
 
 
 
 
 
 
 
 
 
4148
  }
4149
 
 
4150
  $arr = array ( "embed_display"=>$embed_display );
4151
+ } //if logfile
4152
+ else {
4153
+
4154
+ $video_embed_queue[$video_key]['encode_formats'][$format]['status'] = "error";
4155
+ $lastline = "No log file";
4156
+
4157
+ }
4158
+
4159
+ if ( $video_embed_queue[$video_key]['encode_formats'][$format]['status'] == "error" ) {
4160
+ $video_embed_queue[$video_key]['encode_formats'][$format]['lastline'] = $lastline;
4161
+ update_option('kgvid_video_embed_queue', $video_embed_queue);
4162
+ $embed_display = '<strong>Error: </strong><span style="color:red;">'.$lastline.'.</span>';
4163
+ $next_video = kgvid_encode_videos(); //start the next queued video
4164
+ if ( !empty($next_video['format']) ) {
4165
+ $embed_display .= '<script type="text/javascript">percent_timeout = setTimeout(function(){'.$script_function.'}, 1000);</script>';
4166
+ $args = array($next_video['video_key'], $next_video['format'], $page);
4167
+ wp_schedule_single_event(time()+60, 'kgvid_cron_queue_check', $args);
4168
+ }
4169
  }
 
4170
 
4171
  }//if not completed
4172
  else { $arr = array ( "embed_display"=>"<strong>".ucwords($video_embed_queue[$video_key]['encode_formats'][$format]['status'])."</strong>" ); }
4244
  $post->guid = str_replace( $path_parts['extension'], $new_mime['ext'], $post->guid );
4245
  $post->post_mime_type = $new_mime['type'];
4246
  wp_update_post($post);
4247
+
4248
+ return $new_url;
4249
  }
4250
 
4251
  function kgvid_clear_completed_queue($type) {