Video Embed & Thumbnail Generator - Version 3.1

Version Description

  • January 30, 2013 =
  • Added video watermark overlay option. (Video.js only)
  • Changed front-end CSS file name to kgvid_styles.css and made it always available, not just when galleries are on the page.
  • Removed my watermark testing logo which was accidentally inserted above videos in version 3.0.3.
  • Added option to choose -b:v or legacy -b flags when encoding. Recent FFMPEG versions only accept -b:v.
  • Added automatic encode queue cleanup. Any completed entry older than a week will be removed.
  • Added deactivation hook to remove queue and scheduled queue cleanup on deactivation.
  • Added uninstall.php to remove settings from the database on uninstall.
  • Disabled "Delete Permanently" link while encoding is canceling.
  • Checked for escapeshellcmd. If it's disabled on the server, encoding can't start.
  • Fixed insert title and download link checkboxes. They will actually insert something now.
  • Changed method for determining if a video has been played or paused and played again, for counting purposes.
  • Fixed check for mime type when generating H.264 video encode checkboxes to avoid showing options for QuickTime files that are higher resolution than the original video.
Download this release

Release Info

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

Code changes from version 3.0.3 to 3.1

css/{kgvid_video_gallery.css → kgvid_styles.css} RENAMED
@@ -1,3 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  .kgvid_video_gallery_thumb {
2
  position: relative;
3
  display:inline-block;
1
+ div.kgvid_watermark {
2
+ display: block;
3
+ position: absolute;
4
+ bottom: 10px;
5
+ right: 10px;
6
+ z-index: 1001;
7
+ margin: 0px;
8
+ }
9
+
10
+ .vjs-controls {
11
+ z-index:1002;
12
+ }
13
+
14
  .kgvid_video_gallery_thumb {
15
  position: relative;
16
  display:inline-block;
index.html ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
+ <HTML>
3
+
4
+ <HEAD>
5
+ <TITLE>Access Denied</TITLE>
6
+ </HEAD>
7
+
8
+ <BODY>
9
+ <br/><b>This folder is not web accessible.</b><br/>
10
+ </BODY>
11
+
12
+ </HTML>
js/kgvid_video_embed.js CHANGED
@@ -1,49 +1,20 @@
1
- function kgvid_set_mp4_src(mp4_srcs) {
2
-
3
- var player = _V_('video_'+mp4_srcs.id);
4
-
5
- var support_1080 = false;
6
- var support_720 = false;
7
-
8
- if ( screen.width >= 1080 || screen.height >= 1080 ) { support_1080 = true; support_720 = true; }
9
- else if ( screen.width >= 960 || screen.height >= 960 ) { support_720 = true; support_1080 = false; }
10
- else if ( screen.width < 960 && screen.height < 960 ) { support_1080 = false; support_720 = false; }
11
-
12
- if ( support_1080 == true ) {
13
- if ( typeof(mp4_srcs.src_original) != undefined ) { }
14
- else if ( typeof(mp4_srcs.src_1080) != undefined ) { player.src({ type: "video/mp4", src: mp4_srcs.src_1080 }); }
15
- else if ( typeof(mp4_srcs.src_720) != undefined ) { player.src({ type: "video/mp4", src: mp4_srcs.src_720 }); }
16
- }
17
-
18
- if ( support_720 == true && support_1080 == false ) {
19
- if ( typeof(mp4_srcs.src_720) != undefined ) { player.src({ type: "video/mp4", src: mp4_srcs.src_720 }); }
20
- }
21
-
22
- if ( support_720 == false && support_1080 == false ) {
23
- if ( typeof(mp4_srcs.mobile) != undefined ) { player.src({ type: "video/mp4", src: mp4_srcs.src_mobile }); }
24
- }
25
- alert (support_720);
26
- }
27
-
28
  function kgvid_SetVideo(source, width, height) {
29
  jQuery('#kgvid_GalleryVideo').attr('src', source);
30
  jQuery('#kgvid_GalleryVideo').attr('width', parseInt(width)+20);
31
  jQuery('#kgvid_GalleryVideo').attr('height', parseInt(height)+20);
32
  jQuery('#kgvid_GalleryPlayerDiv').dialog("option", "width", parseInt(width)+30);
33
  jQuery('#kgvid_GalleryPlayerDiv').closest('.ui-dialog').height(parseInt(height))
34
- //jQuery('#kgvid_GalleryPlayerDiv').dialog("option", "height", parseInt(height)+30);
35
  jQuery('#kgvid_GalleryPlayerDiv').dialog('open');
36
  jQuery('.ui-widget-overlay').click(function () { jQuery('#kgvid_GalleryPlayerDiv').dialog('close'); });
37
  }
38
 
39
  function kgvid_video_counter(id, plays, ends, event) {
40
 
41
- //var player = _V_('video_'+id)
42
- //if ( player.currentTime() > 1 ) { alert ("Count"); }
43
  var changed = false;
44
 
45
  if (plays != "not_countable" ) { //video is in the db
46
- if ( document.getElementById(id+'_played').value == 'not_played' ) { plays++; changed = true; }
 
47
  if ( event == "ended" ) { ends++; changed = true; }
48
  if ( changed == true ) {
49
  jQuery.post(ajax_object.ajaxurl, {
@@ -52,11 +23,10 @@ function kgvid_video_counter(id, plays, ends, event) {
52
  video_plays: plays,
53
  complete_views: ends
54
  }, function(data) {
55
- //alert(data);
56
  });
57
  }
58
  }
59
 
60
- document.getElementById(id+'_played').value = 'played';
61
 
62
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  function kgvid_SetVideo(source, width, height) {
2
  jQuery('#kgvid_GalleryVideo').attr('src', source);
3
  jQuery('#kgvid_GalleryVideo').attr('width', parseInt(width)+20);
4
  jQuery('#kgvid_GalleryVideo').attr('height', parseInt(height)+20);
5
  jQuery('#kgvid_GalleryPlayerDiv').dialog("option", "width", parseInt(width)+30);
6
  jQuery('#kgvid_GalleryPlayerDiv').closest('.ui-dialog').height(parseInt(height))
 
7
  jQuery('#kgvid_GalleryPlayerDiv').dialog('open');
8
  jQuery('.ui-widget-overlay').click(function () { jQuery('#kgvid_GalleryPlayerDiv').dialog('close'); });
9
  }
10
 
11
  function kgvid_video_counter(id, plays, ends, event) {
12
 
 
 
13
  var changed = false;
14
 
15
  if (plays != "not_countable" ) { //video is in the db
16
+ var played = jQuery('#video_'+id+'_div').data("played") || "not played";
17
+ if ( played == "not played" ) { plays++; changed = true; console.log("Played") }
18
  if ( event == "ended" ) { ends++; changed = true; }
19
  if ( changed == true ) {
20
  jQuery.post(ajax_object.ajaxurl, {
23
  video_plays: plays,
24
  complete_views: ends
25
  }, function(data) {
 
26
  });
27
  }
28
  }
29
 
30
+ jQuery('#video_'+id+'_div').data("played", "played");
31
 
32
  }
js/kgvid_video_plugin_admin.js CHANGED
@@ -358,11 +358,13 @@ function kgvid_encode_queue(action, order) {
358
  function kgvid_hide_plugin_settings(selected_option) {
359
  if (selected_option == "Video.js") {
360
  jQuery("table:contains(End of video image)").hide();
 
361
  jQuery("h3:contains(The following options will only affect Flash playback)").hide();
362
  jQuery("tr:contains(Skin Class)").show();
363
  }
364
  if (selected_option == "Strobe Media Playback") {
365
  jQuery("table:contains(End of video image)").show();
 
366
  jQuery("h3:contains(The following options will only affect Flash playback)").show();
367
  jQuery("tr:contains(Skin Class)").hide();
368
  }
358
  function kgvid_hide_plugin_settings(selected_option) {
359
  if (selected_option == "Video.js") {
360
  jQuery("table:contains(End of video image)").hide();
361
+ jQuery("tr:contains(Watermark)").show();
362
  jQuery("h3:contains(The following options will only affect Flash playback)").hide();
363
  jQuery("tr:contains(Skin Class)").show();
364
  }
365
  if (selected_option == "Strobe Media Playback") {
366
  jQuery("table:contains(End of video image)").show();
367
+ jQuery("tr:contains(Watermark)").hide();
368
  jQuery("h3:contains(The following options will only affect Flash playback)").show();
369
  jQuery("tr:contains(Skin Class)").hide();
370
  }
license.txt ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kyleg
4
  Tags: video, video gallery, html5, shortcode, thumbnail, ffmpeg, libav, embed, mobile, webm, ogg, h.264
5
  Requires at least: 3.5
6
  Tested up to: 3.5.1
7
- Stable tag: 3.0.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -60,6 +60,7 @@ width="720" height="404"]http://www.kylegilman.net/wp-content/uploads/2011/10/Re
60
 
61
  = These options will only affect Video.js playback =
62
 
 
63
  * `skin="example-css-class"` Completely change the look of the video player. <a href="https://github.com/zencoder/video-js/blob/master/docs/skins.md">Instructions here.</a>
64
  * `volume="0.5"` Pre-set the volume for unusually loud videos. Value between 0 and 1.
65
 
@@ -126,13 +127,27 @@ Use the "Embed from URL" tab. Use the format http://username:password@yourdomain
126
 
127
  == Changelog ==
128
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  = 3.0.3 - January 29, 2013 =
130
  * Fixed bug that added a blank line to JavaScript embedded in the page if "volume" wasn't set in the short code (Video.js only).
131
  * If video player is set larger than the containing DIV and the player size is reduced to fit, the height is now rounded to the nearest integer.
132
 
133
  = 3.0.2 - January 24, 2013 =
134
  * Fixed bug that permanently disabled buttons on the Embed Video from URL tab.
135
- * Disabled "Delete Permanently" link for encoded files found on other servers.
136
  * Reduced the jQuery UI Dialog css and put it in its own scope to avoid conflicts with existing jQuery UI Dialog themes.
137
  * Cleaned out some leftover code.
138
 
4
  Tags: video, video gallery, html5, shortcode, thumbnail, ffmpeg, libav, embed, mobile, webm, ogg, h.264
5
  Requires at least: 3.5
6
  Tested up to: 3.5.1
7
+ Stable tag: 3.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
60
 
61
  = These options will only affect Video.js playback =
62
 
63
+ * `watermark="http://www.example.com/image.png"` sets watermark for video. Overrides default watermark in plugin settings.
64
  * `skin="example-css-class"` Completely change the look of the video player. <a href="https://github.com/zencoder/video-js/blob/master/docs/skins.md">Instructions here.</a>
65
  * `volume="0.5"` Pre-set the volume for unusually loud videos. Value between 0 and 1.
66
 
127
 
128
  == Changelog ==
129
 
130
+ = 3.1 - January 30, 2013 =
131
+ * Added video watermark overlay option. (Video.js only)
132
+ * Changed front-end CSS file name to kgvid_styles.css and made it always available, not just when galleries are on the page.
133
+ * Removed my watermark testing logo which was accidentally inserted above videos in version 3.0.3.
134
+ * Added option to choose -b:v or legacy -b flags when encoding. Recent FFMPEG versions only accept -b:v.
135
+ * Added automatic encode queue cleanup. Any completed entry older than a week will be removed.
136
+ * Added deactivation hook to remove queue and scheduled queue cleanup on deactivation.
137
+ * Added uninstall.php to remove settings from the database on uninstall.
138
+ * Disabled "Delete Permanently" link while encoding is canceling.
139
+ * Checked for escapeshellcmd. If it's disabled on the server, encoding can't start.
140
+ * Fixed insert title and download link checkboxes. They will actually insert something now.
141
+ * Changed method for determining if a video has been played or paused and played again, for counting purposes.
142
+ * Fixed check for mime type when generating H.264 video encode checkboxes to avoid showing options for QuickTime files that are higher resolution than the original video.
143
+
144
  = 3.0.3 - January 29, 2013 =
145
  * Fixed bug that added a blank line to JavaScript embedded in the page if "volume" wasn't set in the short code (Video.js only).
146
  * If video player is set larger than the containing DIV and the player size is reduced to fit, the height is now rounded to the nearest integer.
147
 
148
  = 3.0.2 - January 24, 2013 =
149
  * Fixed bug that permanently disabled buttons on the Embed Video from URL tab.
150
+ * Disabled "Delete Permanently" option for encoded files found on other servers.
151
  * Reduced the jQuery UI Dialog css and put it in its own scope to avoid conflicts with existing jQuery UI Dialog themes.
152
  * Cleaned out some leftover code.
153
 
uninstall.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) { exit (); }
3
+ delete_option('kgvid_video_embed_options');
4
+ ?>
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/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: 3.0.3
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
 
@@ -41,7 +41,7 @@ if ( ! defined( 'ABSPATH' ) )
41
  die( "Can't load this file directly" );
42
 
43
  function kgvid_default_options_fn() {
44
- $options = array("version"=>3.0,
45
  "embed_method"=>"Video.js",
46
  "template"=>false,
47
  "encode_1080"=>"on",
@@ -52,11 +52,13 @@ function kgvid_default_options_fn() {
52
  "app_path"=>"/usr/local/bin",
53
  "video_app" => "ffmpeg",
54
  "ffmpeg_exists"=>"notchecked",
 
55
  "ffmpeg_vpre"=>false,
56
  "moov"=>"none",
57
  "generate_thumbs"=>4,
58
  "titlecode"=>"<strong>",
59
  "poster"=>"",
 
60
  "width"=>"640",
61
  "height"=>"360",
62
  "gallery_width"=>"960",
@@ -174,8 +176,6 @@ function kgvid_check_ffmpeg_exists($options, $save) {
174
 
175
  if(function_exists('exec')) {
176
  $exec_enabled = true;
177
- //$plugin_url = plugins_url("", __FILE__);
178
- //$plugin_url = str_replace("https://", "http://", $plugin_url);
179
  exec ( $options['app_path'].'/'.$options['video_app'].' -i '.plugin_dir_path(__FILE__).'/flash/skin/images/PlayNormal.png '.$uploads['path'].'/ffmpeg_exists_test.jpg', $output, $returnvalue );
180
  }
181
 
@@ -282,7 +282,7 @@ function kgvid_get_video_dimensions($video = false) {
282
 
283
  $video = str_replace("https://", "http://", $video);
284
 
285
- $command = $ffmpegPath . ' -i "' . $video . '" -codecs 2>&1';
286
 
287
  exec ( $command, $output );
288
  $lastline = end($output);
@@ -300,13 +300,16 @@ function kgvid_get_video_dimensions($video = false) {
300
  preg_match('/rotate : (.*?)\n/', $output, $matches);
301
  if ( array_key_exists(1, $matches) == true ) { $rotate = $matches[1]; }
302
  else $rotate = "0";
 
 
 
 
303
  $configuration = array();
304
  $lib_list = array('libfaac', 'libvo_aacenc', 'libtheora', 'libvorbis', 'libvpx', 'libx264');
305
  foreach ($lib_list as $lib) {
306
  if ( strpos($output, $lib) !== false ) { $configuration[$lib] = "true"; }
307
  else { $configuration[$lib] = "false"; }
308
  }
309
-
310
  return array ('width' => $width, 'height' => $height, 'duration' => $duration, 'configuration' => $configuration, 'rotate' => $rotate, 'worked'=>true );
311
  } else {
312
  return array ('output'=>$lastline, 'worked'=>false);
@@ -374,6 +377,7 @@ class kgvid_Process{
374
 
375
  function kgvid_video_embed_enqueue_scripts() {
376
  $options = get_option('kgvid_video_embed_options');
 
377
  if ( $options['embed_method'] == "Strobe Media Playback" ) {
378
  wp_enqueue_script( 'swfobject' );
379
  }
@@ -384,6 +388,7 @@ function kgvid_video_embed_enqueue_scripts() {
384
  wp_enqueue_style( 'video-js-kg-skin', plugins_url("", __FILE__).'/video-js/kg-video-js-skin.css' );
385
  }
386
 
 
387
  wp_enqueue_script( 'jquery-ui-dialog' );
388
  wp_enqueue_script( 'kgvid_video_embed', plugins_url("", __FILE__).'/js/kgvid_video_embed.js' );
389
  wp_localize_script( 'kgvid_video_embed', 'ajax_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); // setting ajaxurl
@@ -414,6 +419,7 @@ function KGVID_shortcode($atts, $content = ''){
414
  'controlbar' => $options['controlbar_style'],
415
  'autohide' => $options['autohide'],
416
  'poster' => $options['poster'],
 
417
  'endOfVideoOverlay' => $options['endOfVideoOverlay'],
418
  'endOfVideoOverlaySame' => $options['endOfVideoOverlaySame'],
419
  'playbutton' => $options['playbutton'],
@@ -531,10 +537,6 @@ function KGVID_shortcode($atts, $content = ''){
531
 
532
  $code = "";
533
 
534
- if ($id !="") {
535
- if ( !empty($attachment_info->post_excerpt) ) { $code .= '<div id="attachment_'.$id.'" class="wp-caption alignnone">'; }
536
- }
537
-
538
  $code .= "<div id=\"video_".$div_suffix."_div\" class=\"kgvid_videodiv\">";
539
  $code .= "<video id=\"video_".$div_suffix."\" ";
540
  if ($query_atts["loop"] == 'true') { $code .= "loop " ;}
@@ -580,9 +582,10 @@ function KGVID_shortcode($atts, $content = ''){
580
  }
581
  $aspect_ratio = round($query_atts["height"] / $query_atts["width"], 3);
582
 
583
- $code .= "<input type='hidden' id='".$div_suffix."_played' value='not_played'><script type='text/javascript'>
584
- _V_('video_".$div_suffix."').ready(function(){
585
- var width = document.getElementById(this.id).parentElement.offsetWidth;
 
586
  if ( width < ".$query_atts["width"]." ) { this.width(width).height( Math.round(width * ".$aspect_ratio.") ); }";
587
  if ( !empty($query_atts["volume"]) ) { $code .= "\n\t\t\t"."this.volume(".$query_atts['volume'].");"."\n\t\t\t"; }
588
  $code .= "this.addEvent('play', function(){
@@ -597,12 +600,12 @@ function KGVID_shortcode($atts, $content = ''){
597
  </script>\n";
598
  }
599
 
600
- if ($id !="") {
601
  $iframeurl = site_url('/')."?attachment_id=".$id;
602
  $iframecode = '<iframe src="'.$iframeurl.'" frameborder="0" scrolling="no" width="'.$query_atts['width'].'" height="'.$query_atts["height"].'"></iframe>';
603
  $code .= "<div class='kgvid_embed_code' type='text' value='".$iframecode."' width='10' onClick='this.select();'></div>\n";
604
  if ( !empty($attachment_info->post_excerpt) ) { $code .= '<p class="wp-caption-text">'.$attachment_info->post_excerpt.'</p></div>'; }
605
- }
606
 
607
  if ( in_array($moviefiletype, $flashcompatible) && $options['embed_method'] == "Strobe Media Playback" ) {
608
  $code .= "<script type=\"text/javascript\">\n\t";
@@ -635,7 +638,6 @@ function KGVID_shortcode($atts, $content = ''){
635
  }
636
  $code .= '<div id="kgvid_GalleryPlayerDiv"><iframe id="kgvid_GalleryVideo" src="" width="640" height="360" frameborder="0" webkitallowfullscreen="" allowfullscreen=""></iframe></div>';
637
  $code .= '<script type="text/javascript">jQuery(document).ready(function() {
638
- jQuery(\'head\').append(\'<link rel="stylesheet" href="'.plugins_url("", __FILE__).'/css/kgvid_video_gallery.css" type="text/css" />\');
639
  jQuery(\'#kgvid_GalleryPlayerDiv\').dialog({
640
  zIndex: 10000,
641
  autoOpen: false,
@@ -710,13 +712,14 @@ function kgvid_generate_encode_checkboxes($movieurl, $post_id, $page) {
710
 
711
  if ( is_numeric($post_id) ) {
712
  $post_mime_type = get_post_mime_type($post_id);
 
713
  $actualwidth = get_post_meta($post_id, "_kgflashmediaplayer-actualwidth", true);
714
  $actualheight = get_post_meta($post_id, "_kgflashmediaplayer-actualheight", true);
715
  }
716
  else {
717
 
718
  $post_mime_type = pathinfo($movieurl, PATHINFO_EXTENSION);
719
- if ( $post_mime_type == "m4v" ) { $post_mime_type = "mp4"; }
720
 
721
  if ( !empty($video_embed_queue) ) {
722
  foreach ($video_embed_queue as $video_key => $video_entry) {
@@ -786,7 +789,7 @@ function kgvid_generate_encode_checkboxes($movieurl, $post_id, $page) {
786
  if ( $encodevideo_info[$format.'_exists'] ) { //if the video file exists
787
  if ( $format_stats['status'] != "encoding" ) { // not currently encoding
788
  if ( $format_stats['status'] == "notchecked" ) { $meta[$format] = ' <strong>Encoded</strong>'; }
789
- $meta[$format] .= '<a id="delete-'.$post_id.'-'.$format.'" class="kgvid_delete-format" onclick="kgvid_delete_video(\''.$movieurl.'\', \''.$post_id.'\', \''.$format.'\');" href="javascript:void(0)">Delete Permanently</a>';
790
  $disabled[$format] = ' disabled title="Format already exists"';
791
  $checked[$format] = '';
792
  }
@@ -991,7 +994,8 @@ function kgvid_FMPOptionsPage() {
991
  <?php settings_fields('kgvid_video_embed_options'); ?>
992
  <?php do_settings_sections(__FILE__); ?>
993
  <p class='submit'>
994
- <?php submit_button('Save Changes', 'primary', 'submit', false); submit_button('Reset Options', 'secondary', 'video-embed-thumbnail-generator-reset', false); ?>
 
995
  </p>
996
  </form>
997
  <script type="text/javascript">
@@ -1023,11 +1027,13 @@ function kgvid_video_embed_options_init() {
1023
  add_settings_field('encode_formats', 'Default Mobile/HTML5 Video encode formats:', 'kgvid_encode_formats_callback', __FILE__, 'kgvid_video_embed_plugin_settings');
1024
  add_settings_field('app_path', 'Path to applications on server:', 'kgvid_app_path_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'app_path' ) );
1025
  add_settings_field('video_app', 'Application for thumbnails & encoding:', 'kgvid_video_app_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'video_app' ) );
 
1026
  add_settings_field('ffmpeg_vpre', 'FFMPEG Options:', 'kgvid_ffmpeg_vpre_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'ffmpeg_vpre' ) );
1027
  add_settings_field('moov', 'Application to fix encoded H.264 headers for streaming:', 'kgvid_moov_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'moov' ) );
1028
  add_settings_field('generate_thumbs', 'Default number of thumbnails to generate:', 'kgvid_generate_thumbs_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'generate_thumbs' ) );
1029
  add_settings_field('titlecode', 'Video Title Text HTML Formatting:', 'kgvid_titlecode_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'titlecode' ) );
1030
  add_settings_field('poster', 'Poster image:', 'kgvid_poster_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'poster' ) );
 
1031
  add_settings_field('width', 'Max video width:', 'kgvid_width_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'width' ) );
1032
  add_settings_field('height', 'Max video height:', 'kgvid_height_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'height' ) );
1033
  add_settings_field('gallery_width', 'Max gallery video width:', 'kgvid_gallery_width_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'gallery_width' ) );
@@ -1100,6 +1106,14 @@ function kgvid_update_settings() {
1100
 
1101
  update_option('kgvid_video_embed_options', $options);
1102
  }
 
 
 
 
 
 
 
 
1103
  }
1104
  add_action('init', 'kgvid_update_settings' );
1105
 
@@ -1183,6 +1197,11 @@ function kgvid_video_embed_options_validate($input) { //validate & sanitize inpu
1183
  echo "</select> <a class='kgvid_tooltip' href='#'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>FFMPEG split into two separate branches in 2011. The new branch is called LIBAV. Both are still actively developed. Debian & Ubuntu users probably have LIBAV installed.</span></a>";
1184
  }
1185
 
 
 
 
 
 
1186
  function kgvid_ffmpeg_vpre_callback() {
1187
  $options = get_option('kgvid_video_embed_options');
1188
  echo "<input ".checked( $options['ffmpeg_vpre'], "on", false )." id='ffmpeg_vpre' name='kgvid_video_embed_options[ffmpeg_vpre]' type='checkbox' /> <label for='ffmpeg_vpre'>Enable FFMPEG 'vpre' flags.</label> <a class='kgvid_tooltip' href='#'><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 vpre flags 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 will cause newer versions of FFMPEG to fail and probably won't work on Windows servers.</span></a>";
@@ -1214,6 +1233,11 @@ function kgvid_video_embed_options_validate($input) { //validate & sanitize inpu
1214
  echo "<input id='poster' name='kgvid_video_embed_options[poster]' size='60' type='text' value='".$options['poster']."' />";
1215
  }
1216
 
 
 
 
 
 
1217
  function kgvid_width_callback() {
1218
  $options = get_option('kgvid_video_embed_options');
1219
  echo "<input id='width' name='kgvid_video_embed_options[width]' size='5' type='text' value='".$options['width']."' />";
@@ -1672,7 +1696,7 @@ class kgInsertMedia {
1672
  $attachment['poster'] = get_post_meta($attachment_id, "_kgflashmediaplayer-poster", true);
1673
  $attachment['width'] = get_post_meta($attachment_id, "_kgflashmediaplayer-width", true);
1674
  $attachment['height'] = get_post_meta($attachment_id, "_kgflashmediaplayer-height", true);
1675
- $attachment['downloadlink'] = get_post_meta($attachment_id, "_kgflashmediaplayer-download", true);
1676
  $attachment['showtitle'] = get_post_meta($attachment_id, "_kgflashmediaplayer-showtitle", true);
1677
  if ($attachment['showtitle'] =="checked") {
1678
  $titlecode = html_entity_decode(stripslashes($options['titlecode']));
@@ -1910,12 +1934,6 @@ function kgvid_schedule_cleanup_generated_files() { //schedules deleting all tmp
1910
  wp_schedule_single_event(time()+600, 'kgvid_cleanup_generated_logfiles', $args);
1911
  }
1912
 
1913
- if (isset($_POST['queue'])) {
1914
- $timestamp = wp_next_scheduled( 'kgvid_cleanup_queue' );
1915
- wp_unschedule_event($timestamp, 'kgvid_cleanup_queue' );
1916
- wp_schedule_single_event(time()+86400, 'kgvid_cleanup_queue');
1917
- }
1918
-
1919
  die(); // this is required to return a proper result
1920
  }
1921
  add_action('wp_ajax_kgvid_schedule_cleanup_generated_files', 'kgvid_schedule_cleanup_generated_files');
@@ -2217,12 +2235,12 @@ function kgvid_encode_videos() {
2217
 
2218
  if ( ! file_exists($encodevideo_info['encodepath']) ) { mkdir($encodevideo_info['encodepath']); }
2219
 
2220
- if ( $options['video_app'] == "avconv" ) {
2221
  $video_bitrate_flag = "b:v";
2222
  $audio_bitrate_flag = "b:a";
2223
  }
2224
 
2225
- if ( $options['video_app'] == "ffmpeg" ) {
2226
  $video_bitrate_flag = "b";
2227
  $audio_bitrate_flag = "ab";
2228
  }
@@ -2305,8 +2323,11 @@ function kgvid_encode_videos() {
2305
  $logfile = $encodevideo_info['encodepath'].str_replace(" ", "_", $encodevideo_info['moviefilebasename'])."_".$queued_format."_".sprintf("%04s",mt_rand(1, 1000))."_encode.txt";
2306
 
2307
  $cmd = escapeshellcmd($ffmpegPath." ".$ffmpeg_args);
2308
- $cmd = $cmd." > ".$logfile." 2>&1 & echo $!";
2309
-
 
 
 
2310
  $process = new kgvid_Process($cmd);
2311
 
2312
  sleep(1);
@@ -2316,6 +2337,9 @@ function kgvid_encode_videos() {
2316
 
2317
  $args = array('logfile'=>$logfile);
2318
  wp_schedule_single_event(time()+600, 'kgvid_cleanup_generated_logfiles', $args);
 
 
 
2319
 
2320
  //update_post_meta($video['attachmentID'], '_kgflashmediaplayer-encode'.$format, 'on');
2321
 
@@ -2337,10 +2361,8 @@ function kgvid_encode_videos() {
2337
  );
2338
 
2339
  $video_embed_queue[$video_key] = $queue_entry;
2340
-
2341
- //$encoding = $video['encode_formats'][$queued_format];
2342
 
2343
- //$embed_display .= " <em><small>".$cmd."</small></em>";
2344
 
2345
  } //end if there's stuff to encode
2346
 
@@ -2526,7 +2548,7 @@ function kgvid_ajax_encode_progress() {
2526
  }
2527
  add_action('wp_ajax_kgvid_encode_progress', 'kgvid_ajax_encode_progress');
2528
 
2529
- function kgvid_clear_completed_queue() {
2530
 
2531
  $video_embed_queue = get_option('kgvid_video_embed_queue');
2532
 
@@ -2542,6 +2564,12 @@ function kgvid_clear_completed_queue() {
2542
  $keep[$video_key] = true;
2543
  break;
2544
  }
 
 
 
 
 
 
2545
  }
2546
  }
2547
  }
@@ -2561,7 +2589,7 @@ function kgvid_ajax_clear_completed_queue() {
2561
 
2562
  check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
2563
  global $wpdb;
2564
- kgvid_clear_completed_queue();
2565
  $table = kgvid_generate_queue_table();
2566
  echo ($table);
2567
  die();
@@ -2587,6 +2615,11 @@ function kgvid_ajax_clear_queue_entry() {
2587
  }
2588
  add_action('wp_ajax_kgvid_clear_queue_entry', 'kgvid_ajax_clear_queue_entry');
2589
 
 
 
 
 
 
2590
  function kgvid_fix_moov_atom($video_key, $format) {
2591
 
2592
  $options = get_option('kgvid_video_embed_options');
@@ -2609,10 +2642,7 @@ function kgvid_fix_moov_atom($video_key, $format) {
2609
  if ( $options['moov'] == 'MP4Box' ) {
2610
  $cmd = escapeshellcmd($options['app_path']."/".$options['moov']." -inter 500 ".$filepath);
2611
  exec($cmd);
2612
- }//if MP4Box is selected
2613
-
2614
- //$video_embed_queue[$video_key][$format]['status'] = "moov_fixed";
2615
- //update_option('kgvid_video_embed_options');
2616
 
2617
  }//if there is an application selected for fixing moov atoms on libx264-encoded files.
2618
 
@@ -2685,4 +2715,10 @@ function kgvid_count_play() {
2685
  die(); // stop executing script
2686
  }
2687
 
 
 
 
 
 
 
2688
  ?>
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/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: 3.1
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
 
41
  die( "Can't load this file directly" );
42
 
43
  function kgvid_default_options_fn() {
44
+ $options = array("version"=>3.1,
45
  "embed_method"=>"Video.js",
46
  "template"=>false,
47
  "encode_1080"=>"on",
52
  "app_path"=>"/usr/local/bin",
53
  "video_app" => "ffmpeg",
54
  "ffmpeg_exists"=>"notchecked",
55
+ "video_bitrate_flag"=>false,
56
  "ffmpeg_vpre"=>false,
57
  "moov"=>"none",
58
  "generate_thumbs"=>4,
59
  "titlecode"=>"<strong>",
60
  "poster"=>"",
61
+ "watermark"=>"",
62
  "width"=>"640",
63
  "height"=>"360",
64
  "gallery_width"=>"960",
176
 
177
  if(function_exists('exec')) {
178
  $exec_enabled = true;
 
 
179
  exec ( $options['app_path'].'/'.$options['video_app'].' -i '.plugin_dir_path(__FILE__).'/flash/skin/images/PlayNormal.png '.$uploads['path'].'/ffmpeg_exists_test.jpg', $output, $returnvalue );
180
  }
181
 
282
 
283
  $video = str_replace("https://", "http://", $video);
284
 
285
+ $command = $ffmpegPath . ' -i "' . $video . '" 2>&1';
286
 
287
  exec ( $command, $output );
288
  $lastline = end($output);
300
  preg_match('/rotate : (.*?)\n/', $output, $matches);
301
  if ( array_key_exists(1, $matches) == true ) { $rotate = $matches[1]; }
302
  else $rotate = "0";
303
+
304
+ $command = $ffmpegPath . ' -i "' . $video . '" -codecs 2>&1';
305
+ exec ( $command, $output );
306
+ $output = implode("\n", $output);
307
  $configuration = array();
308
  $lib_list = array('libfaac', 'libvo_aacenc', 'libtheora', 'libvorbis', 'libvpx', 'libx264');
309
  foreach ($lib_list as $lib) {
310
  if ( strpos($output, $lib) !== false ) { $configuration[$lib] = "true"; }
311
  else { $configuration[$lib] = "false"; }
312
  }
 
313
  return array ('width' => $width, 'height' => $height, 'duration' => $duration, 'configuration' => $configuration, 'rotate' => $rotate, 'worked'=>true );
314
  } else {
315
  return array ('output'=>$lastline, 'worked'=>false);
377
 
378
  function kgvid_video_embed_enqueue_scripts() {
379
  $options = get_option('kgvid_video_embed_options');
380
+
381
  if ( $options['embed_method'] == "Strobe Media Playback" ) {
382
  wp_enqueue_script( 'swfobject' );
383
  }
388
  wp_enqueue_style( 'video-js-kg-skin', plugins_url("", __FILE__).'/video-js/kg-video-js-skin.css' );
389
  }
390
 
391
+ wp_enqueue_style( 'kgvid_video_gallery', plugins_url("", __FILE__).'/css/kgvid_styles.css' );
392
  wp_enqueue_script( 'jquery-ui-dialog' );
393
  wp_enqueue_script( 'kgvid_video_embed', plugins_url("", __FILE__).'/js/kgvid_video_embed.js' );
394
  wp_localize_script( 'kgvid_video_embed', 'ajax_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); // setting ajaxurl
419
  'controlbar' => $options['controlbar_style'],
420
  'autohide' => $options['autohide'],
421
  'poster' => $options['poster'],
422
+ 'watermark' => $options['watermark'],
423
  'endOfVideoOverlay' => $options['endOfVideoOverlay'],
424
  'endOfVideoOverlaySame' => $options['endOfVideoOverlaySame'],
425
  'playbutton' => $options['playbutton'],
537
 
538
  $code = "";
539
 
 
 
 
 
540
  $code .= "<div id=\"video_".$div_suffix."_div\" class=\"kgvid_videodiv\">";
541
  $code .= "<video id=\"video_".$div_suffix."\" ";
542
  if ($query_atts["loop"] == 'true') { $code .= "loop " ;}
582
  }
583
  $aspect_ratio = round($query_atts["height"] / $query_atts["width"], 3);
584
 
585
+ $code .= "<script type='text/javascript'>
586
+ _V_('video_".$div_suffix."').ready(function(){";
587
+ if ( !empty($query_atts["watermark"]) ) { $code .= "\n\t\t\t"."jQuery('#video_".$div_suffix."').prepend(\"<div class='kgvid_watermark'><img src='".$query_atts["watermark"]."'></div>\");"."\n\t\t\t"; }
588
+ $code .= "var width = document.getElementById(this.id).parentElement.offsetWidth;
589
  if ( width < ".$query_atts["width"]." ) { this.width(width).height( Math.round(width * ".$aspect_ratio.") ); }";
590
  if ( !empty($query_atts["volume"]) ) { $code .= "\n\t\t\t"."this.volume(".$query_atts['volume'].");"."\n\t\t\t"; }
591
  $code .= "this.addEvent('play', function(){
600
  </script>\n";
601
  }
602
 
603
+ /* if ($id !="") {
604
  $iframeurl = site_url('/')."?attachment_id=".$id;
605
  $iframecode = '<iframe src="'.$iframeurl.'" frameborder="0" scrolling="no" width="'.$query_atts['width'].'" height="'.$query_atts["height"].'"></iframe>';
606
  $code .= "<div class='kgvid_embed_code' type='text' value='".$iframecode."' width='10' onClick='this.select();'></div>\n";
607
  if ( !empty($attachment_info->post_excerpt) ) { $code .= '<p class="wp-caption-text">'.$attachment_info->post_excerpt.'</p></div>'; }
608
+ } */
609
 
610
  if ( in_array($moviefiletype, $flashcompatible) && $options['embed_method'] == "Strobe Media Playback" ) {
611
  $code .= "<script type=\"text/javascript\">\n\t";
638
  }
639
  $code .= '<div id="kgvid_GalleryPlayerDiv"><iframe id="kgvid_GalleryVideo" src="" width="640" height="360" frameborder="0" webkitallowfullscreen="" allowfullscreen=""></iframe></div>';
640
  $code .= '<script type="text/javascript">jQuery(document).ready(function() {
 
641
  jQuery(\'#kgvid_GalleryPlayerDiv\').dialog({
642
  zIndex: 10000,
643
  autoOpen: false,
712
 
713
  if ( is_numeric($post_id) ) {
714
  $post_mime_type = get_post_mime_type($post_id);
715
+ if ( $post_mime_type == "video/m4v" || $post_mime_type == "video/quicktime" ) { $post_mime_type = "video/mp4"; }
716
  $actualwidth = get_post_meta($post_id, "_kgflashmediaplayer-actualwidth", true);
717
  $actualheight = get_post_meta($post_id, "_kgflashmediaplayer-actualheight", true);
718
  }
719
  else {
720
 
721
  $post_mime_type = pathinfo($movieurl, PATHINFO_EXTENSION);
722
+ if ( $post_mime_type == "m4v" || $post_mime_type == "mov" ) { $post_mime_type = "mp4"; }
723
 
724
  if ( !empty($video_embed_queue) ) {
725
  foreach ($video_embed_queue as $video_key => $video_entry) {
789
  if ( $encodevideo_info[$format.'_exists'] ) { //if the video file exists
790
  if ( $format_stats['status'] != "encoding" ) { // not currently encoding
791
  if ( $format_stats['status'] == "notchecked" ) { $meta[$format] = ' <strong>Encoded</strong>'; }
792
+ if ( $format_stats['status'] != "canceling" ) { $meta[$format] .= '<a id="delete-'.$post_id.'-'.$format.'" class="kgvid_delete-format" onclick="kgvid_delete_video(\''.$movieurl.'\', \''.$post_id.'\', \''.$format.'\');" href="javascript:void(0)">Delete Permanently</a>'; }
793
  $disabled[$format] = ' disabled title="Format already exists"';
794
  $checked[$format] = '';
795
  }
994
  <?php settings_fields('kgvid_video_embed_options'); ?>
995
  <?php do_settings_sections(__FILE__); ?>
996
  <p class='submit'>
997
+ <?php submit_button('Save Changes', 'primary', 'submit', false); ?>
998
+ <?php submit_button('Reset Options', 'secondary', 'video-embed-thumbnail-generator-reset', false); ?>
999
  </p>
1000
  </form>
1001
  <script type="text/javascript">
1027
  add_settings_field('encode_formats', 'Default Mobile/HTML5 Video encode formats:', 'kgvid_encode_formats_callback', __FILE__, 'kgvid_video_embed_plugin_settings');
1028
  add_settings_field('app_path', 'Path to applications on server:', 'kgvid_app_path_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'app_path' ) );
1029
  add_settings_field('video_app', 'Application for thumbnails & encoding:', 'kgvid_video_app_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'video_app' ) );
1030
+ add_settings_field('video_bitrate_flag', 'FFMPEG Options:', 'kgvid_video_bitrate_flag_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'video_bitrate_flag' ) );
1031
  add_settings_field('ffmpeg_vpre', 'FFMPEG Options:', 'kgvid_ffmpeg_vpre_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'ffmpeg_vpre' ) );
1032
  add_settings_field('moov', 'Application to fix encoded H.264 headers for streaming:', 'kgvid_moov_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'moov' ) );
1033
  add_settings_field('generate_thumbs', 'Default number of thumbnails to generate:', 'kgvid_generate_thumbs_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'generate_thumbs' ) );
1034
  add_settings_field('titlecode', 'Video Title Text HTML Formatting:', 'kgvid_titlecode_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'titlecode' ) );
1035
  add_settings_field('poster', 'Poster image:', 'kgvid_poster_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'poster' ) );
1036
+ add_settings_field('watermark', 'Watermark image:', 'kgvid_watermark_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'watermark' ) );
1037
  add_settings_field('width', 'Max video width:', 'kgvid_width_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'width' ) );
1038
  add_settings_field('height', 'Max video height:', 'kgvid_height_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'height' ) );
1039
  add_settings_field('gallery_width', 'Max gallery video width:', 'kgvid_gallery_width_callback', __FILE__, 'kgvid_video_embed_playback_settings', array( 'label_for' => 'gallery_width' ) );
1106
 
1107
  update_option('kgvid_video_embed_options', $options);
1108
  }
1109
+
1110
+ elseif ( $options['version'] < 3.1 ) {
1111
+ $options['version'] = 3.1;
1112
+ if ( $options['ffmpeg_vpre'] == "on" ) { $options['video_bitrate_flag'] = "on"; } //if user has ffmpeg_vpre turned on, they need the old bitrate flags too
1113
+ else { $options['video_bitrate_flag'] = false; }
1114
+ $options['watermark'] = "";
1115
+ update_option('kgvid_video_embed_options', $options);
1116
+ }
1117
  }
1118
  add_action('init', 'kgvid_update_settings' );
1119
 
1197
  echo "</select> <a class='kgvid_tooltip' href='#'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>FFMPEG split into two separate branches in 2011. The new branch is called LIBAV. Both are still actively developed. Debian & Ubuntu users probably have LIBAV installed.</span></a>";
1198
  }
1199
 
1200
+ function kgvid_video_bitrate_flag_callback() {
1201
+ $options = get_option('kgvid_video_embed_options');
1202
+ echo "<input ".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='#'><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 will cause newer versions of FFMPEG to fail.</span></a>";
1203
+ }
1204
+
1205
  function kgvid_ffmpeg_vpre_callback() {
1206
  $options = get_option('kgvid_video_embed_options');
1207
  echo "<input ".checked( $options['ffmpeg_vpre'], "on", false )." id='ffmpeg_vpre' name='kgvid_video_embed_options[ffmpeg_vpre]' type='checkbox' /> <label for='ffmpeg_vpre'>Enable FFMPEG 'vpre' flags.</label> <a class='kgvid_tooltip' href='#'><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 vpre flags 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 will cause newer versions of FFMPEG to fail and probably won't work on Windows servers.</span></a>";
1233
  echo "<input id='poster' name='kgvid_video_embed_options[poster]' size='60' type='text' value='".$options['poster']."' />";
1234
  }
1235
 
1236
+ function kgvid_watermark_callback() {
1237
+ $options = get_option('kgvid_video_embed_options');
1238
+ echo "<input id='watermark' name='kgvid_video_embed_options[watermark]' size='60' type='text' value='".$options['watermark']."' />";
1239
+ }
1240
+
1241
  function kgvid_width_callback() {
1242
  $options = get_option('kgvid_video_embed_options');
1243
  echo "<input id='width' name='kgvid_video_embed_options[width]' size='5' type='text' value='".$options['width']."' />";
1696
  $attachment['poster'] = get_post_meta($attachment_id, "_kgflashmediaplayer-poster", true);
1697
  $attachment['width'] = get_post_meta($attachment_id, "_kgflashmediaplayer-width", true);
1698
  $attachment['height'] = get_post_meta($attachment_id, "_kgflashmediaplayer-height", true);
1699
+ $attachment['downloadlink'] = get_post_meta($attachment_id, "_kgflashmediaplayer-downloadlink", true);
1700
  $attachment['showtitle'] = get_post_meta($attachment_id, "_kgflashmediaplayer-showtitle", true);
1701
  if ($attachment['showtitle'] =="checked") {
1702
  $titlecode = html_entity_decode(stripslashes($options['titlecode']));
1934
  wp_schedule_single_event(time()+600, 'kgvid_cleanup_generated_logfiles', $args);
1935
  }
1936
 
 
 
 
 
 
 
1937
  die(); // this is required to return a proper result
1938
  }
1939
  add_action('wp_ajax_kgvid_schedule_cleanup_generated_files', 'kgvid_schedule_cleanup_generated_files');
2235
 
2236
  if ( ! file_exists($encodevideo_info['encodepath']) ) { mkdir($encodevideo_info['encodepath']); }
2237
 
2238
+ if ( $options['video_app'] == "avconv" || $options['video_bitrate_flag'] == false ) {
2239
  $video_bitrate_flag = "b:v";
2240
  $audio_bitrate_flag = "b:a";
2241
  }
2242
 
2243
+ else {
2244
  $video_bitrate_flag = "b";
2245
  $audio_bitrate_flag = "ab";
2246
  }
2323
  $logfile = $encodevideo_info['encodepath'].str_replace(" ", "_", $encodevideo_info['moviefilebasename'])."_".$queued_format."_".sprintf("%04s",mt_rand(1, 1000))."_encode.txt";
2324
 
2325
  $cmd = escapeshellcmd($ffmpegPath." ".$ffmpeg_args);
2326
+ if ( !empty($cmd) ) { $cmd = $cmd." > ".$logfile." 2>&1 & echo $!"; }
2327
+ else {
2328
+ $arr = array ( "embed_display"=>"<span style='color:red;'>Error: Command escapeshellcmd is disabled.</span>" );
2329
+ return $arr;
2330
+ }
2331
  $process = new kgvid_Process($cmd);
2332
 
2333
  sleep(1);
2337
 
2338
  $args = array('logfile'=>$logfile);
2339
  wp_schedule_single_event(time()+600, 'kgvid_cleanup_generated_logfiles', $args);
2340
+ if ( !wp_next_scheduled( 'kgvid_cleanup_queue' ) ) {
2341
+ wp_schedule_event( time()+86400, 'daily', 'kgvid_cleanup_queue');
2342
+ }
2343
 
2344
  //update_post_meta($video['attachmentID'], '_kgflashmediaplayer-encode'.$format, 'on');
2345
 
2361
  );
2362
 
2363
  $video_embed_queue[$video_key] = $queue_entry;
 
 
2364
 
2365
+ //$embed_display .= "<script type='text/javascript'>alert('".$ffmpegPath." ".$ffmpeg_args."');</script>";
2366
 
2367
  } //end if there's stuff to encode
2368
 
2548
  }
2549
  add_action('wp_ajax_kgvid_encode_progress', 'kgvid_ajax_encode_progress');
2550
 
2551
+ function kgvid_clear_completed_queue($type) {
2552
 
2553
  $video_embed_queue = get_option('kgvid_video_embed_queue');
2554
 
2564
  $keep[$video_key] = true;
2565
  break;
2566
  }
2567
+ if ( $type == "scheduled" && $value['status'] == "Encoding Complete" ) {
2568
+ if ( time() - intval($value['ended']) < 604800 ) { //if it finished less than a week ago
2569
+ $keep[$video_key] = true;
2570
+ break;
2571
+ }
2572
+ }
2573
  }
2574
  }
2575
  }
2589
 
2590
  check_ajax_referer( 'video-embed-thumbnail-generator-nonce', 'security' );
2591
  global $wpdb;
2592
+ kgvid_clear_completed_queue('manual');
2593
  $table = kgvid_generate_queue_table();
2594
  echo ($table);
2595
  die();
2615
  }
2616
  add_action('wp_ajax_kgvid_clear_queue_entry', 'kgvid_ajax_clear_queue_entry');
2617
 
2618
+ function kgvid_cleanup_queue_handler() {
2619
+ kgvid_clear_completed_queue('scheduled');
2620
+ }
2621
+ add_action('kgvid_cleanup_queue', 'kgvid_cleanup_queue_handler');
2622
+
2623
  function kgvid_fix_moov_atom($video_key, $format) {
2624
 
2625
  $options = get_option('kgvid_video_embed_options');
2642
  if ( $options['moov'] == 'MP4Box' ) {
2643
  $cmd = escapeshellcmd($options['app_path']."/".$options['moov']." -inter 500 ".$filepath);
2644
  exec($cmd);
2645
+ }//if MP4Box is selected
 
 
 
2646
 
2647
  }//if there is an application selected for fixing moov atoms on libx264-encoded files.
2648
 
2715
  die(); // stop executing script
2716
  }
2717
 
2718
+ function kgvid_deactivate() {
2719
+ wp_clear_scheduled_hook('kgvid_cleanup_queue');
2720
+ delete_option('kgvid_video_embed_queue');
2721
+ }
2722
+ register_deactivation_hook( __FILE__, 'kgvid_deactivate' );
2723
+
2724
  ?>