Video Embed & Thumbnail Generator - Version 2.0.4

Version Description

  • April 19, 2012 =
  • Once again changed the process checking for FFMPEG installations. Should be universal now.
  • Added setting to turn on vpre flags for users with installed versions of FFMPEG old enough that libx264 requires vpre flags to operate.
  • Added setting to replace the video attachment template with a page containing only the code necessary to display the video. Makes embedding your hosted videos on other sites easier.
  • Fixed progress bar for older versions of FFMPEG.
  • Added Flash fallback when OGV or WEBM videos are embedded.
Download this release

Release Info

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

Code changes from version 2.0.3 to 2.0.4

kg_callffmpeg.php CHANGED
@@ -244,8 +244,10 @@ if ($action == "generate" || $action == "encode" ) {
244
  else { $aaclib = "libvo_aacenc"; }
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
@@ -301,10 +303,10 @@ if ($action == "generate" || $action == "encode" ) {
301
 
302
  $embed_display .= " <em><small>(continues if window is closed)</small></em>";
303
 
304
- //$output_map = array_map(create_function('$key, $value', 'return $key.":".$value." # ";'), array_keys($process->output), array_values($process->output));
305
- //$output_implode = implode($output_map);
306
 
307
- //$embed_display .= "Command: ".$cmd." Status: ".$process->status()." Output: ".$output_implode;
308
 
309
  }//if any HTML5 videos don't already exist
310
 
244
  else { $aaclib = "libvo_aacenc"; }
245
 
246
  $ipodbitrate = $movie_height * 3;
247
+ $vpre_flags = "";
248
+ if ( get_option('wp_FMP_vpre') == 'true' ) { $vpre_flags = '-vpre slow -vpre ipod640'; }
249
 
250
+ $ffmpeg_ipod_options = ' -acodec '.$aaclib.' -ab 128k -s '.$ipod_movie_width.'x'.$ipod_movie_height.' -vcodec libx264 '.$vpre_flags.' -threads 1 '.$movie_rotate.' -b '.$ipodbitrate.'k -bt 800k -f ipod "'.$encodevideo_info['mobilefilepath'].'"';
251
  $encode_anything = "true";
252
  $embed_display .= "<strong> Encoding Mobile M4V. </strong>";
253
  }//if the proper FFMPEG libraries are enabled
303
 
304
  $embed_display .= " <em><small>(continues if window is closed)</small></em>";
305
 
306
+ $output_map = array_map(create_function('$key, $value', 'return $key.":".$value." # ";'), array_keys($process->output), array_values($process->output));
307
+ $output_implode = implode($output_map);
308
 
309
+ //$embed_display .= "Command: ".$cmd." Output: ".$output_implode;
310
 
311
  }//if any HTML5 videos don't already exist
312
 
kg_video_plugin.js CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  function kg_set_dimension(postID, valuetochange, currentvalue) {
2
  var kg_aspect = (document.getElementById('attachments['+postID+'][kgflashmediaplayer-aspect]').value);
3
  var changeaspect = kg_aspect;
@@ -35,12 +38,17 @@ function kg_generate_thumb(postID, buttonPushed) {
35
  var altembedselectid = "#attachments_"+postID+"_altembedselect";
36
  var thumbnailboxID = "#attachments_"+postID+"_kgflashmediaplayer-thumbnailbox";
37
  var thumbnailboxoverlayID = "#attachments_"+postID+"_kgflashmediaplayer-thumbnailboxoverlay";
 
38
  var widthID = 'attachments_'+postID+'_kgflashmediaplayer-width';
39
  var heightID = 'attachments_'+postID+'_kgflashmediaplayer-height';
40
  var widthsaveID = 'attachments['+postID+'][kgflashmediaplayer-widthsave]';
41
  var heightsaveID = 'attachments['+postID+'][kgflashmediaplayer-heightsave]';
42
  var maxwidthID = 'attachments['+postID+'][kgflashmediaplayer-maxwidth]';
43
  var maxheightID = 'attachments['+postID+'][kgflashmediaplayer-maxheight]';
 
 
 
 
44
 
45
  if (buttonPushed == "generate" || buttonPushed == "random" ) {
46
  actionName = "generate";
@@ -52,8 +60,9 @@ function kg_generate_thumb(postID, buttonPushed) {
52
  }
53
 
54
  if (buttonPushed != "encode") {
 
55
  jQuery(thumbnailplaceholderid).empty();
56
- jQuery(thumbnailplaceholderid).append('<p><strong>Choose Thumbnail:</strong></p><div id="attachments_'+postID+'_kgflashmediaplayer-thumbnailboxoverlay" name="attachments_'+postID+'_kgflashmediaplayer-thumbnailboxoverlay" class="kg_thumbnail_overlay"><div id="attachments_'+postID+'_kgflashmediaplayer-ajaxloading" name="attachments_'+postID+'_kgflashmediaplayer-ajaxloading" class="kg_ajax_loading"></div><div name="attachments_'+postID+'_kgflashmediaplayer-thumbnailbox" id="attachments_'+postID+'_kgflashmediaplayer-thumbnailbox" class="kg_thumbnail_box"></div></div>');
57
  }
58
 
59
  if (buttonPushed == "encode") {
@@ -62,13 +71,6 @@ function kg_generate_thumb(postID, buttonPushed) {
62
  jQuery(encodeplaceholderid).append('<strong>Encoding...</strong>');
63
  }
64
 
65
-
66
- var i=1;
67
- var increaser = 0;
68
- var iincreaser = 0;
69
-
70
- //for (i=1; i<=howmanythumbs; i++) { //loop until thumbnails are generated
71
-
72
  function kg_do_post() {
73
 
74
  iincreaser = i + increaser;
@@ -82,11 +84,14 @@ function kg_generate_thumb(postID, buttonPushed) {
82
  //jQuery(thumbnailselectID).fadeIn(1000);
83
  jQuery(thumbnailselectID).animate({opacity: 'toggle', height: 'toggle', width: 'toggle'}, 1000);
84
  //jQuery(thumbnailselectID).animate({display:"inline-block"}, 2000);
85
- if (data.lastthumbnumber != "break") { i = parseInt(data.lastthumbnumber); }
86
  else { i = howmanythumbs + 1; }
87
  increaser++;
88
- if ( i <= howmanythumbs ) { setTimeout(function(){kg_do_post()}, 1000); }
89
- else { jQuery(thumbnailboxoverlayID).fadeTo(2000, 1); }
 
 
 
90
 
91
  kg_aspect = data.movie_height/data.movie_width;
92
  document.getElementById('attachments['+postID+'][kgflashmediaplayer-aspect]').value = kg_aspect;
@@ -131,19 +136,31 @@ function kg_generate_thumb(postID, buttonPushed) {
131
  function kg_insert_shortcode() {
132
 
133
  var kgflashmediaplayersecurity = document.getElementById('attachments[singleurl][kgflashmediaplayer-security]').value;
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
- jQuery.post(ajaxurl, { action:'kg_callffmpeg', security: kgflashmediaplayersecurity, attachmentID: 'singleurl', movieurl: document.getElementById('attachments[singleurl][kgflashmediaplayer-url]').value, ffmpeg_action:'submit', poster: document.getElementById('attachments[singleurl][kgflashmediaplayer-poster]').value }, function(data) {
136
  jQuery('attachments_singleurl_thumbnailplaceholder').empty();
137
  }, "json" );
138
 
139
  var shortcode = "";
140
  if (document.getElementById('videotitle').value != "") { shortcode += '<strong>' + document.getElementById('videotitle').value + '</strong><br />'; }
141
- if (document.getElementById('attachments[singleurl][kgflashmediaplayer-url]').value !="") {
142
  shortcode += ' [FMP';
143
  if (document.getElementById('attachments[singleurl][kgflashmediaplayer-poster]').value !="") { shortcode += ' poster="' + document.getElementById("attachments[singleurl][kgflashmediaplayer-poster]").value + '"'; }
144
  if (document.getElementById('attachments_singleurl_kgflashmediaplayer-width').value !="") { shortcode += ' width="' + document.getElementById("attachments_singleurl_kgflashmediaplayer-width").value + '"'; }
145
  if (document.getElementById('attachments_singleurl_kgflashmediaplayer-height').value !="") { shortcode += ' height="' + document.getElementById("attachments_singleurl_kgflashmediaplayer-height").value + '"'; }
146
- shortcode += ']' + document.getElementById('attachments[singleurl][kgflashmediaplayer-url]').value + '[/FMP] '; }
147
  if (document.getElementById('downloadlink').checked) { shortcode += '<br /><a href="' + document.getElementById("attachments[singleurl][kgflashmediaplayer-url]").value + '">Right-click or ctrl-click this link to download</a>'; }
148
 
149
  parent.send_to_editor(shortcode);
@@ -234,4 +251,14 @@ function kg_cancel_encode(kg_pid, postID) {
234
 
235
  jQuery.post(ajaxurl, { action:"kg_cancel_encode", security: kgflashmediaplayersecurity, kg_pid: kg_pid } );
236
 
237
- }
 
 
 
 
 
 
 
 
 
 
1
+ var kgthumbnailTimeout = new Array();
2
+ var kgstopthumb;
3
+
4
  function kg_set_dimension(postID, valuetochange, currentvalue) {
5
  var kg_aspect = (document.getElementById('attachments['+postID+'][kgflashmediaplayer-aspect]').value);
6
  var changeaspect = kg_aspect;
38
  var altembedselectid = "#attachments_"+postID+"_altembedselect";
39
  var thumbnailboxID = "#attachments_"+postID+"_kgflashmediaplayer-thumbnailbox";
40
  var thumbnailboxoverlayID = "#attachments_"+postID+"_kgflashmediaplayer-thumbnailboxoverlay";
41
+ var cancelthumbdivID = '#attachments_'+postID+'_kgflashmediaplayer-cancelthumbsdiv';
42
  var widthID = 'attachments_'+postID+'_kgflashmediaplayer-width';
43
  var heightID = 'attachments_'+postID+'_kgflashmediaplayer-height';
44
  var widthsaveID = 'attachments['+postID+'][kgflashmediaplayer-widthsave]';
45
  var heightsaveID = 'attachments['+postID+'][kgflashmediaplayer-heightsave]';
46
  var maxwidthID = 'attachments['+postID+'][kgflashmediaplayer-maxwidth]';
47
  var maxheightID = 'attachments['+postID+'][kgflashmediaplayer-maxheight]';
48
+ kgstopthumb = false;
49
+ var i=1;
50
+ var increaser = 0;
51
+ var iincreaser = 0;
52
 
53
  if (buttonPushed == "generate" || buttonPushed == "random" ) {
54
  actionName = "generate";
60
  }
61
 
62
  if (buttonPushed != "encode") {
63
+
64
  jQuery(thumbnailplaceholderid).empty();
65
+ jQuery(thumbnailplaceholderid).append('<strong>Choose Thumbnail: </strong><div style="display:inline-block;" id="attachments_'+postID+'_kgflashmediaplayer-cancelthumbsdiv" name="attachments_'+postID+'_kgflashmediaplayer-cancelthumbsdiv"> <input type="button" id="attachments_'+postID+'_kgflashmediaplayer-cancelencode" class="button-secondary" value="Cancel Generating" name="attachments_'+postID+'_cancelencode" onclick="kg_cancel_thumbs(\''+postID+'\');kgstopthumb=true;"></div><div id="attachments_'+postID+'_kgflashmediaplayer-thumbnailboxoverlay" name="attachments_'+postID+'_kgflashmediaplayer-thumbnailboxoverlay" class="kg_thumbnail_overlay"><div name="attachments_'+postID+'_kgflashmediaplayer-thumbnailbox" id="attachments_'+postID+'_kgflashmediaplayer-thumbnailbox" class="kg_thumbnail_box"></div></div>');
66
  }
67
 
68
  if (buttonPushed == "encode") {
71
  jQuery(encodeplaceholderid).append('<strong>Encoding...</strong>');
72
  }
73
 
 
 
 
 
 
 
 
74
  function kg_do_post() {
75
 
76
  iincreaser = i + increaser;
84
  //jQuery(thumbnailselectID).fadeIn(1000);
85
  jQuery(thumbnailselectID).animate({opacity: 'toggle', height: 'toggle', width: 'toggle'}, 1000);
86
  //jQuery(thumbnailselectID).animate({display:"inline-block"}, 2000);
87
+ if (data.lastthumbnumber != "break" && kgstopthumb == false) { i = parseInt(data.lastthumbnumber); }
88
  else { i = howmanythumbs + 1; }
89
  increaser++;
90
+ if ( i <= howmanythumbs ) { kgthumbnailTimeout[i] = setTimeout(function(){kg_do_post()}, 750); }
91
+ else {
92
+ jQuery(thumbnailboxoverlayID).fadeTo(2000, 1);
93
+ jQuery(cancelthumbdivID).animate({opacity: 0}, 500);
94
+ }
95
 
96
  kg_aspect = data.movie_height/data.movie_width;
97
  document.getElementById('attachments['+postID+'][kgflashmediaplayer-aspect]').value = kg_aspect;
136
  function kg_insert_shortcode() {
137
 
138
  var kgflashmediaplayersecurity = document.getElementById('attachments[singleurl][kgflashmediaplayer-security]').value;
139
+ var url = document.getElementById('attachments[singleurl][kgflashmediaplayer-url]').value;
140
+ var alturl = "";
141
+
142
+ if ( document.getElementById('attachments[singleurl][kgflashmediaplayer-altembed]') ) { alturl = document.getElementById('attachments[singleurl][kgflashmediaplayer-altembed]').value; }
143
+ if ( alturl != "" ) { url = alturl; }
144
+ var validExtensions = new Array(".flv", ".f4v", ".mp4", ".mov", ".m4v", ".webm", ".ogg", ".ogv");
145
+ var extension;
146
+ var extensionExists = false;
147
+ for (extension in validExtensions) {
148
+ if (url.indexOf(extension) != -1) { extensionExists = true; break; }
149
+ }
150
+ if (extensionExists == false) { alert("Please enter a URL that points to a valid video file. Video sharing sites are not supported by this plugin.\nTo embed from YouTube, Vimeo, etc, just paste the link directly into the post window and WordPress will handle the rest."); return; }
151
 
152
+ jQuery.post(ajaxurl, { action:'kg_callffmpeg', security: kgflashmediaplayersecurity, attachmentID: 'singleurl', movieurl: url, ffmpeg_action:'submit', poster: document.getElementById('attachments[singleurl][kgflashmediaplayer-poster]').value }, function(data) {
153
  jQuery('attachments_singleurl_thumbnailplaceholder').empty();
154
  }, "json" );
155
 
156
  var shortcode = "";
157
  if (document.getElementById('videotitle').value != "") { shortcode += '<strong>' + document.getElementById('videotitle').value + '</strong><br />'; }
158
+ if (url !="") {
159
  shortcode += ' [FMP';
160
  if (document.getElementById('attachments[singleurl][kgflashmediaplayer-poster]').value !="") { shortcode += ' poster="' + document.getElementById("attachments[singleurl][kgflashmediaplayer-poster]").value + '"'; }
161
  if (document.getElementById('attachments_singleurl_kgflashmediaplayer-width').value !="") { shortcode += ' width="' + document.getElementById("attachments_singleurl_kgflashmediaplayer-width").value + '"'; }
162
  if (document.getElementById('attachments_singleurl_kgflashmediaplayer-height').value !="") { shortcode += ' height="' + document.getElementById("attachments_singleurl_kgflashmediaplayer-height").value + '"'; }
163
+ shortcode += ']' + url + '[/FMP] '; }
164
  if (document.getElementById('downloadlink').checked) { shortcode += '<br /><a href="' + document.getElementById("attachments[singleurl][kgflashmediaplayer-url]").value + '">Right-click or ctrl-click this link to download</a>'; }
165
 
166
  parent.send_to_editor(shortcode);
251
 
252
  jQuery.post(ajaxurl, { action:"kg_cancel_encode", security: kgflashmediaplayersecurity, kg_pid: kg_pid } );
253
 
254
+ }
255
+
256
+
257
+ function kg_cancel_thumbs(postID) {
258
+ for( key in kgthumbnailTimeout ){ clearTimeout(kgthumbnailTimeout[key]); }
259
+ var thumbnailboxoverlayID = "#attachments_"+postID+"_kgflashmediaplayer-thumbnailboxoverlay";
260
+ jQuery(thumbnailboxoverlayID).fadeTo(2000, 1);
261
+ var cancelthumbdivID = '#attachments_'+postID+'_kgflashmediaplayer-cancelthumbsdiv';
262
+ jQuery(cancelthumbdivID).animate({opacity: 0}, 500);
263
+ jQuery(cancelthumbdivID).remove;
264
+ }
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.3
8
 
9
  Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes.
10
 
@@ -43,6 +43,10 @@ width="720" height="404"]http://www.kylegilman.net/wp-content/uploads/2011/10/Re
43
 
44
  After you save the post, the thumbnail file will be registered in the Wordpress Media Library and added to the post's attachments. Thumbnails are saved in the current Wordpress uploads directory. Encoded videos are not yet registered with the media library.
45
 
 
 
 
 
46
  = If you want to further modify the way the Flash video player works, you can add the following options inside the [FMP] tag. These will override anything you’ve set in the plugin settings. =
47
 
48
  * `poster="http://www.example.com/image.jpg"` sets the thumbnail
@@ -78,7 +82,11 @@ AddType video/webm .webm`
78
 
79
  = Why doesn't my video play? =
80
 
81
- Most of the time your video doesn't play because it's not encoded in the right format. Videos have containers like mp4, mov, ogv, mkv, flv, etc and within those containers there are video and audio codecs like H.264, MPEG-4, VP8, etc. The best option for this plugin is an mp4 container with H.264 video and AAC audio. mp4s with MPEG-4 video will not play in the Flash player, and if you don't use AAC audio you won't get any audio.
 
 
 
 
82
 
83
  = Why doesn't this work with YouTube? =
84
 
@@ -86,7 +94,11 @@ WordPress already has <a href="http://codex.wordpress.org/Embeds">a built-in sys
86
 
87
  = I'm on shared hosting and can't install software. Does this work without FFMPEG? =
88
 
89
- Some of it will work without FFMPEG. You can generate embed codes for your videos on any host because that part of the plugin is JavaScript running in your browser. But without FFMPEG you won't be able to generate thumbnails or generate HTML5 videos. There is no way around this. A program has to read the video files in order to generate the thumbnails, and FFMPEG is the best one I've found to do that.
 
 
 
 
90
 
91
  = Why doesn't the encoding progress bar work on Windows servers? =
92
 
@@ -101,6 +113,13 @@ Because I can't figure out how to do it. Windows works a little differently from
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.
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.4
8
 
9
  Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes.
10
 
43
 
44
  After you save the post, the thumbnail file will be registered in the Wordpress Media Library and added to the post's attachments. Thumbnails are saved in the current Wordpress uploads directory. Encoded videos are not yet registered with the media library.
45
 
46
+ = To embed videos on other sites = turn on the Attachment Template Override in the plugin settings. This will replace your video attachment template with a page that only has enough code to display the video. You can then embed the video using code like this
47
+
48
+ `<iframe width="960" height="540" frameborder="0" scrolling="no" src="http://www.kylegilman.net/?attachment_id=1906"></iframe>`
49
+
50
  = If you want to further modify the way the Flash video player works, you can add the following options inside the [FMP] tag. These will override anything you’ve set in the plugin settings. =
51
 
52
  * `poster="http://www.example.com/image.jpg"` sets the thumbnail
82
 
83
  = Why doesn't my video play? =
84
 
85
+ Most of the time your video doesn't play because it's not encoded in the right format. Videos have containers like mp4, mov, ogv, mkv, flv, etc and within those containers there are video and audio codecs like H.264, MPEG-4, VP8, etc. The best option for this plugin is an mp4 container with H.264 video and AAC audio. mp4s with MPEG-4 video will not play in the Flash player, and if you don't use AAC audio you won't get any audio.
86
+
87
+ If you recorded the video using a Samsung Galaxy S II phone, even though most programs will tell you it's H.264 video with AAC audio, there's a good chance that it's actually recorded in 3gp4 format, which won't work with the Flash player. Use MediaInfo Library to get really detailed information about your media files.
88
+
89
+ The Flash player will not play mp4/m4v/mov files that don't have the MooV atom at the head of the file. FFMPEG puts the moov atom at the end of the file, so this can be a problem. I'm working on a solution for an upcoming version of the plugin.
90
 
91
  = Why doesn't this work with YouTube? =
92
 
94
 
95
  = I'm on shared hosting and can't install software. Does this work without FFMPEG? =
96
 
97
+ Some of it will work without FFMPEG. You can generate embed codes for your videos on any host because that part of the plugin is JavaScript running in your browser. But without FFMPEG you won't be able to generate thumbnails or generate HTML5 videos. There is no way around this. A program has to read the video files in order to generate the thumbnails, and FFMPEG is the best one I've found to do that. Dreamhost is one of the few shared hosts I know of that has FFMPEG installed and available for users.
98
+
99
+ = How can I encode videos in directories protected by .htaccess passwords? =
100
+
101
+ Use the "Embed from URL" tab. Use the format http://username:password@yourdomain.com/uploads/2012/01/awesomevid.mp4 in the Video URL field.
102
 
103
  = Why doesn't the encoding progress bar work on Windows servers? =
104
 
113
 
114
  == Changelog ==
115
 
116
+ = 2.0.4 - April 19, 2012 =
117
+ * Once again changed the process checking for FFMPEG installations. Should be universal now.
118
+ * Added setting to turn on vpre flags for users with installed versions of FFMPEG old enough that libx264 requires vpre flags to operate.
119
+ * Added setting to replace the video attachment template with a page containing only the code necessary to display the video. Makes embedding your hosted videos on other sites easier.
120
+ * Fixed progress bar for older versions of FFMPEG.
121
+ * Added Flash fallback when OGV or WEBM videos are embedded.
122
+
123
  = 2.0.3 - February 24, 2012 =
124
  * 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.
125
  * Changed encoding bitrate flag back to -b instead of -b:v to retain compatibility with older versions of FFMPEG.
video-embed-thumbnail-generator.css CHANGED
@@ -1,171 +1,171 @@
1
- .meter, .meter_finished {
2
- margin-top: 5px;
3
- height: 18px;
4
- width: 280px;
5
- display: inline-block;
6
- position: relative;
7
- background: #e4e4e4;
8
- -moz-border-radius: 12px;
9
- -webkit-border-radius: 12px;
10
- border-radius: 12px;
11
- padding: 5px;
12
- -webkit-box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3);
13
- -moz-box-shadow : inset 0 -1px 1px rgba(255,255,255,0.3);
14
- box-shadow : inset 0 -1px 1px rgba(255,255,255,0.3);
15
- }
16
-
17
- .meter > span {
18
- text-align: right;
19
- padding-right: 5px;
20
- font-weight: bold;
21
- color: white;
22
- font-size: 80%;
23
- display: inline-block;
24
- height: 100%;
25
- -webkit-border-top-right-radius: 4px;
26
- -webkit-border-bottom-right-radius: 4px;
27
- -moz-border-radius-topright: 4px;
28
- -moz-border-radius-bottomright: 4px;
29
- border-top-right-radius: 4px;
30
- border-bottom-right-radius: 4px;
31
- -webkit-border-top-left-radius: 10px;
32
- -webkit-border-bottom-left-radius: 10px;
33
- -moz-border-radius-topleft: 10px;
34
- -moz-border-radius-bottomleft: 10px;
35
- border-top-left-radius: 10px;
36
- border-bottom-left-radius: 10px;
37
- background-color: rgb(41,140,186);
38
- background-image: -webkit-gradient(
39
- linear,
40
- left bottom,
41
- left top,
42
- color-stop(0, rgb(41,140,186)),
43
- color-stop(1, rgb(64,176,228))
44
- );
45
- background-image: -webkit-linear-gradient(
46
- center bottom,
47
- rgb(41,140,186) 37%,
48
- rgb(64,176,228) 69%
49
- );
50
- background-image: -moz-linear-gradient(
51
- center bottom,
52
- rgb(41,140,186) 37%,
53
- rgb(64,176,228) 69%
54
- );
55
- background-image: -ms-linear-gradient(
56
- center bottom,
57
- rgb(41,140,186) 37%,
58
- rgb(64,176,228) 69%
59
- );
60
- background-image: -o-linear-gradient(
61
- center bottom,
62
- rgb(41,140,186) 37%,
63
- rgb(64,176,228) 69%
64
- );
65
- -webkit-box-shadow:
66
- inset 0 2px 9px rgba(255,255,255,0.3),
67
- inset 0 -2px 6px rgba(0,0,0,0.4);
68
- -moz-box-shadow:
69
- inset 0 2px 9px rgba(255,255,255,0.3),
70
- inset 0 -2px 6px rgba(0,0,0,0.4);
71
- position: relative;
72
- overflow: hidden;
73
- }
74
-
75
-
76
- .meter_finished > span {
77
- text-align: center;
78
- font-weight: bold;
79
- color: white;
80
- font-size: 80%;
81
- display: inline-block;
82
- height: 100%;
83
- -webkit-border-top-right-radius: 10px;
84
- -webkit-border-bottom-right-radius: 10px;
85
- -moz-border-radius-topright: 10px;
86
- -moz-border-radius-bottomright: 10px;
87
- border-top-right-radius: 10px;
88
- border-bottom-right-radius: 10px;
89
- -webkit-border-top-left-radius: 10px;
90
- -webkit-border-bottom-left-radius: 10px;
91
- -moz-border-radius-topleft: 10px;
92
- -moz-border-radius-bottomleft: 10px;
93
- border-top-left-radius: 10px;
94
- border-bottom-left-radius: 10px;
95
- background-color: rgb(41,140,186);
96
- background-image: -webkit-gradient(
97
- linear,
98
- left bottom,
99
- left top,
100
- color-stop(0, rgb(41,140,186)),
101
- color-stop(1, rgb(41,140,186))
102
- );
103
- background-image: -webkit-linear-gradient(
104
- center bottom,
105
- rgb(41,140,186) 37%,
106
- rgb(41,140,186) 69%
107
- );
108
- background-image: -moz-linear-gradient(
109
- center bottom,
110
- rgb(41,140,186) 37%,
111
- rgb(41,140,186) 69%
112
- );
113
- background-image: -ms-linear-gradient(
114
- center bottom,
115
- rgb(41,140,186) 37%,
116
- rgb(41,140,186) 69%
117
- );
118
- background-image: -o-linear-gradient(
119
- center bottom,
120
- rgb(41,140,186) 37%,
121
- rgb(41,140,186) 69%
122
- );
123
- -webkit-box-shadow:
124
- inset 0 2px 9px rgba(255,255,255,0.3),
125
- inset 0 -2px 6px rgba(0,0,0,0.4);
126
- -moz-box-shadow:
127
- inset 0 2px 9px rgba(255,255,255,0.3),
128
- inset 0 -2px 6px rgba(0,0,0,0.4);
129
- position: relative;
130
- overflow: hidden;
131
- }
132
-
133
- div.kg_thumbnail_box {
134
- border-style:solid;
135
- border-color:#ccc;
136
- border-width:1px;
137
- width:425px;
138
- text-align:center;
139
- margin-bottom:10px;
140
- padding:5px;
141
- }
142
-
143
- div.kg_thumbnail_overlay {
144
- width: 100%;
145
- height:100%;
146
- background: #fff;
147
- opacity: 0.5;
148
- filter: alpha(opacity = 50); /* required for opacity to work in IE */
149
- }
150
-
151
- div.kg_thumbnail_select {
152
- text-align:center;
153
- display:inline-block;
154
- }
155
-
156
- img.kg_thumbnail {
157
- margin:2px;
158
- }
159
-
160
- .kg_embedselect {
161
- border-left:2px solid #ccc;
162
- display:inline;
163
- padding-left:8px;
164
- }
165
-
166
- div.kg_cancel_button {
167
- display:inline-block;
168
- vertical-align:top;
169
- margin-top:7px;
170
- padding-left:5px;
171
  }
1
+ .meter, .meter_finished {
2
+ margin-top: 5px;
3
+ height: 18px;
4
+ width: 280px;
5
+ display: inline-block;
6
+ position: relative;
7
+ background: #e4e4e4;
8
+ -moz-border-radius: 12px;
9
+ -webkit-border-radius: 12px;
10
+ border-radius: 12px;
11
+ padding: 5px;
12
+ -webkit-box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3);
13
+ -moz-box-shadow : inset 0 -1px 1px rgba(255,255,255,0.3);
14
+ box-shadow : inset 0 -1px 1px rgba(255,255,255,0.3);
15
+ }
16
+
17
+ .meter > span {
18
+ text-align: right;
19
+ padding-right: 5px;
20
+ font-weight: bold;
21
+ color: white;
22
+ font-size: 80%;
23
+ display: inline-block;
24
+ height: 100%;
25
+ -webkit-border-top-right-radius: 4px;
26
+ -webkit-border-bottom-right-radius: 4px;
27
+ -moz-border-radius-topright: 4px;
28
+ -moz-border-radius-bottomright: 4px;
29
+ border-top-right-radius: 4px;
30
+ border-bottom-right-radius: 4px;
31
+ -webkit-border-top-left-radius: 10px;
32
+ -webkit-border-bottom-left-radius: 10px;
33
+ -moz-border-radius-topleft: 10px;
34
+ -moz-border-radius-bottomleft: 10px;
35
+ border-top-left-radius: 10px;
36
+ border-bottom-left-radius: 10px;
37
+ background-color: rgb(41,140,186);
38
+ background-image: -webkit-gradient(
39
+ linear,
40
+ left bottom,
41
+ left top,
42
+ color-stop(0, rgb(41,140,186)),
43
+ color-stop(1, rgb(64,176,228))
44
+ );
45
+ background-image: -webkit-linear-gradient(
46
+ center bottom,
47
+ rgb(41,140,186) 37%,
48
+ rgb(64,176,228) 69%
49
+ );
50
+ background-image: -moz-linear-gradient(
51
+ center bottom,
52
+ rgb(41,140,186) 37%,
53
+ rgb(64,176,228) 69%
54
+ );
55
+ background-image: -ms-linear-gradient(
56
+ center bottom,
57
+ rgb(41,140,186) 37%,
58
+ rgb(64,176,228) 69%
59
+ );
60
+ background-image: -o-linear-gradient(
61
+ center bottom,
62
+ rgb(41,140,186) 37%,
63
+ rgb(64,176,228) 69%
64
+ );
65
+ -webkit-box-shadow:
66
+ inset 0 2px 9px rgba(255,255,255,0.3),
67
+ inset 0 -2px 6px rgba(0,0,0,0.4);
68
+ -moz-box-shadow:
69
+ inset 0 2px 9px rgba(255,255,255,0.3),
70
+ inset 0 -2px 6px rgba(0,0,0,0.4);
71
+ position: relative;
72
+ overflow: hidden;
73
+ }
74
+
75
+
76
+ .meter_finished > span {
77
+ text-align: center;
78
+ font-weight: bold;
79
+ color: white;
80
+ font-size: 80%;
81
+ display: inline-block;
82
+ height: 100%;
83
+ -webkit-border-top-right-radius: 10px;
84
+ -webkit-border-bottom-right-radius: 10px;
85
+ -moz-border-radius-topright: 10px;
86
+ -moz-border-radius-bottomright: 10px;
87
+ border-top-right-radius: 10px;
88
+ border-bottom-right-radius: 10px;
89
+ -webkit-border-top-left-radius: 10px;
90
+ -webkit-border-bottom-left-radius: 10px;
91
+ -moz-border-radius-topleft: 10px;
92
+ -moz-border-radius-bottomleft: 10px;
93
+ border-top-left-radius: 10px;
94
+ border-bottom-left-radius: 10px;
95
+ background-color: rgb(41,140,186);
96
+ background-image: -webkit-gradient(
97
+ linear,
98
+ left bottom,
99
+ left top,
100
+ color-stop(0, rgb(41,140,186)),
101
+ color-stop(1, rgb(41,140,186))
102
+ );
103
+ background-image: -webkit-linear-gradient(
104
+ center bottom,
105
+ rgb(41,140,186) 37%,
106
+ rgb(41,140,186) 69%
107
+ );
108
+ background-image: -moz-linear-gradient(
109
+ center bottom,
110
+ rgb(41,140,186) 37%,
111
+ rgb(41,140,186) 69%
112
+ );
113
+ background-image: -ms-linear-gradient(
114
+ center bottom,
115
+ rgb(41,140,186) 37%,
116
+ rgb(41,140,186) 69%
117
+ );
118
+ background-image: -o-linear-gradient(
119
+ center bottom,
120
+ rgb(41,140,186) 37%,
121
+ rgb(41,140,186) 69%
122
+ );
123
+ -webkit-box-shadow:
124
+ inset 0 2px 9px rgba(255,255,255,0.3),
125
+ inset 0 -2px 6px rgba(0,0,0,0.4);
126
+ -moz-box-shadow:
127
+ inset 0 2px 9px rgba(255,255,255,0.3),
128
+ inset 0 -2px 6px rgba(0,0,0,0.4);
129
+ position: relative;
130
+ overflow: hidden;
131
+ }
132
+
133
+ div.kg_thumbnail_box {
134
+ border-style:solid;
135
+ border-color:#ccc;
136
+ border-width:1px;
137
+ width:425px;
138
+ text-align:center;
139
+ margin-bottom:10px;
140
+ padding:5px;
141
+ }
142
+
143
+ div.kg_thumbnail_overlay {
144
+ width: 100%;
145
+ height:100%;
146
+ background: #fff;
147
+ opacity: 0.5;
148
+ filter: alpha(opacity = 50); /* required for opacity to work in IE */
149
+ }
150
+
151
+ div.kg_thumbnail_select {
152
+ text-align:center;
153
+ display:inline-block;
154
+ }
155
+
156
+ img.kg_thumbnail {
157
+ margin:2px;
158
+ }
159
+
160
+ .kg_embedselect {
161
+ border-left:2px solid #ccc;
162
+ display:inline;
163
+ padding-left:8px;
164
+ }
165
+
166
+ div.kg_cancel_button {
167
+ display:inline-block;
168
+ vertical-align:top;
169
+ margin-top:7px;
170
+ padding-left:5px;
171
  }
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.3
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
 
@@ -48,10 +48,8 @@ function kg_add_upload_mimes ( $existing_mimes=array() ) {
48
  return $existing_mimes;
49
 
50
  }
51
-
52
  add_filter('upload_mimes', 'kg_add_upload_mimes');
53
 
54
-
55
  function url_exists($url) {
56
  $hdrs = @get_headers($url);
57
  return is_array($hdrs) ? preg_match('/^HTTP\\/\\d+\\.\\d+\\s+2\\d\\d\\s+.*$/',$hdrs[0]) : false;
@@ -113,14 +111,18 @@ function kg_check_ffmpeg_exists() {
113
  $exec_enabled = false;
114
  $ffmpeg_exists = false;
115
  $output = array();
116
-
117
- if(function_exists('exec')) { $exec_enabled = true; }
118
-
119
  $ffmpeg_path = get_option('wp_FMP_ffmpeg');
 
 
 
 
 
 
120
 
121
- if ( $exec_enabled == true && ( file_exists($ffmpeg_path.'/ffmpeg') || file_exists($ffmpeg_path.'/ffmpeg.exe') ) ) { //if FFMPEG exists
122
  update_option('wp_FMP_ffmpeg_exists', "true");
123
  $ffmpeg_exists = true;
 
124
  }
125
  else { update_option('wp_FMP_ffmpeg_exists', "notinstalled"); }
126
 
@@ -146,7 +148,7 @@ function kg_encodevideo_info($movieurl, $postID) {
146
  }
147
  else {
148
  $url_parts = parse_url($uploads['url']);
149
- if ( strpos($moviefilepath, $url_parts['host']) != "" ) { //if we're on the same server
150
  $encodevideo_info['sameserver'] = true;
151
  $filename = urldecode($moviefilepath);
152
  $parsed_url= parse_url($filename);
@@ -261,6 +263,8 @@ function video_embed_thumbnail_generator_activate() {
261
  define("wp_FMP_default_mobile_res", "480", true);
262
  define("wp_FMP_default_encodeogg", "false", true);
263
  define("wp_FMP_default_encodewebm", "true", true);
 
 
264
 
265
  add_option('wp_FMP_swfobject', wp_FMP_swfobject_default);
266
  add_option('wp_FMP_flashplayer', wp_FMP_flashplayer_default);
@@ -284,6 +288,8 @@ function video_embed_thumbnail_generator_activate() {
284
  add_option('wp_FMP_encodemobile', wp_FMP_default_encodemobile);
285
  add_option('wp_FMP_encodeogg', wp_FMP_default_encodeogg);
286
  add_option('wp_FMP_encodewebm', wp_FMP_default_encodewebm);
 
 
287
 
288
  kg_check_ffmpeg_exists();
289
 
@@ -297,8 +303,8 @@ function addSWFObject() {
297
  }
298
  }
299
 
300
-
301
  function FMP_shortcode($atts, $content = ''){
 
302
 
303
  // workaround for relative video URL (contributed by Lee Fernandes)
304
  if(substr($content, 0, 1) == '/') $content = get_bloginfo('url').$content;
@@ -320,49 +326,56 @@ function FMP_shortcode($atts, $content = ''){
320
 
321
  $div_suffix = substr(uniqid(rand(), true),0,4);
322
 
 
 
 
 
 
 
323
 
324
  $video_swf = plugins_url('', __FILE__)."/flash/StrobeMediaPlayback.swf";
325
  $minimum_flash = "10.1.0";
326
 
327
- $flashvars = "{src:'".urlencode(trim($content))."'";
 
328
 
329
  if($query_atts["controlbar"] != '') {
330
- $flashvars .= ", controlBarMode:'".$query_atts["controlbar"]."'";
331
  }
332
  if($query_atts["autohide"] != '') {
333
- $flashvars .= ", controlBarAutoHide:'".$query_atts["autohide"]."'";
334
  }
335
  if($query_atts["poster"] != '') {
336
- $flashvars .= ", poster:'".$query_atts["poster"]."'";
337
  }
338
  if($query_atts["playbutton"] != '') {
339
- $flashvars .= ", playButtonOverlay:'".$query_atts["playbutton"]."'";
340
  }
341
  if($query_atts["loop"] != '') {
342
- $flashvars .= ", loop:'".$query_atts["loop"]."'";
343
  }
344
  if($query_atts["autoplay"] != '') {
345
- $flashvars .= ", autoPlay:'".$query_atts["autoplay"]."'";
346
  }
347
  if($query_atts["streamtype"] != '') {
348
- $flashvars .= ", streamType:'".$query_atts["streamtype"]."'";
349
  }
350
  if($query_atts["scalemode"] != '') {
351
- $flashvars .= ", scaleMode:'".$query_atts["scalemode"]."'";
352
  }
353
  if($query_atts["backgroundcolor"] != '') {
354
- $flashvars .= ", backgroundColor:'".$query_atts["backgroundcolor"]."'";
355
  }
356
  if($query_atts["configuration"] != '') {
357
- $flashvars .= ", configuration:'".urlencode($query_atts["configuration"])."'";
358
  }
359
  if($query_atts["skin"] != '') {
360
- $flashvars .= ", skin:'".urlencode($query_atts["skin"])."'";
361
  }
362
 
363
  $flashvars .= "}";
364
 
365
- $params = "{allowfullscreen:'true', allowscriptaccess:'always', base:'".plugins_url("", __FILE__)."/flash/'}";
366
 
367
  if(get_option('wp_FMP_HTML5') == "true") {
368
  include_once dirname( __FILE__ ) .'/mdetect.php';
@@ -370,13 +383,10 @@ function FMP_shortcode($atts, $content = ''){
370
  $isAndroid = $uagent_obj->DetectAndroid(); //determine if we're running on an Android device
371
  $isTierIphone = $uagent_obj->DetectTierIphone(); //determine if we're running on a mobile device that plays iPhone-optimized video
372
  $moviefilebasename = pathinfo(trim($content), PATHINFO_FILENAME);
373
- //$moviefilebasename = str_replace(" ", "_", $moviefilebasename);
374
  $moviefiletype = pathinfo(trim($content), PATHINFO_EXTENSION);
375
  $flashcompatible = array("flv", "f4v", "mp4", "mov", "m4v");
376
  $h264compatible = array("mp4", "mov", "m4v");
377
-
378
- $encodevideo_info = kg_encodevideo_info(trim($content), 'singleurl');
379
-
380
  $code = "<div id=\"flashcontent".$div_suffix."\">";
381
  $code .= "<video ";
382
  if ($query_atts["loop"] == 'true') { $code .= "loop='loop' " ;}
@@ -408,8 +418,27 @@ function FMP_shortcode($atts, $content = ''){
408
  } }
409
  if ( $encodevideo_info["webm_exists"] ) { $code .= "<source src='".$encodevideo_info["webmurl"]."' type='video/webm'>\n"; }
410
  if ( $encodevideo_info["ogg_exists"] ) { $code .= "<source src='".$encodevideo_info["oggurl"]."' type='video/ogg'>\n"; }
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  $code .= "</video>\n";
412
  $code .= "</div>\n\n";
 
 
 
 
 
 
413
  } else {
414
  if ( in_array($moviefiletype, $flashcompatible) ) { $code = "<div id=\"flashcontent".$div_suffix."\">".get_option('wp_FMP_flashplayer')."</div>\n\n"; }
415
  }
@@ -451,6 +480,8 @@ function FMPOptionsPage() {
451
  define("wp_FMP_default_encodemobile", "true", true);
452
  define("wp_FMP_default_encodeogg", "false", true);
453
  define("wp_FMP_default_encodewebm", "true", true);
 
 
454
 
455
  if (isset($_POST['wp_FMP_reset'])) {
456
  update_option('wp_FMP_swfobject', wp_FMP_swfobject_default);
@@ -473,7 +504,9 @@ function FMPOptionsPage() {
473
  update_option('wp_FMP_mobile_res', wp_FMP_default_mobile_res);
474
  update_option('wp_FMP_encodemobile', wp_FMP_default_encodemobile);
475
  update_option('wp_FMP_encodeogg', wp_FMP_default_encodeogg);
476
- update_option('wp_FMP_encodewebm', wp_FMP_default_encodewebm);
 
 
477
 
478
  echo "<div class='updated'><p><strong>Video Embed & Thumbnail Generator plugin reset to default settings</strong></p></div>";
479
 
@@ -499,6 +532,8 @@ function FMPOptionsPage() {
499
  $use_encodemobile = $_POST[wp_FMP_encodemobile];
500
  $use_encodeogg = $_POST[wp_FMP_encodeogg];
501
  $use_encodewebm = $_POST[wp_FMP_encodewebm];
 
 
502
 
503
  if ($use_swfobject == 'use') {
504
  update_option(wp_FMP_swfobject, "true");
@@ -536,7 +571,6 @@ function FMPOptionsPage() {
536
  update_option(wp_FMP_playbutton, "false");
537
  }
538
 
539
-
540
  if ($use_encodemobile == 'use') {
541
  update_option(wp_FMP_encodemobile, "true");
542
  } else {
@@ -553,7 +587,19 @@ function FMPOptionsPage() {
553
  update_option(wp_FMP_encodewebm, "true");
554
  } else {
555
  update_option(wp_FMP_encodewebm, "false");
556
- }
 
 
 
 
 
 
 
 
 
 
 
 
557
 
558
  update_option('wp_FMP_mobile_res', $_POST[wp_FMP_mobile_res]);
559
  update_option('wp_FMP_width', $_POST[wp_FMP_width]);
@@ -624,6 +670,23 @@ function FMPOptionsPage() {
624
  Uncheck if you don't want HTML5 video fallback when Flash isn't installed.
625
  </td>
626
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
627
  <tr>
628
  <th scope="row" valign="top" align="left">
629
  <label>Default Mobile/HTML5 Video Encode Formats:</label>
@@ -682,7 +745,7 @@ function FMPOptionsPage() {
682
  <option value="720"<?php echo $res_720 ?>>720p</option>
683
  <option value="1080"<?php echo $res_1080 ?>>1080p</option>
684
  </select>
685
- <em>Newer mobile devices can display HD video (iPhone 4/iPad 1/some Android play 720p, iPhone 4s/iPad 2 play 1080p) but many older devices (iPhone 3Gs/older Android) can't play higher than 480p. Increase at your own risk.</em>
686
  </td>
687
  </tr>
688
  <tr>
@@ -695,6 +758,23 @@ function FMPOptionsPage() {
695
  <em>Don't include trailing slash. Example: /usr/local/bin</em>
696
  </td>
697
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
698
  <tr>
699
  <th scope="row" valign="top" align="left">
700
  <label>Flash Player not installed message:</label>
@@ -1103,7 +1183,7 @@ add_action('save_post', 'kg_addPostSave');
1103
  $form_fields["generator"]["label"] = __("Thumbnails");
1104
  $form_fields["generator"]["input"] = "html";
1105
  $form_fields["generator"]["html"] = '<div id="attachments_'. $post->ID .'_thumbnailplaceholder">'. $thumbnail_html .'</div>
1106
- <input id="attachments_'. $post->ID .'_numberofthumbs" type="text" value="'.$numberofthumbs_value.'" maxlength="1" size="4" style="width:25px;" onchange="document.getElementById(\'attachments['.$post->ID.'][thumbtime]\').value =\'\';" '.$ffmpeg_disabled_text.'/>
1107
  <input type="button" id="attachments['. $post->ID .'][thumbgenerate]" class="button-secondary" value="Generate" name="thumbgenerate" onclick="kg_generate_thumb('. $post->ID .', \'generate\');" '.$ffmpeg_disabled_text.'/>
1108
  <input type="button" id="thumbrandomize" class="button-secondary" value="Randomize" name="thumbrandomize" onclick="kg_generate_thumb('. $post->ID .', \'random\');" '.$ffmpeg_disabled_text.'/>
1109
  <input type="checkbox" id="attachments_'. $post->ID .'_firstframe" onchange="document.getElementById(\'attachments['.$post->ID.'][thumbtime]\').value =\'\';" '.$ffmpeg_disabled_text.'/>
@@ -1407,6 +1487,33 @@ function kg_embedurl_handle() {
1407
  }
1408
  add_action('media_upload_embedurl', 'kg_embedurl_handle');
1409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1410
  function kg_cleanup_generated_logfiles_handler($logfile) {
1411
  $lastmodified = "";
1412
  if ( file_exists($logfile) ) { $lastmodified = filemtime($logfile); }
@@ -1497,10 +1604,14 @@ function kg_check_encode_progress() {
1497
  }
1498
 
1499
  if ( array_key_exists(1, $time_matches) == true ) {
1500
- $current_hours = intval(substr($time_matches[1], -11, 2));
1501
- $current_minutes = intval(substr($time_matches[1], -8, 2));
1502
- $current_seconds = intval(substr($time_matches[1], -5, 2));
1503
- $current_seconds = ($current_hours * 60 * 60) + ($current_minutes * 60) + $current_seconds;
 
 
 
 
1504
  $percent_done = round(intval($current_seconds)/intval($movie_duration)*100);
1505
 
1506
  preg_match('/fps=\s+(.*?) /', $lastline, $fps_matches);
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.4
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
 
48
  return $existing_mimes;
49
 
50
  }
 
51
  add_filter('upload_mimes', 'kg_add_upload_mimes');
52
 
 
53
  function url_exists($url) {
54
  $hdrs = @get_headers($url);
55
  return is_array($hdrs) ? preg_match('/^HTTP\\/\\d+\\.\\d+\\s+2\\d\\d\\s+.*$/',$hdrs[0]) : false;
111
  $exec_enabled = false;
112
  $ffmpeg_exists = false;
113
  $output = array();
 
 
 
114
  $ffmpeg_path = get_option('wp_FMP_ffmpeg');
115
+ $uploads = wp_upload_dir();
116
+
117
+ if(function_exists('exec')) {
118
+ $exec_enabled = true;
119
+ exec ( get_option('wp_FMP_ffmpeg').'/ffmpeg -i '.plugins_url("", __FILE__).'/flash/skin/images/PlayNormal.png '.$uploads['path'].'/ffmpeg_exists_test.jpg', $output, $returnvalue );
120
+ }
121
 
122
+ if ( $exec_enabled == true && file_exists($uploads['path'].'/ffmpeg_exists_test.jpg') ) { //if FFMPEG has executed successfully
123
  update_option('wp_FMP_ffmpeg_exists', "true");
124
  $ffmpeg_exists = true;
125
+ unlink($uploads['path'].'/ffmpeg_exists_test.jpg');
126
  }
127
  else { update_option('wp_FMP_ffmpeg_exists', "notinstalled"); }
128
 
148
  }
149
  else {
150
  $url_parts = parse_url($uploads['url']);
151
+ if ( strpos($moviefilepath, $url_parts['host']) != false ) { //if we're on the same server
152
  $encodevideo_info['sameserver'] = true;
153
  $filename = urldecode($moviefilepath);
154
  $parsed_url= parse_url($filename);
263
  define("wp_FMP_default_mobile_res", "480", true);
264
  define("wp_FMP_default_encodeogg", "false", true);
265
  define("wp_FMP_default_encodewebm", "true", true);
266
+ define("wp_FMP_default_vpre", "false", true);
267
+ define("wp_FMP_default_template", "false", true);
268
 
269
  add_option('wp_FMP_swfobject', wp_FMP_swfobject_default);
270
  add_option('wp_FMP_flashplayer', wp_FMP_flashplayer_default);
288
  add_option('wp_FMP_encodemobile', wp_FMP_default_encodemobile);
289
  add_option('wp_FMP_encodeogg', wp_FMP_default_encodeogg);
290
  add_option('wp_FMP_encodewebm', wp_FMP_default_encodewebm);
291
+ add_option('wp_FMP_vpre', wp_FMP_default_vpre);
292
+ add_option('wp_FMP_template', wp_FMP_default_template);
293
 
294
  kg_check_ffmpeg_exists();
295
 
303
  }
304
  }
305
 
 
306
  function FMP_shortcode($atts, $content = ''){
307
+
308
 
309
  // workaround for relative video URL (contributed by Lee Fernandes)
310
  if(substr($content, 0, 1) == '/') $content = get_bloginfo('url').$content;
326
 
327
  $div_suffix = substr(uniqid(rand(), true),0,4);
328
 
329
+ global $wpdb;
330
+ $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$content'";
331
+ $id = $wpdb->get_var($query);
332
+
333
+ if ($id != "") { $encodevideo_info = kg_encodevideo_info(trim($content), $id); }
334
+ else { $encodevideo_info = kg_encodevideo_info(trim($content), 'singleurl'); }
335
 
336
  $video_swf = plugins_url('', __FILE__)."/flash/StrobeMediaPlayback.swf";
337
  $minimum_flash = "10.1.0";
338
 
339
+ if ( in_array($moviefiletype, $flashcompatible) ) { $flashvars = "{src:'".urlencode(trim($content))."'"; }
340
+ else { $flashvars = "{'src':'".urlencode(trim($encodevideo_info['mobileurl']))."'"; }
341
 
342
  if($query_atts["controlbar"] != '') {
343
+ $flashvars .= ", 'controlBarMode':'".$query_atts["controlbar"]."'";
344
  }
345
  if($query_atts["autohide"] != '') {
346
+ $flashvars .= ", 'controlBarAutoHide':'".$query_atts["autohide"]."'";
347
  }
348
  if($query_atts["poster"] != '') {
349
+ $flashvars .= ", 'poster':'".urlencode(trim($query_atts["poster"]))."'";
350
  }
351
  if($query_atts["playbutton"] != '') {
352
+ $flashvars .= ", 'playButtonOverlay':'".$query_atts["playbutton"]."'";
353
  }
354
  if($query_atts["loop"] != '') {
355
+ $flashvars .= ", 'loop':'".$query_atts["loop"]."'";
356
  }
357
  if($query_atts["autoplay"] != '') {
358
+ $flashvars .= ", 'autoPlay':'".$query_atts["autoplay"]."'";
359
  }
360
  if($query_atts["streamtype"] != '') {
361
+ $flashvars .= ", 'streamType':'".$query_atts["streamtype"]."'";
362
  }
363
  if($query_atts["scalemode"] != '') {
364
+ $flashvars .= ", 'scaleMode':'".$query_atts["scalemode"]."'";
365
  }
366
  if($query_atts["backgroundcolor"] != '') {
367
+ $flashvars .= ", 'backgroundColor':'".$query_atts["backgroundcolor"]."'";
368
  }
369
  if($query_atts["configuration"] != '') {
370
+ $flashvars .= ", 'configuration':'".urlencode($query_atts["configuration"])."'";
371
  }
372
  if($query_atts["skin"] != '') {
373
+ $flashvars .= ", 'skin':'".urlencode($query_atts["skin"])."'";
374
  }
375
 
376
  $flashvars .= "}";
377
 
378
+ $params = "{'allowfullscreen':'true', 'allowscriptaccess':'always', 'base':'".plugins_url("", __FILE__)."/flash/'}";
379
 
380
  if(get_option('wp_FMP_HTML5') == "true") {
381
  include_once dirname( __FILE__ ) .'/mdetect.php';
383
  $isAndroid = $uagent_obj->DetectAndroid(); //determine if we're running on an Android device
384
  $isTierIphone = $uagent_obj->DetectTierIphone(); //determine if we're running on a mobile device that plays iPhone-optimized video
385
  $moviefilebasename = pathinfo(trim($content), PATHINFO_FILENAME);
 
386
  $moviefiletype = pathinfo(trim($content), PATHINFO_EXTENSION);
387
  $flashcompatible = array("flv", "f4v", "mp4", "mov", "m4v");
388
  $h264compatible = array("mp4", "mov", "m4v");
389
+
 
 
390
  $code = "<div id=\"flashcontent".$div_suffix."\">";
391
  $code .= "<video ";
392
  if ($query_atts["loop"] == 'true') { $code .= "loop='loop' " ;}
418
  } }
419
  if ( $encodevideo_info["webm_exists"] ) { $code .= "<source src='".$encodevideo_info["webmurl"]."' type='video/webm'>\n"; }
420
  if ( $encodevideo_info["ogg_exists"] ) { $code .= "<source src='".$encodevideo_info["oggurl"]."' type='video/ogg'>\n"; }
421
+ if ( !in_array($moviefiletype, $flashcompatible) && $encodevideo_info["mobile_exists"] ) { // Flash fallback if WEBM/OGV embed
422
+ $flashvars_remove = array("{", "}", "'");
423
+ $flashvars_reformat = str_replace($flashvars_remove, "", $flashvars);
424
+ $flashvars_reformat = str_replace(":", "=", $flashvars_reformat);
425
+ $flashvars_reformat = str_replace(", ", "&", $flashvars_reformat);
426
+ $code .= '<object width="'.trim($query_atts["width"]).'" height="'.trim($query_atts["height"]).'" type="application/x-shockwave-flash" data="'.$video_swf.'">'."\n";
427
+ $code .= '<param name="movie" value="'.$video_swf.'" /></param>'."\n";
428
+ $code .= '<param name="flashvars" value="'.$flashvars_reformat.'" /></param>'."\n";
429
+ $code .= '<param name="base" value="'.plugins_url('', __FILE__).'/flash/" /></param>'."\n";
430
+ $code .= '<param name="allowFullScreen" value="true" /></param>'."\n";
431
+ $code .= '<param name="allowscriptaccess" value="always" /></param>'."\n";
432
+ $code .= '</object>';
433
+ }
434
  $code .= "</video>\n";
435
  $code .= "</div>\n\n";
436
+
437
+ /* if ($id !="") {
438
+ $iframeurl = site_url('/')."?attachment_id=".$id;
439
+ $iframecode = '<iframe src="'.$iframeurl.'" frameborder="0" scrolling="no" width="'.$query_atts['width'].'" height="'.$query_atts["height"].'"></iframe>';
440
+ $code .= "<div style='background-color:#e8e8e8; width:".$query_atts['width']."px; height:25px; margin-top:-25px; padding:5px; font-size:8pt;'>Embed code: <input style='height:10px; background-color:#f4f4f4;' type='text' value='".$iframecode."' width='10' onClick='this.select();'></div>\n";
441
+ } */
442
  } else {
443
  if ( in_array($moviefiletype, $flashcompatible) ) { $code = "<div id=\"flashcontent".$div_suffix."\">".get_option('wp_FMP_flashplayer')."</div>\n\n"; }
444
  }
480
  define("wp_FMP_default_encodemobile", "true", true);
481
  define("wp_FMP_default_encodeogg", "false", true);
482
  define("wp_FMP_default_encodewebm", "true", true);
483
+ define("wp_FMP_default_vpre", "false", true);
484
+ define("wp_FMP_default_template", "false", true);
485
 
486
  if (isset($_POST['wp_FMP_reset'])) {
487
  update_option('wp_FMP_swfobject', wp_FMP_swfobject_default);
504
  update_option('wp_FMP_mobile_res', wp_FMP_default_mobile_res);
505
  update_option('wp_FMP_encodemobile', wp_FMP_default_encodemobile);
506
  update_option('wp_FMP_encodeogg', wp_FMP_default_encodeogg);
507
+ update_option('wp_FMP_encodewebm', wp_FMP_default_encodewebm);
508
+ update_option('wp_FMP_vpre', wp_FMP_default_vpre);
509
+ update_option('wp_FMP_template', wp_FMP_default_template);
510
 
511
  echo "<div class='updated'><p><strong>Video Embed & Thumbnail Generator plugin reset to default settings</strong></p></div>";
512
 
532
  $use_encodemobile = $_POST[wp_FMP_encodemobile];
533
  $use_encodeogg = $_POST[wp_FMP_encodeogg];
534
  $use_encodewebm = $_POST[wp_FMP_encodewebm];
535
+ $use_vpre = $_POST[wp_FMP_vpre];
536
+ $use_template = $_POST[wp_FMP_template];
537
 
538
  if ($use_swfobject == 'use') {
539
  update_option(wp_FMP_swfobject, "true");
571
  update_option(wp_FMP_playbutton, "false");
572
  }
573
 
 
574
  if ($use_encodemobile == 'use') {
575
  update_option(wp_FMP_encodemobile, "true");
576
  } else {
587
  update_option(wp_FMP_encodewebm, "true");
588
  } else {
589
  update_option(wp_FMP_encodewebm, "false");
590
+ }
591
+
592
+ if ($use_vpre == 'use') {
593
+ update_option(wp_FMP_vpre, "true");
594
+ } else {
595
+ update_option(wp_FMP_vpre, "false");
596
+ }
597
+
598
+ if ($use_template == 'use') {
599
+ update_option(wp_FMP_template, "true");
600
+ } else {
601
+ update_option(wp_FMP_template, "false");
602
+ }
603
 
604
  update_option('wp_FMP_mobile_res', $_POST[wp_FMP_mobile_res]);
605
  update_option('wp_FMP_width', $_POST[wp_FMP_width]);
670
  Uncheck if you don't want HTML5 video fallback when Flash isn't installed.
671
  </td>
672
  </tr>
673
+ <tr>
674
+ <th scope="row" valign="top" align="left">
675
+ <label>Attachment Template Override:</label>
676
+ </th>
677
+ <td width="10"></td>
678
+ <td>
679
+ <?php
680
+ echo "<input type='checkbox' name='wp_FMP_template' id='wp_FMP_template' value='use' ";
681
+ if(get_option('wp_FMP_template') == "true") {
682
+ echo "checked";
683
+ }
684
+ echo " />\n";
685
+ ?>
686
+ Check to enable experimental minimalist video attachment template.<br />
687
+ <em><small>Allows easy iframe embedding on other sites. Will override any existing video attachment template page.</small></em>
688
+ </td>
689
+ </tr>
690
  <tr>
691
  <th scope="row" valign="top" align="left">
692
  <label>Default Mobile/HTML5 Video Encode Formats:</label>
745
  <option value="720"<?php echo $res_720 ?>>720p</option>
746
  <option value="1080"<?php echo $res_1080 ?>>1080p</option>
747
  </select>
748
+ <em>Newer mobile devices can display HD video (iPhone 4/iPad 1/some Android play 720p, iPhone 4s/iPad 2+ play 1080p) but many older devices (iPhone 3Gs/older Android) can't play higher than 480p. Increase at your own risk.</em>
749
  </td>
750
  </tr>
751
  <tr>
758
  <em>Don't include trailing slash. Example: /usr/local/bin</em>
759
  </td>
760
  </tr>
761
+ <tr>
762
+ <th scope="row" valign="top" align="left">
763
+ <label>FFMPEG Options:</label>
764
+ </th>
765
+ <td width="10"></td>
766
+ <td>
767
+ <?php
768
+ echo "<input type='checkbox' name='wp_FMP_vpre' id='wp_FMP_vpre' value='use' ";
769
+ if(get_option('wp_FMP_vpre') == "true") {
770
+ echo "checked";
771
+ }
772
+ echo " />\n";
773
+ ?>
774
+ Enable FFMPEG 'vpre' flags.<br />
775
+ <em><small>Check this if your installed version of FFMPEG is old enough that libx264 requires vpre flags to operate (Dreamhost users must turn this on).<br />This should help if you can encode WEBM or OGV files but H264/Mobile files fail. It will cause newer versions of FFMPEG to fail and probably won't work on Windows servers.</em></small>
776
+ </td>
777
+ </tr>
778
  <tr>
779
  <th scope="row" valign="top" align="left">
780
  <label>Flash Player not installed message:</label>
1183
  $form_fields["generator"]["label"] = __("Thumbnails");
1184
  $form_fields["generator"]["input"] = "html";
1185
  $form_fields["generator"]["html"] = '<div id="attachments_'. $post->ID .'_thumbnailplaceholder">'. $thumbnail_html .'</div>
1186
+ <input id="attachments_'. $post->ID .'_numberofthumbs" type="text" value="'.$numberofthumbs_value.'" maxlength="2" size="4" style="width:25px;" onchange="document.getElementById(\'attachments['.$post->ID.'][thumbtime]\').value =\'\';" '.$ffmpeg_disabled_text.'/>
1187
  <input type="button" id="attachments['. $post->ID .'][thumbgenerate]" class="button-secondary" value="Generate" name="thumbgenerate" onclick="kg_generate_thumb('. $post->ID .', \'generate\');" '.$ffmpeg_disabled_text.'/>
1188
  <input type="button" id="thumbrandomize" class="button-secondary" value="Randomize" name="thumbrandomize" onclick="kg_generate_thumb('. $post->ID .', \'random\');" '.$ffmpeg_disabled_text.'/>
1189
  <input type="checkbox" id="attachments_'. $post->ID .'_firstframe" onchange="document.getElementById(\'attachments['.$post->ID.'][thumbtime]\').value =\'\';" '.$ffmpeg_disabled_text.'/>
1487
  }
1488
  add_action('media_upload_embedurl', 'kg_embedurl_handle');
1489
 
1490
+
1491
+ function kg_video_attachment_template() {
1492
+
1493
+ global $post;
1494
+ $embed_enabled = get_post_meta($post->ID, "_kgflashmediaplayer-embed", true);
1495
+ $poster = get_post_meta($post->ID, "_kgflashmediaplayer-poster", true);
1496
+ $width = get_post_meta($post->ID, "_kgflashmediaplayer-width", true);
1497
+ $height = get_post_meta($post->ID, "_kgflashmediaplayer-height", true);
1498
+ $url = wp_get_attachment_url($post->ID);
1499
+
1500
+ if ($embed_enabled == "checked" ) {
1501
+ $shortcode = '[FMP';
1502
+ if ($poster !="" ) { $shortcode .= ' poster="'.$poster.'"';}
1503
+ if ($width !="" ) { $shortcode .= ' width="'.$width.'"';}
1504
+ if ($height !="" ) { $shortcode .= ' height="'.$height.'"';}
1505
+ $shortcode .= ']'.$url.'[/FMP]';
1506
+ echo "<html>\n<head>";
1507
+ echo "\n<script src=\"".plugins_url("", __FILE__)."/flash/swfobject.js\" type=\"text/javascript\"></script>\n";
1508
+ echo "</head>\n<body>";
1509
+ echo do_shortcode( $shortcode );
1510
+ echo '</body></html>';
1511
+ exit;
1512
+ }
1513
+ }
1514
+ if ( get_option('wp_FMP_template') == 'true' ) { add_action('template_redirect', 'kg_video_attachment_template'); }
1515
+
1516
+
1517
  function kg_cleanup_generated_logfiles_handler($logfile) {
1518
  $lastmodified = "";
1519
  if ( file_exists($logfile) ) { $lastmodified = filemtime($logfile); }
1604
  }
1605
 
1606
  if ( array_key_exists(1, $time_matches) == true ) {
1607
+ if ( strpos($time_matches[1], ':') !== false ) {
1608
+ $current_hours = intval(substr($time_matches[1], -11, 2));
1609
+ $current_minutes = intval(substr($time_matches[1], -8, 2));
1610
+ $current_seconds = intval(substr($time_matches[1], -5, 2));
1611
+ $current_seconds = ($current_hours * 60 * 60) + ($current_minutes * 60) + $current_seconds;
1612
+ }
1613
+ else { $current_seconds = $time_matches[1]; }
1614
+
1615
  $percent_done = round(intval($current_seconds)/intval($movie_duration)*100);
1616
 
1617
  preg_match('/fps=\s+(.*?) /', $lastline, $fps_matches);