Version Description
- October 12, 2013 =
- Fixed bug that ignored "Enlarge lower resolution videos to max width" plugin setting after thumbnails were generated.
- Fixed bug that caused in-browser thumbnail generation to fail after switching between several attachments in Chrome.
- Fixed bug that prevented fallback to FFMPEG/LIBAV when the video format was not compatible with the browser.
- Fixed bug that lost disabled plugin settings if the "Save Changes" button was pressed.
- Fixed bug that fixed moov atom incorrectly when using qt-faststart.
- Added verification of the "Path to applications folder on server" setting to strip extra slashes and unnecessary subfolders.
- Added "Fixing moov atom for streaming" section to FFMPEG test output.
- Added legacy FFMPEG libx264 flags manually so we don't have to rely on finding vpre files.
- Now multiplying H.264 level flags by 10 for better compatibility.
- Removed unnecessary & inconsistent check for existing thumbnail files on attachment pages.
Download this release
Release Info
Developer | kylegilman |
Plugin | Video Embed & Thumbnail Generator |
Version | 4.2.4 |
Comparing to | |
See all releases |
Code changes from version 4.2.3 to 4.2.4
- css/video-embed-thumbnail-generator_admin.css +18 -0
- js/kgvid_video_plugin_admin.js +57 -24
- readme.txt +16 -2
- video-embed-thumbnail-generator.php +143 -115
css/video-embed-thumbnail-generator_admin.css
CHANGED
@@ -471,3 +471,21 @@ td.media-icon img {
|
|
471 |
height: 100%;
|
472 |
padding: 0;
|
473 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
471 |
height: 100%;
|
472 |
padding: 0;
|
473 |
}
|
474 |
+
|
475 |
+
.kgvid-blue-box {
|
476 |
+
width: 454px;
|
477 |
+
margin: 30px 0;
|
478 |
+
padding: 20px 20px 0 20px;
|
479 |
+
background-color: #F0F8FF;
|
480 |
+
border: 2px solid #ddd;
|
481 |
+
}
|
482 |
+
|
483 |
+
.kgvid-blue-box > * {
|
484 |
+
margin-left: auto;
|
485 |
+
margin-right: auto;
|
486 |
+
display: block;
|
487 |
+
text-align: center;
|
488 |
+
font-size: 13pt;
|
489 |
+
line-height: 17pt;
|
490 |
+
margin-bottom: 10px;
|
491 |
+
}
|
js/kgvid_video_plugin_admin.js
CHANGED
@@ -57,6 +57,27 @@ function kgvid_convert_from_timecode(timecode) {
|
|
57 |
|
58 |
}
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
function kgvid_thumb_video_loaded(postID) { //sets up mini custom player for making thumbnails
|
61 |
|
62 |
jQuery('#attachments-'+postID+'-thumbgenerate').prop('disabled', false).attr('title', '');
|
@@ -67,41 +88,40 @@ function kgvid_thumb_video_loaded(postID) { //sets up mini custom player for mak
|
|
67 |
|
68 |
var video = document.getElementById('thumb-video-'+postID);
|
69 |
|
70 |
-
if ( video != null ) {
|
71 |
|
72 |
if ( typeof wp !== 'undefined' ) {
|
73 |
ed_id = wp.media.editor.id();
|
74 |
var ed_media = wp.media.editor.get( ed_id ); // Then we try to first get the editor
|
75 |
ed_media = 'undefined' != typeof( ed_media ) ? ed_media : wp.media.editor.add( ed_id ); // If it hasn't been created yet, we create it
|
76 |
|
77 |
-
var kgvid_break_video_on_close = function() {
|
78 |
-
|
79 |
-
if ( jQuery('#show-thumb-video-'+postID+' :nth-child(2)').html() == "Hide video..." ) {
|
80 |
-
kgvid_reveal_thumb_video(postID); //hide the video if it's open
|
81 |
-
}
|
82 |
-
video.preload = "none";
|
83 |
-
video.src = "";
|
84 |
-
video.load();
|
85 |
-
};
|
86 |
-
|
87 |
if ( ed_media ) {
|
88 |
-
ed_media.on('escape',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
90 |
}
|
91 |
|
92 |
video.removeAttribute("controls");
|
93 |
video.muted=true;
|
|
|
94 |
var playButton = jQuery(".kgvid-play-pause");
|
95 |
var seekBar = jQuery(".kgvid-seek-bar");
|
96 |
var playProgress = jQuery(".kgvid-play-progress");
|
97 |
var seekHandle = jQuery(".kgvid-seek-handle");
|
98 |
|
99 |
-
playButton.on("click", function() {
|
100 |
if (video.paused == true) {
|
101 |
// Play the video
|
102 |
video.play();
|
103 |
-
|
104 |
-
|
105 |
// Pause the video
|
106 |
video.pause();
|
107 |
}
|
@@ -159,6 +179,9 @@ function kgvid_thumb_video_loaded(postID) { //sets up mini custom player for mak
|
|
159 |
seekHandle.css('left', percentage+'%');
|
160 |
video.currentTime = maxduration * percentage / 100;
|
161 |
};
|
|
|
|
|
|
|
162 |
}
|
163 |
}
|
164 |
|
@@ -168,7 +191,7 @@ function kgvid_reveal_thumb_video(postID) {
|
|
168 |
video = document.getElementById('thumb-video-'+postID);
|
169 |
|
170 |
if ( text.html() == "Choose from video..." ) { //video is being revealed
|
171 |
-
|
172 |
jQuery(video).removeAttr('src');
|
173 |
jQuery(video).attr("preload", "metadata");
|
174 |
video.load();
|
@@ -189,6 +212,7 @@ function kgvid_reveal_thumb_video(postID) {
|
|
189 |
|
190 |
video.pause();
|
191 |
jQuery('#thumb-video-'+postID).off('timeupdate.kgvid');
|
|
|
192 |
text.html('Choose from video...');
|
193 |
|
194 |
}
|
@@ -258,20 +282,21 @@ function kgvid_generate_thumb(postID, buttonPushed) {
|
|
258 |
|
259 |
kgvid_aspect = data.movie_height/data.movie_width;
|
260 |
document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-aspect]')[0].value = kgvid_aspect;
|
261 |
-
|
|
|
262 |
else { document.getElementById(widthID).value = document.getElementsByName(maxwidthID)[0].value; }
|
263 |
-
|
264 |
-
|
265 |
-
//jQuery.post( ajaxurl , { action:"kgvid_schedule_cleanup_generated_files", security:kgflashmediaplayersecurity, thumbs:"true" } );
|
266 |
kgvid_redraw_encode_checkboxes(attachmentURL, postID, page);
|
267 |
|
268 |
}, "json");
|
269 |
|
270 |
}// end kgvid_do_post function
|
271 |
|
272 |
-
if ( jQuery('#thumb-video-'+postID).data('allowed') == "on" ) {
|
273 |
|
274 |
video = document.getElementById('thumb-video-'+postID);
|
|
|
275 |
|
276 |
if ( video.preload == "none" ) {
|
277 |
jQuery(video).removeAttr('src');
|
@@ -319,6 +344,7 @@ function kgvid_generate_thumb(postID, buttonPushed) {
|
|
319 |
jQuery(cancelthumbdivID).animate({opacity: 0, height: 'toggle'}, 500);
|
320 |
jQuery(thumbnailboxID).prepend('<div id="saveallthumbs-'+postID+'-div"><input style="display:none;" type="button" id="attachments-'+postID+'-saveallthumbs" class="button-secondary kgvid-centered-block" value="Save All Thumbnails" name="attachments-'+postID+'-saveallthumbs" onclick="kgvid_saveall_thumbs(\''+postID+'\');"></div>');
|
321 |
jQuery('#attachments-'+postID+'-saveallthumbs').animate({opacity: 'toggle', height: 'toggle'}, 500);
|
|
|
322 |
}
|
323 |
}
|
324 |
|
@@ -355,6 +381,13 @@ function kgvid_generate_thumb(postID, buttonPushed) {
|
|
355 |
}
|
356 |
}
|
357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
function kgvid_save_canvas_thumb(postID, time_id, total, index) {
|
359 |
|
360 |
var kgflashmediaplayersecurity = document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-security]')[0].value;
|
@@ -805,7 +838,7 @@ function kgvid_save_plugin_settings(input_obj) {
|
|
805 |
jQuery( '.kgvid_setting_nearvid' ).width( jQuery('#width').val() );
|
806 |
}
|
807 |
if ( save_queue[0].id == "app_path" || save_queue[0].id == "video_app" ) {
|
808 |
-
jQuery('#app_path').data('ffmpeg_exists', data.ffmpeg_exists)
|
809 |
kgvid_hide_plugin_settings();
|
810 |
}
|
811 |
if ( jQuery(input_obj).hasClass('affects_player') == true ) {
|
@@ -871,7 +904,7 @@ function kgvid_switch_settings_tab(tab) {
|
|
871 |
jQuery("h3:contains(Plugin Settings)").show();
|
872 |
jQuery("table:contains(Default number of thumbnails to generate)").show();
|
873 |
jQuery("h3:contains(Video Encoding Settings)").hide();
|
874 |
-
jQuery("table:contains(Path to applications on server)").hide();
|
875 |
}
|
876 |
|
877 |
if ( tab == "encoding" ) {
|
@@ -887,7 +920,7 @@ function kgvid_switch_settings_tab(tab) {
|
|
887 |
jQuery("table:contains(XML configuration file)").hide();
|
888 |
jQuery("h3:contains(The following options will only affect Flash playback)").hide();
|
889 |
jQuery("h3:contains(Video Encoding Settings)").show();
|
890 |
-
jQuery("table:contains(Path to applications on server)").show();
|
891 |
|
892 |
if ( jQuery('#app_path').data('ffmpeg_exists') == "on" && jQuery('#ffmpeg_output').html() == "" ) {
|
893 |
jQuery('#ffmpeg_output').html('Running test...')
|
57 |
|
58 |
}
|
59 |
|
60 |
+
function kgvid_break_video_on_close(postID) {
|
61 |
+
|
62 |
+
var video = document.getElementById('thumb-video-'+postID);
|
63 |
+
|
64 |
+
if ( video != null ) {
|
65 |
+
|
66 |
+
var playButton = jQuery(".kgvid-play-pause");
|
67 |
+
|
68 |
+
/* if ( jQuery('#show-thumb-video-'+postID+' :nth-child(2)').html() == "Hide video..." ) {
|
69 |
+
kgvid_reveal_thumb_video(postID); //hide the video if it's open
|
70 |
+
} */
|
71 |
+
playButton.off("click.kgvid");
|
72 |
+
video.preload = "none";
|
73 |
+
video.src = "";
|
74 |
+
video.load();
|
75 |
+
jQuery(video).data('setup', false);
|
76 |
+
jQuery(video).data('busy', false);
|
77 |
+
}
|
78 |
+
|
79 |
+
};
|
80 |
+
|
81 |
function kgvid_thumb_video_loaded(postID) { //sets up mini custom player for making thumbnails
|
82 |
|
83 |
jQuery('#attachments-'+postID+'-thumbgenerate').prop('disabled', false).attr('title', '');
|
88 |
|
89 |
var video = document.getElementById('thumb-video-'+postID);
|
90 |
|
91 |
+
if ( video != null && jQuery(video).data('setup') != true ) {
|
92 |
|
93 |
if ( typeof wp !== 'undefined' ) {
|
94 |
ed_id = wp.media.editor.id();
|
95 |
var ed_media = wp.media.editor.get( ed_id ); // Then we try to first get the editor
|
96 |
ed_media = 'undefined' != typeof( ed_media ) ? ed_media : wp.media.editor.add( ed_id ); // If it hasn't been created yet, we create it
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
if ( ed_media ) {
|
99 |
+
ed_media.on( 'escape',
|
100 |
+
function(postID) {
|
101 |
+
return function() {
|
102 |
+
if ( jQuery('#show-thumb-video-'+postID+' :nth-child(2)').html() == "Hide video..." ) {
|
103 |
+
kgvid_reveal_thumb_video(postID);
|
104 |
+
}
|
105 |
+
//kgvid_break_video_on_close(postID);
|
106 |
+
}
|
107 |
+
}(postID) );
|
108 |
}
|
109 |
}
|
110 |
|
111 |
video.removeAttribute("controls");
|
112 |
video.muted=true;
|
113 |
+
|
114 |
var playButton = jQuery(".kgvid-play-pause");
|
115 |
var seekBar = jQuery(".kgvid-seek-bar");
|
116 |
var playProgress = jQuery(".kgvid-play-progress");
|
117 |
var seekHandle = jQuery(".kgvid-seek-handle");
|
118 |
|
119 |
+
playButton.on("click.kgvid", function() {
|
120 |
if (video.paused == true) {
|
121 |
// Play the video
|
122 |
video.play();
|
123 |
+
}
|
124 |
+
else {
|
125 |
// Pause the video
|
126 |
video.pause();
|
127 |
}
|
179 |
seekHandle.css('left', percentage+'%');
|
180 |
video.currentTime = maxduration * percentage / 100;
|
181 |
};
|
182 |
+
|
183 |
+
jQuery(video).data('setup', true);
|
184 |
+
if ( jQuery(video).data('busy') != true ) { kgvid_break_video_on_close(postID); }
|
185 |
}
|
186 |
}
|
187 |
|
191 |
video = document.getElementById('thumb-video-'+postID);
|
192 |
|
193 |
if ( text.html() == "Choose from video..." ) { //video is being revealed
|
194 |
+
jQuery(video).data('busy', true);
|
195 |
jQuery(video).removeAttr('src');
|
196 |
jQuery(video).attr("preload", "metadata");
|
197 |
video.load();
|
212 |
|
213 |
video.pause();
|
214 |
jQuery('#thumb-video-'+postID).off('timeupdate.kgvid');
|
215 |
+
kgvid_break_video_on_close(postID);
|
216 |
text.html('Choose from video...');
|
217 |
|
218 |
}
|
282 |
|
283 |
kgvid_aspect = data.movie_height/data.movie_width;
|
284 |
document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-aspect]')[0].value = kgvid_aspect;
|
285 |
+
|
286 |
+
if (parseInt(data.movie_width) < parseInt(document.getElementsByName(maxwidthID)[0].value) && jQuery('#attachments-'+postID+'-kgflashmediaplayer-width').data('minimum') != 'on' ) { document.getElementById(widthID).value = data.movie_width; }
|
287 |
else { document.getElementById(widthID).value = document.getElementsByName(maxwidthID)[0].value; }
|
288 |
+
document.getElementById(heightID).value = Math.round(kgvid_aspect*parseInt(document.getElementById(widthID).value));
|
289 |
+
|
|
|
290 |
kgvid_redraw_encode_checkboxes(attachmentURL, postID, page);
|
291 |
|
292 |
}, "json");
|
293 |
|
294 |
}// end kgvid_do_post function
|
295 |
|
296 |
+
if ( jQuery('#thumb-video-'+postID).data('allowed') == "on" && jQuery('#thumb-video-'+postID).data('setup') != undefined ) {
|
297 |
|
298 |
video = document.getElementById('thumb-video-'+postID);
|
299 |
+
jQuery(video).data('busy', true);
|
300 |
|
301 |
if ( video.preload == "none" ) {
|
302 |
jQuery(video).removeAttr('src');
|
344 |
jQuery(cancelthumbdivID).animate({opacity: 0, height: 'toggle'}, 500);
|
345 |
jQuery(thumbnailboxID).prepend('<div id="saveallthumbs-'+postID+'-div"><input style="display:none;" type="button" id="attachments-'+postID+'-saveallthumbs" class="button-secondary kgvid-centered-block" value="Save All Thumbnails" name="attachments-'+postID+'-saveallthumbs" onclick="kgvid_saveall_thumbs(\''+postID+'\');"></div>');
|
346 |
jQuery('#attachments-'+postID+'-saveallthumbs').animate({opacity: 'toggle', height: 'toggle'}, 500);
|
347 |
+
kgvid_break_video_on_close(postID);
|
348 |
}
|
349 |
}
|
350 |
|
381 |
}
|
382 |
}
|
383 |
|
384 |
+
function kgvid_select_thumbnail(thumb_url, post_id, movieoffset) {
|
385 |
+
jQuery('[name="attachments['+post_id+'][kgflashmediaplayer-poster]"]').val(thumb_url); //get this by name because it's the same before WP v3.5
|
386 |
+
var time_display = kgvid_convert_to_timecode(movieoffset);
|
387 |
+
document.getElementById('attachments-'+post_id+'-thumbtime').value = time_display;
|
388 |
+
document.getElementById('attachments-'+post_id+'-numberofthumbs').value = '1';
|
389 |
+
}
|
390 |
+
|
391 |
function kgvid_save_canvas_thumb(postID, time_id, total, index) {
|
392 |
|
393 |
var kgflashmediaplayersecurity = document.getElementsByName('attachments['+postID+'][kgflashmediaplayer-security]')[0].value;
|
838 |
jQuery( '.kgvid_setting_nearvid' ).width( jQuery('#width').val() );
|
839 |
}
|
840 |
if ( save_queue[0].id == "app_path" || save_queue[0].id == "video_app" ) {
|
841 |
+
jQuery('#app_path').val(data.app_path).data('ffmpeg_exists', data.ffmpeg_exists);
|
842 |
kgvid_hide_plugin_settings();
|
843 |
}
|
844 |
if ( jQuery(input_obj).hasClass('affects_player') == true ) {
|
904 |
jQuery("h3:contains(Plugin Settings)").show();
|
905 |
jQuery("table:contains(Default number of thumbnails to generate)").show();
|
906 |
jQuery("h3:contains(Video Encoding Settings)").hide();
|
907 |
+
jQuery("table:contains(Path to applications folder on server)").hide();
|
908 |
}
|
909 |
|
910 |
if ( tab == "encoding" ) {
|
920 |
jQuery("table:contains(XML configuration file)").hide();
|
921 |
jQuery("h3:contains(The following options will only affect Flash playback)").hide();
|
922 |
jQuery("h3:contains(Video Encoding Settings)").show();
|
923 |
+
jQuery("table:contains(Path to applications folder on server)").show();
|
924 |
|
925 |
if ( jQuery('#app_path').data('ffmpeg_exists') == "on" && jQuery('#ffmpeg_output').html() == "" ) {
|
926 |
jQuery('#ffmpeg_output').html('Running test...')
|
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.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -132,6 +132,8 @@ WordPress already has <a href="http://codex.wordpress.org/Embeds">a built-in sys
|
|
132 |
|
133 |
If you're like most users and don't have FFMPEG installed on your server, the plugin relies on your browser's built-in ability to play videos. Google Chrome is best when making thumbnails because it supports the most formats. Wikipedia has <a href="http://en.wikipedia.org/wiki/HTML5_video#Browser_support">a great chart that explains which browsers work with which video formats</a>.
|
134 |
|
|
|
|
|
135 |
= I'm getting an error message FFMPEG not found at /usr/local/bin/. You can embed existing videos, but video thumbnail generation and Mobile/HTML5 video encoding is not possible without FFMPEG. =
|
136 |
|
137 |
First off, don't panic.
|
@@ -153,7 +155,19 @@ Enter the username & password in the plugin settings "FFMPEG Settings" tab, or u
|
|
153 |
|
154 |
== Changelog ==
|
155 |
|
156 |
-
= 4.2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
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.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
132 |
|
133 |
If you're like most users and don't have FFMPEG installed on your server, the plugin relies on your browser's built-in ability to play videos. Google Chrome is best when making thumbnails because it supports the most formats. Wikipedia has <a href="http://en.wikipedia.org/wiki/HTML5_video#Browser_support">a great chart that explains which browsers work with which video formats</a>.
|
134 |
|
135 |
+
If you were able to make thumbnails using FFMPEG before updating to version 4.2, try disabling in-browser thumbnail creation in the FFMPEG Settings tab of the plugin settings.
|
136 |
+
|
137 |
= I'm getting an error message FFMPEG not found at /usr/local/bin/. You can embed existing videos, but video thumbnail generation and Mobile/HTML5 video encoding is not possible without FFMPEG. =
|
138 |
|
139 |
First off, don't panic.
|
155 |
|
156 |
== Changelog ==
|
157 |
|
158 |
+
= 4.2.4 - October 12, 2013 =
|
159 |
+
* Fixed bug that ignored "Enlarge lower resolution videos to max width" plugin setting after thumbnails were generated.
|
160 |
+
* Fixed bug that caused in-browser thumbnail generation to fail after switching between several attachments in Chrome.
|
161 |
+
* Fixed bug that prevented fallback to FFMPEG/LIBAV when the video format was not compatible with the browser.
|
162 |
+
* Fixed bug that lost disabled plugin settings if the "Save Changes" button was pressed.
|
163 |
+
* Fixed bug that fixed moov atom incorrectly when using qt-faststart.
|
164 |
+
* Added verification of the "Path to applications folder on server" setting to strip extra slashes and unnecessary subfolders.
|
165 |
+
* Added "Fixing moov atom for streaming" section to FFMPEG test output.
|
166 |
+
* Added legacy FFMPEG libx264 flags manually so we don't have to rely on finding vpre files.
|
167 |
+
* Now multiplying H.264 level flags by 10 for better compatibility.
|
168 |
+
* Removed unnecessary & inconsistent check for existing thumbnail files on attachment pages.
|
169 |
+
|
170 |
+
= 4.2.3 - October 9, 2013 =
|
171 |
* Fixed bug that caused encoding on Windows servers to hang and not show progress.
|
172 |
* Fixed bug that only disabled right-clicking when using the Video.js player.
|
173 |
* Fixed bug that prevented encoding videos from the External URL tab.
|
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.
|
7 |
Author: Kyle Gilman
|
8 |
Author URI: http://www.kylegilman.net/
|
9 |
|
@@ -47,7 +47,7 @@ function kgvid_default_options_fn() {
|
|
47 |
$upload_capable = kgvid_upload_capable();
|
48 |
|
49 |
$options = array(
|
50 |
-
"version"=>4.
|
51 |
"embed_method"=>"Video.js",
|
52 |
"template"=>false,
|
53 |
"template_gentle"=>"on",
|
@@ -347,19 +347,33 @@ function kgvid_check_ffmpeg_exists($options, $save) {
|
|
347 |
if(function_exists('exec')) {
|
348 |
if (function_exists('escapeshellcmd')) {
|
349 |
$exec_enabled = true;
|
350 |
-
$
|
|
|
351 |
exec ( $cmd, $output, $returnvalue );
|
|
|
352 |
}
|
353 |
else { $function = "ESCAPESHELLCMD"; }
|
354 |
}
|
355 |
else { $function = "EXEC"; }
|
356 |
|
357 |
-
if ( $exec_enabled == true
|
358 |
-
|
359 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
}
|
361 |
|
362 |
-
if ( $save
|
363 |
if ( $ffmpeg_exists == true ) { $options['ffmpeg_exists'] = "on"; }
|
364 |
else {
|
365 |
$options['ffmpeg_exists'] = "notinstalled";
|
@@ -369,7 +383,13 @@ function kgvid_check_ffmpeg_exists($options, $save) {
|
|
369 |
}
|
370 |
|
371 |
$output_output = implode("/n", $output);
|
372 |
-
$arr = array (
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
return $arr;
|
374 |
}
|
375 |
|
@@ -625,7 +645,7 @@ function kgvid_generate_encode_string($input, $output, $libraries, $format, $wid
|
|
625 |
if ( $aaclib == "aac" ) { $aaclib = "aac -strict experimental"; } //the built-in aac encoder is considered experimental
|
626 |
|
627 |
$vpre_flags = "";
|
628 |
-
if ( $options['ffmpeg_vpre'] == 'on' ) { $vpre_flags = ' -
|
629 |
|
630 |
$movflags = "";
|
631 |
if ( $options['moov'] == "movflag" ) {
|
@@ -642,8 +662,7 @@ function kgvid_generate_encode_string($input, $output, $libraries, $format, $wid
|
|
642 |
|
643 |
$level_text = "";
|
644 |
if ( $options['h264_level'] != "none" ) {
|
645 |
-
|
646 |
-
$level_text = " -".$level_flag." ".$options['h264_level'];
|
647 |
}
|
648 |
|
649 |
$ffmpeg_options = "-acodec ".$aaclib." -".$audio_bitrate_flag." ".$options['audio_bitrate']."k -s ".$width."x".$height." -vcodec libx264".$vpre_flags.$movflags.$profile_text.$level_text;
|
@@ -1053,18 +1072,18 @@ function KGVID_shortcode($atts, $content = ''){
|
|
1053 |
}
|
1054 |
else { $aligncode = ""; }
|
1055 |
|
1056 |
-
$code .= '<div id="kgvid_'.$div_suffix.'_wrapper" class="kgvid_wrapper"'.$aligncode.'>';
|
1057 |
-
$code .= '<div id="video_'.$div_suffix.'_div" class="kgvid_videodiv" itemscope itemtype="http://schema.org/VideoObject">';
|
1058 |
-
if ( $query_atts["poster"] != '' ) { $code .= '<meta itemprop="thumbnailURL" content="'.$query_atts["poster"].'" />'; }
|
1059 |
if ( !empty($id) ) { $schema_embedURL = site_url('/')."?attachment_id=".$id."&kgvid_video_embed[enable]=true"; }
|
1060 |
else { $schema_embedURL = $content; }
|
1061 |
-
$code .= '<meta itemprop="embedURL" content="'.$schema_embedURL.'" />';
|
1062 |
|
1063 |
-
if ( !empty($query_atts['title']) ) { $code .= '<meta itemprop="name" content="'.$query_atts['title'].'" />'; }
|
1064 |
if ( !empty($query_atts['description']) ) { $description = $query_atts['description']; }
|
1065 |
elseif ( !empty($query_atts['caption']) ) { $description = $query_atts['caption']; }
|
1066 |
else { $description = ""; }
|
1067 |
-
if ( !empty($description) ) { $code .= '<meta itemprop="description" content="'.esc_attr($description).'" />'; }
|
1068 |
|
1069 |
if ( $options['embed_method'] == "WordPress Default" ) {
|
1070 |
$wp_shortcode = "[video ";
|
@@ -1104,7 +1123,7 @@ function KGVID_shortcode($atts, $content = ''){
|
|
1104 |
|
1105 |
foreach ($video_formats as $name => $type) {
|
1106 |
if ( $name != "original" && $encodevideo_info[$name."url"] == $content ) { unset($sources['original']); }
|
1107 |
-
if ( $encodevideo_info[$name."_exists"] ) { $sources[$name] = '<source src="'.$encodevideo_info[$name."url"].'" type="video/'.$type.'">'; }
|
1108 |
}
|
1109 |
|
1110 |
$code .= '<video id="video_'.$div_suffix.'" ';
|
@@ -1119,10 +1138,10 @@ function KGVID_shortcode($atts, $content = ''){
|
|
1119 |
|
1120 |
$code .= implode("\n", $sources); //add the <source> tags created earlier
|
1121 |
|
1122 |
-
$code .= "</video>\n";
|
1123 |
|
1124 |
}
|
1125 |
-
$code .= "</div
|
1126 |
$show_views = false;
|
1127 |
if ( !empty($id) || !empty($query_atts['caption']) || $content == plugins_url('/images/sample-video-h264.mp4', __FILE__) ) { //generate content below the video
|
1128 |
$view_count = number_format(intval(get_post_meta($id, "_kgflashmediaplayer-starts", true)));
|
@@ -1130,7 +1149,7 @@ function KGVID_shortcode($atts, $content = ''){
|
|
1130 |
if ( $content == plugins_url('/images/sample-video-h264.mp4', __FILE__) ) { $view_count = "XX"; }
|
1131 |
if ( $query_atts['view_count'] == "true" ) { $show_views = true; }
|
1132 |
if ( !empty($query_atts['caption']) || $show_views || $query_atts['downloadlink'] == "true" ) {
|
1133 |
-
$code .= '<div class="kgvid_below_video" id="video_'.$div_suffix.'_below">';
|
1134 |
if ( $show_views ) { $code .= '<div class="kgvid-viewcount" id="video_'.$div_suffix.'_viewcount">'.$view_count.' views</div>'; }
|
1135 |
if ( !empty($query_atts['caption']) || $query_atts['downloadlink'] == "true" ) {
|
1136 |
$code .= '<div class="kgvid-caption" id="video_'.$div_suffix.'_caption">'.$query_atts['caption'];
|
@@ -1146,21 +1165,21 @@ function KGVID_shortcode($atts, $content = ''){
|
|
1146 |
|
1147 |
if ( $query_atts['title'] != "false" || $query_atts['embedcode'] != "false" ) { //generate content overlaid on video
|
1148 |
$kgvid_meta = true;
|
1149 |
-
$code .= "<div style=\"display:none;\" id=\"video_".$div_suffix."_meta\" class=\"kgvid_video_meta kgvid_video_meta_hover\"
|
1150 |
if ( $query_atts['embedcode'] != "false" ) {
|
1151 |
if ( $query_atts['embedcode'] == "true" ) { $iframeurl = site_url('/')."?attachment_id=".$id."&kgvid_video_embed[enable]=true"; }
|
1152 |
else { $iframeurl = $query_atts['embedcode']; }
|
1153 |
$iframecode = "<iframe src='".$iframeurl."' frameborder='0' scrolling='no' width='".$query_atts['width']."' height='".$query_atts["height"]."'></iframe>";
|
1154 |
-
$code .= "<div id=\"video_".$div_suffix."_embed\" class=\"kgvid_share\"><span>Embed: </span><input type=\"text\" value=\"".$iframecode."\" onClick=\"this.select();\"></div
|
1155 |
}
|
1156 |
if ( $query_atts['title'] != "false" ) {
|
1157 |
-
$code .= "<div id='video_".$div_suffix."_title' class='kgvid_title'>".$query_atts['title']."</div
|
1158 |
}
|
1159 |
-
$code .= "</div
|
1160 |
}
|
1161 |
else { $kgvid_meta = false; }
|
1162 |
if ( !empty($query_atts["watermark"]) && $query_atts["watermark"] != "false" ) { $code .= "<div style=\"display:none;\" id='video_".$div_suffix."_watermark' class='kgvid_watermark'><img src='".$query_atts["watermark"]."' alt='watermark'></div>"; } //generate watermark
|
1163 |
-
$code .= "</div>"; //end kgvid_XXXX_wrapper div
|
1164 |
|
1165 |
$video_variables = array(
|
1166 |
'id' => $div_suffix,
|
@@ -1178,12 +1197,12 @@ function KGVID_shortcode($atts, $content = ''){
|
|
1178 |
$json_video_variables = json_encode( $video_variables );
|
1179 |
|
1180 |
$code .= "\n\t\t"."<script type='text/javascript'>
|
1181 |
-
|
1182 |
if ( $options['embed_method'] == "Video.js" || ($options['embed_method'] == "Strobe Media Playback" && !$flash_source_found) ) {
|
1183 |
$code .= "\n\t\t\t"."if(typeof(jQuery)=='function'){(function($){\$.fn.fitVids=function(){}})(jQuery)};
|
1184 |
-
|
1185 |
}
|
1186 |
-
|
1187 |
$code .= "\n\t\t\t"."swfobject.embedSWF('".$video_swf."', 'video_".$div_suffix."', '".trim($query_atts['width'])."', '".trim($query_atts['height'])."', '".$minimum_flash."', '".plugins_url("", __FILE__)."/flash/expressInstall.swf', $flashvars, $params, '', function(e) { kgvid_setup_video(".$div_suffix."); });";
|
1188 |
} //if Strobe Media
|
1189 |
else {
|
@@ -1640,10 +1659,25 @@ function kgvid_FMPOptionsPage() {
|
|
1640 |
<input type="hidden" id="kgvid_settings_security" value="<?php echo wp_create_nonce('video-embed-thumbnail-generator-nonce'); ?>">
|
1641 |
<?php do_settings_sections(__FILE__); ?>
|
1642 |
<p class='submit'>
|
1643 |
-
<?php submit_button('Save Changes', 'primary', 'kgvid_submit', false); ?>
|
1644 |
<?php submit_button('Reset Options', 'secondary', 'video-embed-thumbnail-generator-reset', false); ?>
|
1645 |
</p>
|
1646 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1647 |
<?php echo "<script type='text/javascript'>
|
1648 |
jQuery(document).ready(function() {
|
1649 |
jQuery('#app_path').data('ffmpeg_exists', '".$options['ffmpeg_exists']."');
|
@@ -1700,7 +1734,7 @@ function kgvid_video_embed_options_init() {
|
|
1700 |
add_settings_field('titlecode', 'Video title text HTML formatting:', 'kgvid_titlecode_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'titlecode' ) );
|
1701 |
add_settings_field('template', 'Attachment template display:', 'kgvid_template_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'template' ) );
|
1702 |
|
1703 |
-
add_settings_field('app_path', 'Path to applications on server:', 'kgvid_app_path_callback', __FILE__, 'kgvid_video_embed_encode_settings', array( 'label_for' => 'app_path' ) );
|
1704 |
add_settings_field('video_app', 'Application for thumbnails & encoding:', 'kgvid_video_app_callback', __FILE__, 'kgvid_video_embed_encode_settings', array( 'label_for' => 'video_app' ) );
|
1705 |
add_settings_field('browser_thumbnails', 'Enable in-browser thumbnails:', 'kgvid_browser_thumbnails_callback', __FILE__, 'kgvid_video_embed_encode_settings', array( 'label_for' => 'browser_thumbnails' ) );
|
1706 |
add_settings_field('encode_formats', 'Default video encode formats:', 'kgvid_encode_formats_callback', __FILE__, 'kgvid_video_embed_encode_settings');
|
@@ -1958,7 +1992,7 @@ add_action('admin_init', 'kgvid_video_embed_options_init' );
|
|
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'>
|
1962 |
}
|
1963 |
|
1964 |
function kgvid_video_app_callback() {
|
@@ -2009,7 +2043,7 @@ add_action('admin_init', 'kgvid_video_embed_options_init' );
|
|
2009 |
function kgvid_htaccess_callback() {
|
2010 |
$options = get_option('kgvid_video_embed_options');
|
2011 |
echo "<div class='kgvid_video_app_required'>";
|
2012 |
-
echo "<table class='kgvid_htaccess'><tbody><tr><td>
|
2013 |
echo "<tr><td>Password:</td><td><input class='regular-text affects_ffmpeg' id='htaccess_password' name='kgvid_video_embed_options[htaccess_password]' type='text' value='".$options['htaccess_password']."' /> <a class='kgvid_tooltip' href='javascript:void(0);'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>If your videos are htaccess protected, <strong class='video_app_name'>".strtoupper($options['video_app'])."</strong> will access them using these credentials.</span></a></td></tr></tbody></table>";
|
2014 |
echo "</div>\n\t";
|
2015 |
}
|
@@ -2118,7 +2152,7 @@ add_action('admin_init', 'kgvid_video_embed_options_init' );
|
|
2118 |
$options = get_option('kgvid_video_embed_options');
|
2119 |
echo "<div class='kgvid_video_app_required'>";
|
2120 |
echo "<input class='affects_ffmpeg' onchange='if(jQuery(\"#ffmpeg_vpre\").attr(\"checked\")==\"checked\"){jQuery(\"#video_bitrate_flag\").attr(\"checked\", \"checked\");}' ".checked( $options['video_bitrate_flag'], "on", false )." id='video_bitrate_flag' name='kgvid_video_embed_options[video_bitrate_flag]' type='checkbox' /> <label for='video_bitrate_flag'>Enable legacy FFMPEG '-b' and '-ba' bitrate flags.</label> <a class='kgvid_tooltip' href='javascript:void(0);'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>Enable if your installed version of FFMPEG is old enough that you can't use the newer -b:v flags (Dreamhost users must turn this on). It may cause newer versions of FFMPEG to fail.</span></a><br />
|
2121 |
-
<input class='affects_ffmpeg' onchange='if(jQuery(\"#ffmpeg_vpre\").attr(\"checked\")==\"checked\"){jQuery(\"#video_bitrate_flag\").attr(\"checked\", \"checked\");}' ".checked( $options['ffmpeg_vpre'], "on", false )." id='ffmpeg_vpre' name='kgvid_video_embed_options[ffmpeg_vpre]' type='checkbox' /> <label for='ffmpeg_vpre'>Enable FFMPEG
|
2122 |
echo "</div>\n\t";
|
2123 |
}
|
2124 |
|
@@ -2146,7 +2180,7 @@ add_action('admin_init', 'kgvid_video_embed_options_init' );
|
|
2146 |
if ( $options['ffmpeg_exists'] != "on" ) { $display_div = " style='display:none;'"; }
|
2147 |
|
2148 |
echo "<div id='ffmpeg_sample_div'".$display_div."><p><strong class='video_app_name'>".strtoupper($options['video_app'])."</strong> sample H.264 encode command:<br /><textarea id='ffmpeg_h264_sample' class='ffmpeg_sample_code code' cols='100' rows='5' wrap='soft' readonly='yes'>".$encode_string."</textarea></p>";
|
2149 |
-
echo "<p><strong class='video_app_name'>".strtoupper($options['video_app'])."</strong> test output:<br /><textarea id='ffmpeg_output' class='ffmpeg_sample_code code' cols='100' rows='20' wrap='soft' readonly='yes'></textarea><br>
|
2150 |
}
|
2151 |
|
2152 |
//end of settings page callback functions
|
@@ -2155,32 +2189,6 @@ function kgvid_update_settings() {
|
|
2155 |
|
2156 |
global $wpdb;
|
2157 |
|
2158 |
-
|
2159 |
-
/* $labels = array(
|
2160 |
-
'name' => 'Video Info',
|
2161 |
-
'singular_name' => 'Video Info',
|
2162 |
-
'search_items' => 'Search Video Info',
|
2163 |
-
'all_items' => 'All Video Info',
|
2164 |
-
'parent_item' => 'Parent Video Info',
|
2165 |
-
'parent_item_colon' => 'Parent Video Info:',
|
2166 |
-
'edit_item' => 'Edit Video Info',
|
2167 |
-
'update_item' => 'Update Video Info',
|
2168 |
-
'add_new_item' => 'Add New Video Info',
|
2169 |
-
'new_item_name' => 'New Video Info',
|
2170 |
-
'menu_name' => 'Video Info',
|
2171 |
-
);
|
2172 |
-
|
2173 |
-
$args = array(
|
2174 |
-
'labels' => $labels,
|
2175 |
-
'hierarchical' => true,
|
2176 |
-
'query_var' => 'true',
|
2177 |
-
'rewrite' => 'true',
|
2178 |
-
'show_admin_column' => 'true',
|
2179 |
-
'show_tagcloud' => 'false'
|
2180 |
-
);
|
2181 |
-
|
2182 |
-
register_taxonomy( 'kgvid-video-info', 'attachment', $args ); */
|
2183 |
-
|
2184 |
$options = get_option('kgvid_video_embed_options');
|
2185 |
$options_old = $options; //save the values that are in the db
|
2186 |
$default_options = kgvid_default_options_fn();
|
@@ -2332,17 +2340,23 @@ function kgvid_video_embed_options_validate($input) { //validate & sanitize inpu
|
|
2332 |
add_settings_error( __FILE__, "options-reset", "Video Embed & Thumbnail Generator settings reset to default values.", "updated" );
|
2333 |
}
|
2334 |
|
2335 |
-
$
|
2336 |
|
2337 |
-
|
2338 |
-
|
2339 |
-
$input['
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2344 |
}
|
2345 |
-
if ( $ffmpeg_info['ffmpeg_exists'] == true ) { $input['ffmpeg_exists'] = "on"; }
|
2346 |
|
2347 |
if ( empty($input['width']) ) {
|
2348 |
add_settings_error( __FILE__, "width-zero", "You must enter a value for the maximum video width.");
|
@@ -2398,7 +2412,7 @@ function kgvid_ajax_save_settings() {
|
|
2398 |
$encode_string = kgvid_generate_encode_string(plugin_dir_url(__FILE__)."images/sample-video-h264.mp4", $uploads['path']."/sample-video-h264-480p.mp4", $movie_info['configuration'], 'mobile', 640, 360, '');
|
2399 |
}
|
2400 |
if ( strpos($setting, 'capability') !== false ) { $validated_options[$setting] = $value; }
|
2401 |
-
$arr = array ( "error_message" => $error_message, "validated_value" => $validated_options[$setting], "ffmpeg_exists" => $validated_options['ffmpeg_exists'], "encode_string" => $encode_string );
|
2402 |
echo json_encode($arr);
|
2403 |
die();
|
2404 |
}
|
@@ -2503,30 +2517,42 @@ function kgvid_image_attachment_fields_to_edit($form_fields, $post) {
|
|
2503 |
$field_id = kgvid_backwards_compatible($post->ID);
|
2504 |
$movieurl = wp_get_attachment_url($post->ID);
|
2505 |
$moviefile = get_attached_file($post->ID);
|
|
|
|
|
2506 |
$video_meta = array();
|
|
|
2507 |
if ( function_exists('wp_read_video_metadata') ) { $video_meta = wp_read_video_metadata($moviefile); }
|
|
|
|
|
2508 |
|
2509 |
$form_fields["kgflashmediaplayer-url"]["input"] = "hidden";
|
2510 |
$form_fields["kgflashmediaplayer-url"]["value"] = $movieurl;
|
2511 |
|
|
|
2512 |
$maxwidth = $options['width'];
|
2513 |
-
if ( $
|
2514 |
-
|
2515 |
-
|
2516 |
if ( $video_meta && array_key_exists('width', $video_meta) ) { $widthset = $video_meta['width']; }
|
2517 |
else { $widthset = $maxwidth; }
|
2518 |
}
|
|
|
2519 |
|
2520 |
$form_fields["kgflashmediaplayer-maxwidth"]["input"] = "hidden";
|
2521 |
$form_fields["kgflashmediaplayer-maxwidth"]["value"] = $maxwidth;
|
2522 |
|
|
|
2523 |
$maxheight = $options['height'];
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
|
|
|
|
|
|
2527 |
if ( $video_meta && array_key_exists('height', $video_meta) ) { $heightset = $video_meta['height']; }
|
2528 |
else { $heightset = $maxheight; }
|
2529 |
}
|
|
|
2530 |
|
2531 |
$form_fields["kgflashmediaplayer-maxheight"]["input"] = "hidden";
|
2532 |
$form_fields["kgflashmediaplayer-maxheight"]["value"] = $maxheight;
|
@@ -2553,17 +2579,6 @@ function kgvid_image_attachment_fields_to_edit($form_fields, $post) {
|
|
2553 |
|
2554 |
$thumbnail_url = get_post_meta($post->ID, "_kgflashmediaplayer-poster", true);
|
2555 |
|
2556 |
-
$uploads = wp_upload_dir();
|
2557 |
-
$url_parts = parse_url($uploads['baseurl']);
|
2558 |
-
$moviefiledirectory = dirname(parse_url(trim($thumbnail_url), PHP_URL_PATH));
|
2559 |
-
$moviefilebasename = pathinfo(trim($thumbnail_url), PATHINFO_BASENAME);
|
2560 |
-
$home_path = substr(strrev(strstr(strrev($uploads['basedir']), strrev("public_html"))), 0, -strlen("public_html"));
|
2561 |
-
if ( strpos( dirname(trim($thumbnail_url)), $url_parts['host']) != "" ) { //if it's on the current server
|
2562 |
-
$originalpath = $home_path."public_html".$moviefiledirectory."/".$moviefilebasename;
|
2563 |
-
if ( !file_exists($originalpath) ) { $thumbnail_url = ""; }
|
2564 |
-
}
|
2565 |
-
else { if ( !kgvid_url_exists($thumbnail_url) ) { $thumbnail_url = ""; } }
|
2566 |
-
|
2567 |
$thumbnail_html = "";
|
2568 |
if ($thumbnail_url != "" ) {
|
2569 |
$thumbnail_html = '<div class="kgvid_thumbnail_box kgvid_chosen_thumbnail_box"><img width="200" src="'.$thumbnail_url.'"></div>';
|
@@ -2687,7 +2702,7 @@ display: inline-block;">Loading thumbnail...</span></div>';
|
|
2687 |
|
2688 |
$form_fields["kgflashmediaplayer-dimensions"]["label"] = __("Video Embed Dimensions");
|
2689 |
$form_fields["kgflashmediaplayer-dimensions"]["input"] = "html";
|
2690 |
-
$form_fields["kgflashmediaplayer-dimensions"]["html"] = 'Width: <input name="attachments['. $post->ID .'][kgflashmediaplayer-width]" id="attachments-'. $post->ID .'-kgflashmediaplayer-width" type="text" value="'.$widthset.'" style="width:50px;" onchange="kgvid_set_dimension('.$post->ID.', \'height\', this.value);" onkeyup="kgvid_set_dimension('.$post->ID.', \'height\', this.value);"> Height:
|
2691 |
<input name="attachments['. $post->ID .'][kgflashmediaplayer-height]" id="attachments-'. $post->ID .'-kgflashmediaplayer-height" type="text" value="'.$heightset.'" style="width:50px;" onchange="kgvid_set_dimension('.$post->ID.', \'width\', this.value);" onkeyup="kgvid_set_dimension('.$post->ID.', \'width\', this.value);"> <br />
|
2692 |
<input type="checkbox" name="attachments['. $post->ID .'][kgflashmediaplayer-lockaspect]" id="attachments-'. $post->ID .'-kgflashmediaplayer-lockaspect" onclick="kgvid_set_aspect('.$post->ID.', this.checked);" value="checked" '.$lockaspectchecked.'>
|
2693 |
<label for="attachments-'. $post->ID .'-kgflashmediaplayer-lockaspect"><small>Lock to aspect ratio</small></label>';
|
@@ -2911,7 +2926,8 @@ function kgvid_save_thumb($post_id, $post_name, $thumb_url, $index=false) {
|
|
2911 |
|
2912 |
usleep(250000);
|
2913 |
|
2914 |
-
$
|
|
|
2915 |
|
2916 |
$args = array(
|
2917 |
'numberposts' => '-1',
|
@@ -3523,16 +3539,7 @@ function kgvid_make_thumbs($postID, $movieurl, $numberofthumbs, $i, $iincreaser,
|
|
3523 |
if ( is_file($thumbnailfilename[$i]) )
|
3524 |
kgvid_schedule_cleanup_generated_files('thumbs');
|
3525 |
|
3526 |
-
|
3527 |
-
$movieoffset_minutes = sprintf("%02s", intval(intval($movieoffset) / 60) );
|
3528 |
-
$movieoffset_seconds = sprintf("%02s", round(fmod( floatval($movieoffset), 60), 2) );
|
3529 |
-
$movieoffset_display = $movieoffset_minutes.":".$movieoffset_seconds;
|
3530 |
-
}
|
3531 |
-
else { $movieoffset_display = "00:".sprintf("%02s", $movieoffset); }
|
3532 |
-
|
3533 |
-
$field_id = kgvid_backwards_compatible($postID);
|
3534 |
-
|
3535 |
-
$thumbnaildisplaycode = '<div class="kgvid_thumbnail_select" name="attachments['.$postID.'][thumb'.$i.']" id="attachments-'.$postID.'-thumb'.$i.'"><label for="kgflashmedia-'.$postID.'-thumbradio'.$i.'"><img src="'.$thumbnailurl.'?'.rand().'" width="200" height="'.$thumbnailheight.'" class="kgvid_thumbnail"></label><br /><input type="radio" name="attachments['.$postID.'][thumbradio'.$i.']" id="kgflashmedia-'.$postID.'-thumbradio'.$i.'" value="'.str_replace('/thumb_tmp/', '/', $thumbnailurl).'" onchange="document.getElementById(\''.$field_id['poster'].'\').value = this.value; document.getElementById(\''.$field_id['thumbtime'].'\').value = \''. $movieoffset_display .'\'; document.getElementById(\'attachments-'. $postID .'-numberofthumbs\').value =\'1\';"></div>';
|
3536 |
|
3537 |
$i++;
|
3538 |
|
@@ -3911,11 +3918,11 @@ function kgvid_encode_videos() {
|
|
3911 |
|
3912 |
function kgvid_ajax_encode_videos() {
|
3913 |
|
3914 |
-
|
3915 |
-
|
3916 |
-
|
3917 |
-
|
3918 |
-
|
3919 |
|
3920 |
}
|
3921 |
add_action('wp_ajax_kgvid_ajax_encode_videos', 'kgvid_ajax_encode_videos');
|
@@ -3923,12 +3930,27 @@ add_action('wp_ajax_kgvid_ajax_encode_videos', 'kgvid_ajax_encode_videos');
|
|
3923 |
function kgvid_test_ffmpeg() {
|
3924 |
|
3925 |
check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
|
|
|
|
|
|
|
3926 |
$cmd = $_POST['command'];
|
3927 |
$cmd=escapeshellcmd(stripcslashes($cmd));
|
3928 |
exec ( $cmd.' 2>&1', $output );
|
3929 |
-
$
|
3930 |
-
|
3931 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3932 |
die;
|
3933 |
|
3934 |
}
|
@@ -4055,7 +4077,7 @@ function kgvid_encode_progress($video_key, $format, $page) {
|
|
4055 |
$time_elapsed = $ended - $started;
|
4056 |
$time_remaining = "0";
|
4057 |
$fps_match = "10";
|
4058 |
-
if ( array_key_exists(1, $libx264_matches) ) { kgvid_fix_moov_atom($video_key
|
4059 |
$video_embed_queue[$video_key]['encode_formats'][$format]['status'] = "Encoding Complete";
|
4060 |
$video_embed_queue[$video_key]['encode_formats'][$format]['ended'] = $ended;
|
4061 |
$video_embed_queue[$video_key]['encode_formats'][$format]['lastline'] = $lastline;
|
@@ -4324,19 +4346,21 @@ function kgvid_cleanup_queue_handler() {
|
|
4324 |
}
|
4325 |
add_action('kgvid_cleanup_queue', 'kgvid_cleanup_queue_handler');
|
4326 |
|
4327 |
-
function kgvid_fix_moov_atom($
|
4328 |
|
4329 |
$options = get_option('kgvid_video_embed_options');
|
|
|
4330 |
|
4331 |
if ( $options['moov'] == "qt-faststart" || $options['moov'] == "MP4Box" ) {
|
4332 |
|
4333 |
-
$
|
4334 |
-
$filepath = $video_embed_queue[$video_key][$format]['filepath'];
|
4335 |
|
4336 |
if ( $options['moov'] == 'qt-faststart' && file_exists($filepath) ) {
|
4337 |
-
$faststart_tmp_file = str_replace('.
|
4338 |
$cmd = escapeshellcmd($options['app_path']."/".$options['moov']." ".$filepath." ".$faststart_tmp_file);
|
4339 |
-
|
|
|
|
|
4340 |
if ( file_exists($faststart_tmp_file) ) {
|
4341 |
unlink($filepath);
|
4342 |
rename($faststart_tmp_file, $filepath);
|
@@ -4345,11 +4369,15 @@ function kgvid_fix_moov_atom($video_key, $format) {
|
|
4345 |
|
4346 |
if ( $options['moov'] == 'MP4Box' ) {
|
4347 |
$cmd = escapeshellcmd($options['app_path']."/".$options['moov']." -inter 500 ".$filepath);
|
4348 |
-
|
|
|
|
|
4349 |
}//if MP4Box is selected
|
4350 |
|
4351 |
}//if there is an application selected for fixing moov atoms on libx264-encoded files.
|
4352 |
|
|
|
|
|
4353 |
}
|
4354 |
|
4355 |
function kgvid_cancel_encode() {
|
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.4
|
7 |
Author: Kyle Gilman
|
8 |
Author URI: http://www.kylegilman.net/
|
9 |
|
47 |
$upload_capable = kgvid_upload_capable();
|
48 |
|
49 |
$options = array(
|
50 |
+
"version"=>4.24,
|
51 |
"embed_method"=>"Video.js",
|
52 |
"template"=>false,
|
53 |
"template_gentle"=>"on",
|
347 |
if(function_exists('exec')) {
|
348 |
if (function_exists('escapeshellcmd')) {
|
349 |
$exec_enabled = true;
|
350 |
+
$test_path = rtrim($options['app_path'], '/');
|
351 |
+
$cmd = escapeshellcmd($test_path.'/'.$options['video_app'].' -i '.plugin_dir_path(__FILE__).'images/sample-video-h264.mp4 -vframes 1 -f mjpeg '.$uploads['path'].'/ffmpeg_exists_test.jpg');
|
352 |
exec ( $cmd, $output, $returnvalue );
|
353 |
+
|
354 |
}
|
355 |
else { $function = "ESCAPESHELLCMD"; }
|
356 |
}
|
357 |
else { $function = "EXEC"; }
|
358 |
|
359 |
+
if ( $exec_enabled == true ) {
|
360 |
+
|
361 |
+
if ( !file_exists($uploads['path'].'/ffmpeg_exists_test.jpg') ) { //if FFMPEG has not executed successfully
|
362 |
+
$test_path = substr($test_path, 0, -strlen($options['video_app'])-1 );
|
363 |
+
$cmd = escapeshellcmd($test_path.'/'.$options['video_app'].' -i '.plugin_dir_path(__FILE__).'images/sample-video-h264.mp4 -vframes 1 -f mjpeg '.$uploads['path'].'/ffmpeg_exists_test.jpg');
|
364 |
+
error_log($cmd);
|
365 |
+
exec ( $cmd, $output, $returnvalue );
|
366 |
+
}
|
367 |
+
|
368 |
+
if ( file_exists($uploads['path'].'/ffmpeg_exists_test.jpg') ) { //FFMEG has executed successfully
|
369 |
+
$ffmpeg_exists = true;
|
370 |
+
unlink($uploads['path'].'/ffmpeg_exists_test.jpg');
|
371 |
+
$options['app_path'] = $test_path;
|
372 |
+
}
|
373 |
+
|
374 |
}
|
375 |
|
376 |
+
if ( $save ) {
|
377 |
if ( $ffmpeg_exists == true ) { $options['ffmpeg_exists'] = "on"; }
|
378 |
else {
|
379 |
$options['ffmpeg_exists'] = "notinstalled";
|
383 |
}
|
384 |
|
385 |
$output_output = implode("/n", $output);
|
386 |
+
$arr = array (
|
387 |
+
"exec_enabled"=>$exec_enabled,
|
388 |
+
"ffmpeg_exists"=>$ffmpeg_exists,
|
389 |
+
"output"=>$output_output,
|
390 |
+
"function"=>$function,
|
391 |
+
"app_path"=>$options['app_path']
|
392 |
+
);
|
393 |
return $arr;
|
394 |
}
|
395 |
|
645 |
if ( $aaclib == "aac" ) { $aaclib = "aac -strict experimental"; } //the built-in aac encoder is considered experimental
|
646 |
|
647 |
$vpre_flags = "";
|
648 |
+
if ( $options['ffmpeg_vpre'] == 'on' ) { $vpre_flags = ' -coder 0 -flags +loop -cmp +chroma -partitions +parti8x8+parti4x4+partp8x8+partb8x8 -me_method hex -subq 6 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -bf 0 -refs 1 -trellis 1 -flags2 +bpyramid+mixed_refs-wpred-dct8x8+fastpskip -wpredp 0 -rc_lookahead 30 -maxrate 10000000 -bufsize 10000000'; }
|
649 |
|
650 |
$movflags = "";
|
651 |
if ( $options['moov'] == "movflag" ) {
|
662 |
|
663 |
$level_text = "";
|
664 |
if ( $options['h264_level'] != "none" ) {
|
665 |
+
$level_text = " -".$level_flag." ".round(floatval($options['h264_level'])*10);
|
|
|
666 |
}
|
667 |
|
668 |
$ffmpeg_options = "-acodec ".$aaclib." -".$audio_bitrate_flag." ".$options['audio_bitrate']."k -s ".$width."x".$height." -vcodec libx264".$vpre_flags.$movflags.$profile_text.$level_text;
|
1072 |
}
|
1073 |
else { $aligncode = ""; }
|
1074 |
|
1075 |
+
$code .= '<div id="kgvid_'.$div_suffix.'_wrapper" class="kgvid_wrapper"'.$aligncode.'>'."\n\t\t\t";
|
1076 |
+
$code .= '<div id="video_'.$div_suffix.'_div" class="kgvid_videodiv" itemscope itemtype="http://schema.org/VideoObject">'."\n\t\t\t\t";
|
1077 |
+
if ( $query_atts["poster"] != '' ) { $code .= '<meta itemprop="thumbnailURL" content="'.$query_atts["poster"].'" />'."\n\t\t\t\t"; }
|
1078 |
if ( !empty($id) ) { $schema_embedURL = site_url('/')."?attachment_id=".$id."&kgvid_video_embed[enable]=true"; }
|
1079 |
else { $schema_embedURL = $content; }
|
1080 |
+
$code .= '<meta itemprop="embedURL" content="'.$schema_embedURL.'" />'."\n\t\t\t\t";
|
1081 |
|
1082 |
+
if ( !empty($query_atts['title']) ) { $code .= '<meta itemprop="name" content="'.$query_atts['title'].'" />'."\n\t\t\t\t"; }
|
1083 |
if ( !empty($query_atts['description']) ) { $description = $query_atts['description']; }
|
1084 |
elseif ( !empty($query_atts['caption']) ) { $description = $query_atts['caption']; }
|
1085 |
else { $description = ""; }
|
1086 |
+
if ( !empty($description) ) { $code .= '<meta itemprop="description" content="'.esc_attr($description).'" />'."\n\t\t\t\t"; }
|
1087 |
|
1088 |
if ( $options['embed_method'] == "WordPress Default" ) {
|
1089 |
$wp_shortcode = "[video ";
|
1123 |
|
1124 |
foreach ($video_formats as $name => $type) {
|
1125 |
if ( $name != "original" && $encodevideo_info[$name."url"] == $content ) { unset($sources['original']); }
|
1126 |
+
if ( $encodevideo_info[$name."_exists"] ) { $sources[$name] = "\t\t\t\t\t".'<source src="'.$encodevideo_info[$name."url"].'" type="video/'.$type.'">'."\n"; }
|
1127 |
}
|
1128 |
|
1129 |
$code .= '<video id="video_'.$div_suffix.'" ';
|
1138 |
|
1139 |
$code .= implode("\n", $sources); //add the <source> tags created earlier
|
1140 |
|
1141 |
+
$code .= "\t\t\t\t</video>\n";
|
1142 |
|
1143 |
}
|
1144 |
+
$code .= "\t\t\t</div>\n";
|
1145 |
$show_views = false;
|
1146 |
if ( !empty($id) || !empty($query_atts['caption']) || $content == plugins_url('/images/sample-video-h264.mp4', __FILE__) ) { //generate content below the video
|
1147 |
$view_count = number_format(intval(get_post_meta($id, "_kgflashmediaplayer-starts", true)));
|
1149 |
if ( $content == plugins_url('/images/sample-video-h264.mp4', __FILE__) ) { $view_count = "XX"; }
|
1150 |
if ( $query_atts['view_count'] == "true" ) { $show_views = true; }
|
1151 |
if ( !empty($query_atts['caption']) || $show_views || $query_atts['downloadlink'] == "true" ) {
|
1152 |
+
$code .= "\t\t\t".'<div class="kgvid_below_video" id="video_'.$div_suffix.'_below">';
|
1153 |
if ( $show_views ) { $code .= '<div class="kgvid-viewcount" id="video_'.$div_suffix.'_viewcount">'.$view_count.' views</div>'; }
|
1154 |
if ( !empty($query_atts['caption']) || $query_atts['downloadlink'] == "true" ) {
|
1155 |
$code .= '<div class="kgvid-caption" id="video_'.$div_suffix.'_caption">'.$query_atts['caption'];
|
1165 |
|
1166 |
if ( $query_atts['title'] != "false" || $query_atts['embedcode'] != "false" ) { //generate content overlaid on video
|
1167 |
$kgvid_meta = true;
|
1168 |
+
$code .= "\t\t\t<div style=\"display:none;\" id=\"video_".$div_suffix."_meta\" class=\"kgvid_video_meta kgvid_video_meta_hover\">\n";
|
1169 |
if ( $query_atts['embedcode'] != "false" ) {
|
1170 |
if ( $query_atts['embedcode'] == "true" ) { $iframeurl = site_url('/')."?attachment_id=".$id."&kgvid_video_embed[enable]=true"; }
|
1171 |
else { $iframeurl = $query_atts['embedcode']; }
|
1172 |
$iframecode = "<iframe src='".$iframeurl."' frameborder='0' scrolling='no' width='".$query_atts['width']."' height='".$query_atts["height"]."'></iframe>";
|
1173 |
+
$code .= "\t\t\t\t<div id=\"video_".$div_suffix."_embed\" class=\"kgvid_share\"><span>Embed: </span><input type=\"text\" value=\"".$iframecode."\" onClick=\"this.select();\"></div>\n";
|
1174 |
}
|
1175 |
if ( $query_atts['title'] != "false" ) {
|
1176 |
+
$code .= "\t\t\t\t<div id='video_".$div_suffix."_title' class='kgvid_title'>".$query_atts['title']."</div>\n";
|
1177 |
}
|
1178 |
+
$code .= "\t\t\t</div>\n";
|
1179 |
}
|
1180 |
else { $kgvid_meta = false; }
|
1181 |
if ( !empty($query_atts["watermark"]) && $query_atts["watermark"] != "false" ) { $code .= "<div style=\"display:none;\" id='video_".$div_suffix."_watermark' class='kgvid_watermark'><img src='".$query_atts["watermark"]."' alt='watermark'></div>"; } //generate watermark
|
1182 |
+
$code .= "\t\t</div>"; //end kgvid_XXXX_wrapper div
|
1183 |
|
1184 |
$video_variables = array(
|
1185 |
'id' => $div_suffix,
|
1197 |
$json_video_variables = json_encode( $video_variables );
|
1198 |
|
1199 |
$code .= "\n\t\t"."<script type='text/javascript'>
|
1200 |
+
kgvid_video_vars['".$div_suffix."'] = jQuery.parseJSON ( '".$json_video_variables."' );";
|
1201 |
if ( $options['embed_method'] == "Video.js" || ($options['embed_method'] == "Strobe Media Playback" && !$flash_source_found) ) {
|
1202 |
$code .= "\n\t\t\t"."if(typeof(jQuery)=='function'){(function($){\$.fn.fitVids=function(){}})(jQuery)};
|
1203 |
+
videojs('video_".$div_suffix."').ready(function(){ kgvid_setup_video('".$div_suffix."'); });";
|
1204 |
}
|
1205 |
+
elseif ( $options['embed_method'] == "Strobe Media Playback" && $flash_source_found ) {
|
1206 |
$code .= "\n\t\t\t"."swfobject.embedSWF('".$video_swf."', 'video_".$div_suffix."', '".trim($query_atts['width'])."', '".trim($query_atts['height'])."', '".$minimum_flash."', '".plugins_url("", __FILE__)."/flash/expressInstall.swf', $flashvars, $params, '', function(e) { kgvid_setup_video(".$div_suffix."); });";
|
1207 |
} //if Strobe Media
|
1208 |
else {
|
1659 |
<input type="hidden" id="kgvid_settings_security" value="<?php echo wp_create_nonce('video-embed-thumbnail-generator-nonce'); ?>">
|
1660 |
<?php do_settings_sections(__FILE__); ?>
|
1661 |
<p class='submit'>
|
1662 |
+
<?php submit_button('Save Changes', 'primary', 'kgvid_submit', false, array( 'onclick' => "jQuery('form :disabled').prop('disabled', false);" ) ); ?>
|
1663 |
<?php submit_button('Reset Options', 'secondary', 'video-embed-thumbnail-generator-reset', false); ?>
|
1664 |
</p>
|
1665 |
</form>
|
1666 |
+
|
1667 |
+
<div class="kgvid-blue-box">
|
1668 |
+
<span>If you’re getting some use out of this plugin, please consider donating a few dollars to support its future development.</span>
|
1669 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
1670 |
+
<input type="hidden" name="cmd" value="_donations">
|
1671 |
+
<input type="hidden" name="business" value="kylegilman@gmail.com">
|
1672 |
+
<input type="hidden" name="lc" value="US">
|
1673 |
+
<input type="hidden" name="item_name" value="Video Embed & Thumbnail Generator Plugin Donation">
|
1674 |
+
<input type="hidden" name="currency_code" value="USD">
|
1675 |
+
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHosted">
|
1676 |
+
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
1677 |
+
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
1678 |
+
</form>
|
1679 |
+
</div>
|
1680 |
+
|
1681 |
<?php echo "<script type='text/javascript'>
|
1682 |
jQuery(document).ready(function() {
|
1683 |
jQuery('#app_path').data('ffmpeg_exists', '".$options['ffmpeg_exists']."');
|
1734 |
add_settings_field('titlecode', 'Video title text HTML formatting:', 'kgvid_titlecode_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'titlecode' ) );
|
1735 |
add_settings_field('template', 'Attachment template display:', 'kgvid_template_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'template' ) );
|
1736 |
|
1737 |
+
add_settings_field('app_path', 'Path to applications folder on server:', 'kgvid_app_path_callback', __FILE__, 'kgvid_video_embed_encode_settings', array( 'label_for' => 'app_path' ) );
|
1738 |
add_settings_field('video_app', 'Application for thumbnails & encoding:', 'kgvid_video_app_callback', __FILE__, 'kgvid_video_embed_encode_settings', array( 'label_for' => 'video_app' ) );
|
1739 |
add_settings_field('browser_thumbnails', 'Enable in-browser thumbnails:', 'kgvid_browser_thumbnails_callback', __FILE__, 'kgvid_video_embed_encode_settings', array( 'label_for' => 'browser_thumbnails' ) );
|
1740 |
add_settings_field('encode_formats', 'Default video encode formats:', 'kgvid_encode_formats_callback', __FILE__, 'kgvid_video_embed_encode_settings');
|
1992 |
|
1993 |
function kgvid_app_path_callback() {
|
1994 |
$options = get_option('kgvid_video_embed_options');
|
1995 |
+
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'>This should be the folder where applications are installed on your server, not a direct path to an application, so it doesn't usually end with <code><strong class='video_app_name'>".strtoupper($options['video_app'])."</strong></code> Example: <code>/usr/local/bin</code>."."\n\t";
|
1996 |
}
|
1997 |
|
1998 |
function kgvid_video_app_callback() {
|
2043 |
function kgvid_htaccess_callback() {
|
2044 |
$options = get_option('kgvid_video_embed_options');
|
2045 |
echo "<div class='kgvid_video_app_required'>";
|
2046 |
+
echo "<table class='kgvid_htaccess'><tbody><tr><td>Username:</td><td><input class='regular-text affects_ffmpeg' id='htaccess_login' name='kgvid_video_embed_options[htaccess_login]' type='text' value='".$options['htaccess_login']."' /></td></tr>";
|
2047 |
echo "<tr><td>Password:</td><td><input class='regular-text affects_ffmpeg' id='htaccess_password' name='kgvid_video_embed_options[htaccess_password]' type='text' value='".$options['htaccess_password']."' /> <a class='kgvid_tooltip' href='javascript:void(0);'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>If your videos are htaccess protected, <strong class='video_app_name'>".strtoupper($options['video_app'])."</strong> will access them using these credentials.</span></a></td></tr></tbody></table>";
|
2048 |
echo "</div>\n\t";
|
2049 |
}
|
2152 |
$options = get_option('kgvid_video_embed_options');
|
2153 |
echo "<div class='kgvid_video_app_required'>";
|
2154 |
echo "<input class='affects_ffmpeg' onchange='if(jQuery(\"#ffmpeg_vpre\").attr(\"checked\")==\"checked\"){jQuery(\"#video_bitrate_flag\").attr(\"checked\", \"checked\");}' ".checked( $options['video_bitrate_flag'], "on", false )." id='video_bitrate_flag' name='kgvid_video_embed_options[video_bitrate_flag]' type='checkbox' /> <label for='video_bitrate_flag'>Enable legacy FFMPEG '-b' and '-ba' bitrate flags.</label> <a class='kgvid_tooltip' href='javascript:void(0);'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>Enable if your installed version of FFMPEG is old enough that you can't use the newer -b:v flags (Dreamhost users must turn this on). It may cause newer versions of FFMPEG to fail.</span></a><br />
|
2155 |
+
<input class='affects_ffmpeg' onchange='if(jQuery(\"#ffmpeg_vpre\").attr(\"checked\")==\"checked\"){jQuery(\"#video_bitrate_flag\").attr(\"checked\", \"checked\");}' ".checked( $options['ffmpeg_vpre'], "on", false )." id='ffmpeg_vpre' name='kgvid_video_embed_options[ffmpeg_vpre]' type='checkbox' /> <label for='ffmpeg_vpre'>Enable legacy FFMPEG parameters.</label> <a class='kgvid_tooltip' href='javascript:void(0);'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>Enable if your installed version of FFMPEG is old enough that libx264 requires additional configuration to operate (Dreamhost users must turn this on). This should help if you can encode WEBM or OGV files but H264/Mobile files fail. It could cause newer versions of FFMPEG to fail.</span></a>";
|
2156 |
echo "</div>\n\t";
|
2157 |
}
|
2158 |
|
2180 |
if ( $options['ffmpeg_exists'] != "on" ) { $display_div = " style='display:none;'"; }
|
2181 |
|
2182 |
echo "<div id='ffmpeg_sample_div'".$display_div."><p><strong class='video_app_name'>".strtoupper($options['video_app'])."</strong> sample H.264 encode command:<br /><textarea id='ffmpeg_h264_sample' class='ffmpeg_sample_code code' cols='100' rows='5' wrap='soft' readonly='yes'>".$encode_string."</textarea></p>";
|
2183 |
+
echo "<p><strong class='video_app_name'>".strtoupper($options['video_app'])."</strong> test output:<br /><textarea id='ffmpeg_output' class='ffmpeg_sample_code code' cols='100' rows='20' wrap='soft' readonly='yes'></textarea><br>For help interpreting this output, <a href='https://github.com/kylegilman/video-embed-thumbnail-generator/wiki/Interpreting-FFMPEG-or-LIBAV-messages'>try our Wiki page on Github</a>.</p></div>\n\t";
|
2184 |
}
|
2185 |
|
2186 |
//end of settings page callback functions
|
2189 |
|
2190 |
global $wpdb;
|
2191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2192 |
$options = get_option('kgvid_video_embed_options');
|
2193 |
$options_old = $options; //save the values that are in the db
|
2194 |
$default_options = kgvid_default_options_fn();
|
2340 |
add_settings_error( __FILE__, "options-reset", "Video Embed & Thumbnail Generator settings reset to default values.", "updated" );
|
2341 |
}
|
2342 |
|
2343 |
+
if ( $input['app_path'] != $options['app_path'] || $input['video_app'] != $options['video_app'] ) {
|
2344 |
|
2345 |
+
$ffmpeg_info = kgvid_check_ffmpeg_exists($input, false);
|
2346 |
+
|
2347 |
+
$input['app_path'] = $ffmpeg_info['app_path'];
|
2348 |
+
|
2349 |
+
|
2350 |
+
if ( $ffmpeg_info['exec_enabled'] == false ) {
|
2351 |
+
add_settings_error( __FILE__, "ffmpeg-disabled", $ffmpeg_info['function']." is disabled in PHP settings. You can embed existing videos and make thumbnails with compatible browsers, but video encoding will not work. Contact your System Administrator to find out if you can enable ".$ffmpeg_info['function'].".", "updated");
|
2352 |
+
$input['ffmpeg_exists'] = "notinstalled";
|
2353 |
+
}
|
2354 |
+
elseif ( $ffmpeg_info['ffmpeg_exists'] == false ) {
|
2355 |
+
add_settings_error( __FILE__, "ffmpeg-disabled", strtoupper($input['video_app'])." not found at ".$input['app_path'].". You can embed existing videos and make thumbnails with compatible browsers, but video encoding is not possible without ".strtoupper($input['video_app']).".", "updated");
|
2356 |
+
$input['ffmpeg_exists'] = "notinstalled";
|
2357 |
+
}
|
2358 |
+
if ( $ffmpeg_info['ffmpeg_exists'] == true ) { $input['ffmpeg_exists'] = "on"; }
|
2359 |
}
|
|
|
2360 |
|
2361 |
if ( empty($input['width']) ) {
|
2362 |
add_settings_error( __FILE__, "width-zero", "You must enter a value for the maximum video width.");
|
2412 |
$encode_string = kgvid_generate_encode_string(plugin_dir_url(__FILE__)."images/sample-video-h264.mp4", $uploads['path']."/sample-video-h264-480p.mp4", $movie_info['configuration'], 'mobile', 640, 360, '');
|
2413 |
}
|
2414 |
if ( strpos($setting, 'capability') !== false ) { $validated_options[$setting] = $value; }
|
2415 |
+
$arr = array ( "error_message" => $error_message, "validated_value" => $validated_options[$setting], "ffmpeg_exists" => $validated_options['ffmpeg_exists'], "encode_string" => $encode_string, "app_path" => $validated_options['app_path'] );
|
2416 |
echo json_encode($arr);
|
2417 |
die();
|
2418 |
}
|
2517 |
$field_id = kgvid_backwards_compatible($post->ID);
|
2518 |
$movieurl = wp_get_attachment_url($post->ID);
|
2519 |
$moviefile = get_attached_file($post->ID);
|
2520 |
+
$widthsaved = get_post_meta($post->ID, "_kgflashmediaplayer-width", true);
|
2521 |
+
$heightsaved = get_post_meta($post->ID, "_kgflashmediaplayer-height", true);
|
2522 |
$video_meta = array();
|
2523 |
+
$video_aspect = NULL;
|
2524 |
if ( function_exists('wp_read_video_metadata') ) { $video_meta = wp_read_video_metadata($moviefile); }
|
2525 |
+
if ( $video_meta && array_key_exists('width', $video_meta) && array_key_exists('height', $video_meta) ) { $video_aspect = $video_meta['height']/$video_meta['width']; }
|
2526 |
+
elseif ( $widthsaved && $heightsaved ) { $video_aspect = intval($heightsaved)/intval($widthsaved); }
|
2527 |
|
2528 |
$form_fields["kgflashmediaplayer-url"]["input"] = "hidden";
|
2529 |
$form_fields["kgflashmediaplayer-url"]["value"] = $movieurl;
|
2530 |
|
2531 |
+
|
2532 |
$maxwidth = $options['width'];
|
2533 |
+
if ( $widthsaved ) { $widthset = $widthsaved; }
|
2534 |
+
elseif ( $options['minimum_width'] == "on" ) { $widthset = $maxwidth; }
|
2535 |
+
else {
|
2536 |
if ( $video_meta && array_key_exists('width', $video_meta) ) { $widthset = $video_meta['width']; }
|
2537 |
else { $widthset = $maxwidth; }
|
2538 |
}
|
2539 |
+
if ( !$widthsaved ) { update_post_meta($post->ID, '_kgflashmediaplayer-width', $widthset); }
|
2540 |
|
2541 |
$form_fields["kgflashmediaplayer-maxwidth"]["input"] = "hidden";
|
2542 |
$form_fields["kgflashmediaplayer-maxwidth"]["value"] = $maxwidth;
|
2543 |
|
2544 |
+
|
2545 |
$maxheight = $options['height'];
|
2546 |
+
|
2547 |
+
if ( $heightsaved ) {
|
2548 |
+
$heightset = $heightsaved;
|
2549 |
+
}
|
2550 |
+
elseif ( $video_aspect ) { $heightset = round($widthset*$video_aspect); }
|
2551 |
+
else {
|
2552 |
if ( $video_meta && array_key_exists('height', $video_meta) ) { $heightset = $video_meta['height']; }
|
2553 |
else { $heightset = $maxheight; }
|
2554 |
}
|
2555 |
+
if ( !$heightsaved ) { update_post_meta($post->ID, '_kgflashmediaplayer-height', $heightset); }
|
2556 |
|
2557 |
$form_fields["kgflashmediaplayer-maxheight"]["input"] = "hidden";
|
2558 |
$form_fields["kgflashmediaplayer-maxheight"]["value"] = $maxheight;
|
2579 |
|
2580 |
$thumbnail_url = get_post_meta($post->ID, "_kgflashmediaplayer-poster", true);
|
2581 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2582 |
$thumbnail_html = "";
|
2583 |
if ($thumbnail_url != "" ) {
|
2584 |
$thumbnail_html = '<div class="kgvid_thumbnail_box kgvid_chosen_thumbnail_box"><img width="200" src="'.$thumbnail_url.'"></div>';
|
2702 |
|
2703 |
$form_fields["kgflashmediaplayer-dimensions"]["label"] = __("Video Embed Dimensions");
|
2704 |
$form_fields["kgflashmediaplayer-dimensions"]["input"] = "html";
|
2705 |
+
$form_fields["kgflashmediaplayer-dimensions"]["html"] = 'Width: <input name="attachments['. $post->ID .'][kgflashmediaplayer-width]" id="attachments-'. $post->ID .'-kgflashmediaplayer-width" type="text" value="'.$widthset.'" style="width:50px;" data-minimum="'.$options['minimum_width'].'" onchange="kgvid_set_dimension('.$post->ID.', \'height\', this.value);" onkeyup="kgvid_set_dimension('.$post->ID.', \'height\', this.value);"> Height:
|
2706 |
<input name="attachments['. $post->ID .'][kgflashmediaplayer-height]" id="attachments-'. $post->ID .'-kgflashmediaplayer-height" type="text" value="'.$heightset.'" style="width:50px;" onchange="kgvid_set_dimension('.$post->ID.', \'width\', this.value);" onkeyup="kgvid_set_dimension('.$post->ID.', \'width\', this.value);"> <br />
|
2707 |
<input type="checkbox" name="attachments['. $post->ID .'][kgflashmediaplayer-lockaspect]" id="attachments-'. $post->ID .'-kgflashmediaplayer-lockaspect" onclick="kgvid_set_aspect('.$post->ID.', this.checked);" value="checked" '.$lockaspectchecked.'>
|
2708 |
<label for="attachments-'. $post->ID .'-kgflashmediaplayer-lockaspect"><small>Lock to aspect ratio</small></label>';
|
2926 |
|
2927 |
usleep(250000);
|
2928 |
|
2929 |
+
$exploded_url = explode($uploads['baseurl'].'/', $thumb_url);
|
2930 |
+
$relative_upload_path = array_pop($exploded_url);
|
2931 |
|
2932 |
$args = array(
|
2933 |
'numberposts' => '-1',
|
3539 |
if ( is_file($thumbnailfilename[$i]) )
|
3540 |
kgvid_schedule_cleanup_generated_files('thumbs');
|
3541 |
|
3542 |
+
$thumbnaildisplaycode = '<div class="kgvid_thumbnail_select" name="attachments['.$postID.'][thumb'.$i.']" id="attachments-'.$postID.'-thumb'.$i.'"><label for="kgflashmedia-'.$postID.'-thumbradio'.$i.'"><img src="'.$thumbnailurl.'?'.rand().'" width="200" height="'.$thumbnailheight.'" class="kgvid_thumbnail"></label><br /><input type="radio" name="attachments['.$postID.'][thumbradio'.$i.']" id="kgflashmedia-'.$postID.'-thumbradio'.$i.'" value="'.str_replace('/thumb_tmp/', '/', $thumbnailurl).'" onchange="kgvid_select_thumbnail(this.value, \''.$postID.'\', '.$movieoffset.');"></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3543 |
|
3544 |
$i++;
|
3545 |
|
3918 |
|
3919 |
function kgvid_ajax_encode_videos() {
|
3920 |
|
3921 |
+
check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
|
3922 |
+
global $wpdb;
|
3923 |
+
$arr = kgvid_encode_videos();
|
3924 |
+
echo json_encode($arr);
|
3925 |
+
die();
|
3926 |
|
3927 |
}
|
3928 |
add_action('wp_ajax_kgvid_ajax_encode_videos', 'kgvid_ajax_encode_videos');
|
3930 |
function kgvid_test_ffmpeg() {
|
3931 |
|
3932 |
check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
|
3933 |
+
$options = get_option('kgvid_video_embed_options');
|
3934 |
+
$uploads = wp_upload_dir();
|
3935 |
+
|
3936 |
$cmd = $_POST['command'];
|
3937 |
$cmd=escapeshellcmd(stripcslashes($cmd));
|
3938 |
exec ( $cmd.' 2>&1', $output );
|
3939 |
+
$output = implode("\n", $output);
|
3940 |
+
|
3941 |
+
|
3942 |
+
|
3943 |
+
if ( file_exists($uploads['path']."/sample-video-h264-480p.mp4") ) {
|
3944 |
+
|
3945 |
+
if ( $options['moov'] == "qt-faststart" || $options['moov'] == "MP4Box" ) {
|
3946 |
+
$output .= kgvid_fix_moov_atom($uploads['path']."/sample-video-h264-480p.mp4");
|
3947 |
+
}
|
3948 |
+
|
3949 |
+
unlink($uploads['path']."/sample-video-h264-480p.mp4");
|
3950 |
+
|
3951 |
+
}
|
3952 |
+
|
3953 |
+
echo $output;
|
3954 |
die;
|
3955 |
|
3956 |
}
|
4077 |
$time_elapsed = $ended - $started;
|
4078 |
$time_remaining = "0";
|
4079 |
$fps_match = "10";
|
4080 |
+
if ( array_key_exists(1, $libx264_matches) ) { $moov_output = kgvid_fix_moov_atom($video_embed_queue[$video_key]['encode_formats'][$format]['filepath']); } //fix the moov atom if the file was encoded by libx264
|
4081 |
$video_embed_queue[$video_key]['encode_formats'][$format]['status'] = "Encoding Complete";
|
4082 |
$video_embed_queue[$video_key]['encode_formats'][$format]['ended'] = $ended;
|
4083 |
$video_embed_queue[$video_key]['encode_formats'][$format]['lastline'] = $lastline;
|
4346 |
}
|
4347 |
add_action('kgvid_cleanup_queue', 'kgvid_cleanup_queue_handler');
|
4348 |
|
4349 |
+
function kgvid_fix_moov_atom($filepath) {
|
4350 |
|
4351 |
$options = get_option('kgvid_video_embed_options');
|
4352 |
+
$output = "";
|
4353 |
|
4354 |
if ( $options['moov'] == "qt-faststart" || $options['moov'] == "MP4Box" ) {
|
4355 |
|
4356 |
+
$output = "\nFixing moov atom for streaming";
|
|
|
4357 |
|
4358 |
if ( $options['moov'] == 'qt-faststart' && file_exists($filepath) ) {
|
4359 |
+
$faststart_tmp_file = str_replace('.mp4', '-faststart.mp4', $filepath);
|
4360 |
$cmd = escapeshellcmd($options['app_path']."/".$options['moov']." ".$filepath." ".$faststart_tmp_file);
|
4361 |
+
$output .= "\n".$cmd."\n";
|
4362 |
+
exec($cmd, $qtfaststart_output, $returnvalue);
|
4363 |
+
$output .= implode("\n", $qtfaststart_output);
|
4364 |
if ( file_exists($faststart_tmp_file) ) {
|
4365 |
unlink($filepath);
|
4366 |
rename($faststart_tmp_file, $filepath);
|
4369 |
|
4370 |
if ( $options['moov'] == 'MP4Box' ) {
|
4371 |
$cmd = escapeshellcmd($options['app_path']."/".$options['moov']." -inter 500 ".$filepath);
|
4372 |
+
$output .= "\n".$cmd."\n";
|
4373 |
+
exec($cmd, $mp4box_output, $returnvalue);
|
4374 |
+
$output .= implode("\n", $mp4box_output);
|
4375 |
}//if MP4Box is selected
|
4376 |
|
4377 |
}//if there is an application selected for fixing moov atoms on libx264-encoded files.
|
4378 |
|
4379 |
+
return $output;
|
4380 |
+
|
4381 |
}
|
4382 |
|
4383 |
function kgvid_cancel_encode() {
|