r47753 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47752‎ | r47753 | r47754 >
Date:18:00, 24 February 2009
Author:dale
Status:deferred
Tags:
Comment:
fixes to local settings setup keep all customizations in parent LocalSettings.php
fixed expire on script load requests
maintenance bug fix
Modified paths:
  • /trunk/extensions/MetavidWiki/includes/MV_DefaultSettings.php (deleted) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_Settings.php (modified) (history)
  • /trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.inc.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/flvServer/MvFlv.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/flvServer/mvFlvServer.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedObj/mv_baseEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mvwScriptLoader.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.inc.php
@@ -183,9 +183,8 @@
184184 }
185185
186186 //check archive.org paths:
187 - ao_file_Ogg_Video
188187
189 -
 188+
190189 if ( count( $set ) == 0 ) {
191190 // no files present (remove stream)
192191 print 'no files present should remove: ' . $stream->name . "\n";
Index: trunk/extensions/MetavidWiki/includes/MV_DefaultSettings.php
@@ -1,222 +0,0 @@
2 -<?
3 -if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
4 -
5 -# ##
6 -# This is the path to your installation of Metavid Wiki as
7 -# seen from the web. Change it if required ($wgScriptPath is the
8 -# path to the base directory of your wiki). No final slash.
9 -# #
10 -$mvgScriptPath = $wgScriptPath . '/extensions/MetavidWiki';
11 -
12 -# ##
13 -# This is the path to your installation of Semantic MediaWiki as
14 -# seen on your local file system. Used for PHP file includes
15 -# #
16 -$mvgIP = $IP . '/extensions/MetavidWiki';
17 -
18 -define( 'SEQUENCE_TAG', 'sequence_hlrd' );
19 -
20 -// include the global functions & register the extension
21 -include_once( 'MV_GlobalFunctions.php' );
22 -
23 -
24 -
25 -//script loader settings:
26 -$mvgJSDebug=false;
27 -$wgEnableScriptLoader = true; //if the script loader is on at all
28 -$wgEnableScriptLoaderJsFile = true; //if you can use the script loader with js files (rather than only js classes)
29 -$wgEnableScriptMinify = true;
30 -
31 -
32 -
33 -// if the search portlet should autoComplete
34 -// (causes the inclution of jquery into every page.. can slow things down a bit)
35 -$mvEnableAutoComplete = true;
36 -
37 -
38 -
39 -// if you want mvd links to be rewritten client side as inline movie clips and link to the stream page
40 -$mvEnableJSMVDrewrite = true;
41 -
42 -# #########################
43 -# semanticWiki integration options
44 -# #########################
45 -// @@todo we should clean this up!... into a semantic maping array or object
46 -// if you want to include spoken by relation in search results:
47 -
48 -// enable dissable varius digest data collection
49 -$mvEnableSearchDigest = true;
50 -$mvEnableClipViewDigest = true;
51 -// keeps track of popular pages in given categories over time
52 -$mvDigestCategories = array( 'Interst_Group', 'Bill', 'Person' );
53 -
54 -// metadata helpers for annotative layer (anno_en)
55 -// 'property'=>category for auto_complete (ALL LOWER CASE)
56 -$mvMetaDataHelpers = array( 'anno_en' => array( 'speech_by' => 'person', 'bill' => 'bill' ) );
57 -
58 -// by default categories are handled differently enable or disable below:
59 -$mvMetaCategoryHelper = true;
60 -
61 -
62 -$mvSpokenByInSearchResult = true;
63 -// if you want to include category lookup in search results:
64 -$mvCategoryInSearchResult = true;
65 -// if you want to include bill lookup in search results:
66 -$mvBillInSearchResult = true;
67 -
68 -
69 -# ########################
70 -# metavid paths
71 -# @@todo clean up with internal handlers for annodex and images
72 -# use the mediaWiki defaults for storage of media
73 -# #########################
74 -
75 -// define the image location:
76 -// $mvImageWebLoc ='http://metavid.org/image_media/';
77 -
78 -// if we should load images from an external server:
79 -$mvExternalImages = false;
80 -// path to metavidWiki install that is serving images:
81 -$mvExternalImgServerPath = 'http://mvprime.cse.ucsc.edu/wiki/index.php';
82 -
83 -$mvWebImgLoc = $mvgScriptPath . '/stream_images';
84 -// full local path for images (if hosted locally)
85 -$mvLocalImgLoc = $mvgIP . '/stream_images';
86 -
87 -// if mediaWiki should serve up redirects to image file path or have php send the image via GD
88 -// if served directly its one less round trip to the server but may tax the server
89 -// a bit more than having apache serving the file
90 -$mvServeImageRedirect = false;
91 -
92 -// the time in seconds of between image frames generated from movie clips.
93 -// (set pretty high for the metavid context where we load the images via scripts
94 -// (early on we did less frequent image grabs)
95 -// normally you would want a lower value like 5 seconds or so
96 -$mvImageGranularityRate = '600';
97 -// the ffmpeg command to generate thumbnail (to disable generating images set to '')
98 -$mvShellOggFrameGrab = '';
99 -
100 -# define the video media locations based on path/server names
101 -$mvVideoArchivePaths['cap1'] = 'http://metavidstorage01.ucsc.edu/media/';
102 -$mvVideoArchivePaths['mvbox2'] = 'http://mvbox2.cse.ucsc.edu/media/';
103 -
104 -// stream msgKeys that support ?t=start_time/end_time temporal url media serving:
105 -$mvDefaultVideoQualityKey = 'mv_ogg_low_quality';
106 -$mvDefaultFlashQualityKey = 'mv_flash_low_quality';
107 -$mvDefaultVideoHighQualityKey = 'mv_ogg_high_quality';
108 -$mvDefaultMP4QualityKey = 'mv_archive_org_mp4';
109 -
110 -$mvVidQualityMsgKeyType['mv_ogg_low_quality'] = $mvVidQualityMsgKeyType['mv_ogg_high_quality']='video/ogg';
111 -$mvVidQualityMsgKeyType['mv_flash_low_quality']='video/x-flv';
112 -
113 -# local path to video archive (if hosted locally)
114 -$mvLocalVideoLoc = '/metavid/video_archive';
115 -
116 -# default clip length
117 -$mvDefaultClipLength = 30;
118 -$mvDefaultClipRange = 10;
119 -
120 -/*how many seconds to display of the video in the default Metavid:stream_name page */
121 -$mvDefaultStreamViewLength = 60 * 20; // 20 min
122 -
123 -// default aspect ratio (should be derived from media resolution once we integrate with oggHandler)
124 -$mvDefaultAspectRatio = .75;
125 -
126 -// limit for media search results:
127 -$mvMediaSearchResultsLimit = 100;
128 -
129 -# define how offten (in seconds) clients do http pull requests
130 -# to get new info when watching live broadcasts
131 -$mvLiveUpdateInterval = 5;
132 -
133 -// should be the same resolution as webstream encode.
134 -$mvDefaultVideoPlaybackRes = '400x300';
135 -$mvDefaultSearchVideoPlaybackRes = '320x240';
136 -$mvDefaultVideoIconSize = '80x60';
137 -
138 -//if to display the ROE resource link
139 -$mvDispROEicon=false;
140 -
141 -//The text Embed a metavid Stream inline in the wiki
142 -$mvEmbedKey = 'Embed';
143 -
144 -//wars people of archive inacuracys (given its a wiki and the source is close caption feed)
145 -$mvEnableStreamNotice=true;
146 -
147 -/*
148 - * All Available meta data layers
149 - * these type keys are used to allow multiple layers of metadata per stream.
150 - * These values key into template_names, msg_descriptions, and application logic )
151 - * Different languages should be in different tracks and documentation should be clear
152 - * to insure data goes into its associative layer.
153 - */
154 -$mvMVDTypeAllAvailable = array( 'ht_en', 'anno_en', 'thomas_en' );
155 -
156 -/*
157 - * the default display set of layers (must be a subset of $mvMVDTypeAllAvaliable)
158 - * note: this is equivalent to ?mvd_tracks=ht_en,anno_en in the url for the stream page.
159 - * this also dictates the default search layers
160 -*/
161 -$mvMVDTypeDefaultDisp = array( 'ht_en', 'anno_en' );
162 -
163 -# ##################
164 -# Special Pages with Interface functions
165 -# ##################
166 -// the wiki image page/image for missing person thumbnail:
167 -define( 'MV_MISSING_PERSON_IMG', 'Missing person.jpg' );
168 -
169 -
170 -// whether to count found results (can take lots of time on big result sets)
171 -$mvDo_SQL_CALC_FOUND_ROWS = true;
172 -
173 -# ########
174 -# Stream Types & User Rights
175 -# @@todo should really integrate "streams" with "media"
176 -# here you can control what rights 'sysop', 'bot', 'user', 'anonymous', have in
177 -# adding streams
178 -# note: all streams are treated equally once added to the system
179 -# (this only control import types)
180 -#
181 -# type: [metavid_file] -- used for pointing to an existing file on the server
182 -# [metavid_live] -- used for the setting up the scripts for a live stream.
183 -# [upload_file] -- used video file uploads
184 -# [external_file] -- used to add external files via http urls (such as a file from archive.org)
185 -$mvStreamTypePermission['metavid_file'] = array( 'sysop', 'bot' );
186 -$mvStreamTypePermission['metavid_live'] = array();
187 -$mvStreamTypePermission['upload_file'] = array();
188 -$mvStreamTypePermission['external_file'] = array();
189 -
190 -$wgGroupPermissions['user']['mv_delete_mvd'] = true;
191 -$wgGroupPermissions['sysop']['mv_edit_stream'] = true;
192 -$wgGroupPermissions['bot']['mv_edit_stream'] = true;
193 -
194 -$wgAvailableRights[] = 'mv_delete_mvd';
195 -$wgAvailableRights[] = 'mv_edit_stream';
196 -
197 -$mvMsgContentTypeLookup = array(
198 - 'ao_file_256Kb_MPEG4' => 'video/mp4',
199 - 'ao_file_64Kb_MPEG4' => 'video/mp4',
200 - 'ao_file_flash_flv' => 'video/x-flv',
201 - 'ao_file_MPEG1' => 'video/mpeg',
202 - 'ao_file_MPEG2' => 'video/mpeg-2',
203 -
204 - 'mv_archive_org_mp4' => 'video/h264',
205 - 'mv_flash_low_quality' => 'video/x-flv',
206 - 'mv_ogg_high_quality' => 'video/ogg',
207 - 'mv_ogg_low_quality' => 'video/ogg'
208 - );
209 -
210 -# ##
211 -# If you already have custom namespaces on your site, insert
212 -# $mvNamespaceIndex = ???; in your config before including the settings
213 -# should be larger than 100 and if you put in a default value
214 -# if your using semantic wiki just init the semantic wiki namespace
215 -# and metavid will take subsequent NS values accordingly.
216 -# #
217 -if ( !isset( $mvNamespaceIndex ) ) {
218 - mvInitNamespaces( 100 );
219 -} else {
220 - mvInitNamespaces();
221 -}
222 -
223 -?>
\ No newline at end of file
Index: trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php
@@ -373,8 +373,8 @@
374374 }
375375
376376 //temp for testing:
377 - //if( $mvgJSDebug )
378 - // $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/add_media_wizard.js?{$unique_req_param}\"></script>" );
 377+ if( $mvgJSDebug )
 378+ $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/add_media_wizard.js?{$unique_req_param}\"></script>" );
379379
380380 $mvCssUrl = $mvgScriptPath . '/skins/mv_custom.css';
381381 $wgOut->addLink( array(
Index: trunk/extensions/MetavidWiki/includes/MV_Settings.php
@@ -1,5 +1,222 @@
22 <?
33 if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
4 -// (this file is depricated update your MV_LocalSettings.php to point to MV_LocalSettings)
5 -include_once( dirname( __FILE__ ) . '/../MV_LocalSettings.php' );
 4+
 5+# ##
 6+# This is the path to your installation of Metavid Wiki as
 7+# seen from the web. Change it if required ($wgScriptPath is the
 8+# path to the base directory of your wiki). No final slash.
 9+# #
 10+$mvgScriptPath = $wgScriptPath . '/extensions/MetavidWiki';
 11+
 12+# ##
 13+# This is the path to your installation of Semantic MediaWiki as
 14+# seen on your local file system. Used for PHP file includes
 15+# #
 16+$mvgIP = $IP . '/extensions/MetavidWiki';
 17+
 18+define( 'SEQUENCE_TAG', 'sequence_hlrd' );
 19+
 20+// include the global functions & register the extension
 21+include_once( 'MV_GlobalFunctions.php' );
 22+
 23+
 24+
 25+//script loader settings:
 26+$mvgJSDebug=false;
 27+$wgEnableScriptLoader = true; //if the script loader is on at all
 28+$wgEnableScriptLoaderJsFile = true; //if you can use the script loader with js files (rather than only js classes)
 29+$wgEnableScriptMinify = true;
 30+
 31+
 32+
 33+// if the search portlet should autoComplete
 34+// (causes the inclution of jquery into every page.. can slow things down a bit)
 35+$mvEnableAutoComplete = true;
 36+
 37+
 38+
 39+// if you want mvd links to be rewritten client side as inline movie clips and link to the stream page
 40+$mvEnableJSMVDrewrite = true;
 41+
 42+# #########################
 43+# semanticWiki integration options
 44+# #########################
 45+// @@todo we should clean this up!... into a semantic maping array or object
 46+// if you want to include spoken by relation in search results:
 47+
 48+// enable dissable varius digest data collection
 49+$mvEnableSearchDigest = true;
 50+$mvEnableClipViewDigest = true;
 51+// keeps track of popular pages in given categories over time
 52+$mvDigestCategories = array( 'Interst_Group', 'Bill', 'Person' );
 53+
 54+// metadata helpers for annotative layer (anno_en)
 55+// 'property'=>category for auto_complete (ALL LOWER CASE)
 56+$mvMetaDataHelpers = array( 'anno_en' => array( 'speech_by' => 'person', 'bill' => 'bill' ) );
 57+
 58+// by default categories are handled differently enable or disable below:
 59+$mvMetaCategoryHelper = true;
 60+
 61+
 62+$mvSpokenByInSearchResult = true;
 63+// if you want to include category lookup in search results:
 64+$mvCategoryInSearchResult = true;
 65+// if you want to include bill lookup in search results:
 66+$mvBillInSearchResult = true;
 67+
 68+
 69+# ########################
 70+# metavid paths
 71+# @@todo clean up with internal handlers for annodex and images
 72+# use the mediaWiki defaults for storage of media
 73+# #########################
 74+
 75+// define the image location:
 76+// $mvImageWebLoc ='http://metavid.org/image_media/';
 77+
 78+// if we should load images from an external server:
 79+$mvExternalImages = false;
 80+// path to metavidWiki install that is serving images:
 81+$mvExternalImgServerPath = 'http://mvprime.cse.ucsc.edu/wiki/index.php';
 82+
 83+$mvWebImgLoc = $mvgScriptPath . '/stream_images';
 84+// full local path for images (if hosted locally)
 85+$mvLocalImgLoc = $mvgIP . '/stream_images';
 86+
 87+// if mediaWiki should serve up redirects to image file path or have php send the image via GD
 88+// if served directly its one less round trip to the server but may tax the server
 89+// a bit more than having apache serving the file
 90+$mvServeImageRedirect = false;
 91+
 92+// the time in seconds of between image frames generated from movie clips.
 93+// (set pretty high for the metavid context where we load the images via scripts
 94+// (early on we did less frequent image grabs)
 95+// normally you would want a lower value like 5 seconds or so
 96+$mvImageGranularityRate = '600';
 97+// the ffmpeg command to generate thumbnail (to disable generating images set to '')
 98+$mvShellOggFrameGrab = '';
 99+
 100+# define the video media locations based on path/server names
 101+$mvVideoArchivePaths['cap1'] = 'http://metavidstorage01.ucsc.edu/media/';
 102+$mvVideoArchivePaths['mvbox2'] = 'http://mvbox2.cse.ucsc.edu/media/';
 103+
 104+// stream msgKeys that support ?t=start_time/end_time temporal url media serving:
 105+$mvDefaultVideoQualityKey = 'mv_ogg_low_quality';
 106+$mvDefaultFlashQualityKey = 'mv_flash_low_quality';
 107+$mvDefaultVideoHighQualityKey = 'mv_ogg_high_quality';
 108+$mvDefaultMP4QualityKey = 'mv_archive_org_mp4';
 109+
 110+$mvVidQualityMsgKeyType['mv_ogg_low_quality'] = $mvVidQualityMsgKeyType['mv_ogg_high_quality']='video/ogg';
 111+$mvVidQualityMsgKeyType['mv_flash_low_quality']='video/x-flv';
 112+
 113+# local path to video archive (if hosted locally)
 114+$mvLocalVideoLoc = '/metavid/video_archive';
 115+
 116+# default clip length
 117+$mvDefaultClipLength = 30;
 118+$mvDefaultClipRange = 10;
 119+
 120+/*how many seconds to display of the video in the default Metavid:stream_name page */
 121+$mvDefaultStreamViewLength = 60 * 20; // 20 min
 122+
 123+// default aspect ratio (should be derived from media resolution once we integrate with oggHandler)
 124+$mvDefaultAspectRatio = .75;
 125+
 126+// limit for media search results:
 127+$mvMediaSearchResultsLimit = 100;
 128+
 129+# define how offten (in seconds) clients do http pull requests
 130+# to get new info when watching live broadcasts
 131+$mvLiveUpdateInterval = 5;
 132+
 133+// should be the same resolution as webstream encode.
 134+$mvDefaultVideoPlaybackRes = '400x300';
 135+$mvDefaultSearchVideoPlaybackRes = '320x240';
 136+$mvDefaultVideoIconSize = '80x60';
 137+
 138+//if to display the ROE resource link
 139+$mvDispROEicon=false;
 140+
 141+//The text Embed a metavid Stream inline in the wiki
 142+$mvEmbedKey = 'Embed';
 143+
 144+//wars people of archive inacuracys (given its a wiki and the source is close caption feed)
 145+$mvEnableStreamNotice=true;
 146+
 147+/*
 148+ * All Available meta data layers
 149+ * these type keys are used to allow multiple layers of metadata per stream.
 150+ * These values key into template_names, msg_descriptions, and application logic )
 151+ * Different languages should be in different tracks and documentation should be clear
 152+ * to insure data goes into its associative layer.
 153+ */
 154+$mvMVDTypeAllAvailable = array( 'ht_en', 'anno_en', 'thomas_en' );
 155+
 156+/*
 157+ * the default display set of layers (must be a subset of $mvMVDTypeAllAvaliable)
 158+ * note: this is equivalent to ?mvd_tracks=ht_en,anno_en in the url for the stream page.
 159+ * this also dictates the default search layers
 160+*/
 161+$mvMVDTypeDefaultDisp = array( 'ht_en', 'anno_en' );
 162+
 163+# ##################
 164+# Special Pages with Interface functions
 165+# ##################
 166+// the wiki image page/image for missing person thumbnail:
 167+define( 'MV_MISSING_PERSON_IMG', 'Missing person.jpg' );
 168+
 169+
 170+// whether to count found results (can take lots of time on big result sets)
 171+$mvDo_SQL_CALC_FOUND_ROWS = true;
 172+
 173+# ########
 174+# Stream Types & User Rights
 175+# @@todo should really integrate "streams" with "media"
 176+# here you can control what rights 'sysop', 'bot', 'user', 'anonymous', have in
 177+# adding streams
 178+# note: all streams are treated equally once added to the system
 179+# (this only control import types)
 180+#
 181+# type: [metavid_file] -- used for pointing to an existing file on the server
 182+# [metavid_live] -- used for the setting up the scripts for a live stream.
 183+# [upload_file] -- used video file uploads
 184+# [external_file] -- used to add external files via http urls (such as a file from archive.org)
 185+$mvStreamTypePermission['metavid_file'] = array( 'sysop', 'bot' );
 186+$mvStreamTypePermission['metavid_live'] = array();
 187+$mvStreamTypePermission['upload_file'] = array();
 188+$mvStreamTypePermission['external_file'] = array();
 189+
 190+$wgGroupPermissions['user']['mv_delete_mvd'] = true;
 191+$wgGroupPermissions['sysop']['mv_edit_stream'] = true;
 192+$wgGroupPermissions['bot']['mv_edit_stream'] = true;
 193+
 194+$wgAvailableRights[] = 'mv_delete_mvd';
 195+$wgAvailableRights[] = 'mv_edit_stream';
 196+
 197+$mvMsgContentTypeLookup = array(
 198+ 'ao_file_256Kb_MPEG4' => 'video/mp4',
 199+ 'ao_file_64Kb_MPEG4' => 'video/mp4',
 200+ 'ao_file_flash_flv' => 'video/x-flv',
 201+ 'ao_file_MPEG1' => 'video/mpeg',
 202+ 'ao_file_MPEG2' => 'video/mpeg-2',
 203+
 204+ 'mv_archive_org_mp4' => 'video/h264',
 205+ 'mv_flash_low_quality' => 'video/x-flv',
 206+ 'mv_ogg_high_quality' => 'video/ogg',
 207+ 'mv_ogg_low_quality' => 'video/ogg'
 208+ );
 209+
 210+# ##
 211+# If you already have custom namespaces on your site, insert
 212+# $mvNamespaceIndex = ???; in your config before including the settings
 213+# should be larger than 100 and if you put in a default value
 214+# if your using semantic wiki just init the semantic wiki namespace
 215+# and metavid will take subsequent NS values accordingly.
 216+# #
 217+if ( !isset( $mvNamespaceIndex ) ) {
 218+ mvInitNamespaces( 100 );
 219+} else {
 220+ mvInitNamespaces();
 221+}
 222+
6223 ?>
\ No newline at end of file
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -89,17 +89,17 @@
9090
9191 "clip_linkback" : "Clip Source Page",
9292
93 - "ogg-player-vlc-mozilla" : "VLC Plugin",
94 - "ogg-player-videoElement" : "Native Ogg Video Support",
95 - "ogg-player-vlc-activex" : "VLC ActiveX",
96 - "ogg-player-oggPlay" : "Annodex OggPlay Plugin",
97 - "ogg-player-oggPlugin" : "Generic Ogg Plugin",
98 - "ogg-player-quicktime-mozilla" : "Quicktime Plugin",
99 - "ogg-player-quicktime-activex" : "Quicktime ActiveX",
100 - "ogg-player-cortado" : "Java Cortado",
101 - "ogg-player-flowplayer" : "Flowplayer",
102 - "ogg-player-selected" : " (selected)",
103 - "generic_missing_plugin" : "You browser does not appear to support playback type: <b>$1</b><br> visit the <a href=\"http://metavid.org/wiki/Client_Playback\">Playback Methods</a> page to download a player<br>",
 93+ "mv_ogg-player-vlc-mozilla" : "VLC Plugin",
 94+ "mv_ogg-player-videoElement" : "Native Ogg Video Support",
 95+ "mv_ogg-player-vlc-activex" : "VLC ActiveX",
 96+ "mv_ogg-player-oggPlay" : "Annodex OggPlay Plugin",
 97+ "mv_ogg-player-oggPlugin" : "Generic Ogg Plugin",
 98+ "mv_ogg-player-quicktime-mozilla" : "Quicktime Plugin",
 99+ "mv_ogg-player-quicktime-activex" : "Quicktime ActiveX",
 100+ "mv_ogg-player-cortado" : "Java Cortado",
 101+ "mv_ogg-player-flowplayer" : "Flowplayer",
 102+ "mv_ogg-player-selected" : " (selected)",
 103+ "mv_generic_missing_plugin" : "You browser does not appear to support playback type: <b>$1</b><br> visit the <a href=\"http://metavid.org/wiki/Client_Playback\">Playback Methods</a> page to download a player<br>",
104104
105105 "add_to_end_of_sequence" : "Add to End of Sequence",
106106
@@ -170,8 +170,7 @@
171171 //two loading stages, first get jQuery
172172 var _this = this;
173173 mvJsLoader.doLoad({
174 - 'window.jQuery' :'jquery/jquery-1.2.6.js',
175 - 'embedVideo' :'libEmbedObj/mv_baseEmbed.js'
 174+ 'window.jQuery' :'jquery/jquery-1.2.6.js'
176175 },function(){
177176 //once jQuery is loaded set up no conflict & load plugins:
178177 _global['$j'] = jQuery.noConflict();
@@ -182,7 +181,8 @@
183182 js_log('jquery loaded');
184183 //load the jQuery dependent plugins:
185184 mvJsLoader.doLoad({
186 - '$j.ui.mouse' :'jquery/jquery.ui-1.5.2/ui/minified/ui.core.min.js',
 185+ 'embedVideo' : 'libEmbedObj/mv_baseEmbed.js',
 186+ '$j.ui.mouse' : 'jquery/jquery.ui-1.5.2/ui/minified/ui.core.min.js',
187187 '$j.ui.droppable' : 'jquery/jquery.ui-1.5.2/ui/minified/ui.droppable.min.js',
188188 '$j.ui.draggable' : 'jquery/jquery.ui-1.5.2/ui/minified/ui.draggable.min.js'
189189 },function(){
@@ -229,7 +229,7 @@
230230 }
231231 }
232232 if( all_libs_loaded ){
233 - js_log('all libs already loaded skiping...' + libs);
 233+ js_log('all libs already loaded skipping...' + libs);
234234 callback();
235235 return ;
236236 }
@@ -360,7 +360,7 @@
361361 },
362362 getName : function()
363363 {
364 - return gM('ogg-player-' + this.id);
 364+ return gM('mv_ogg-player-' + this.id);
365365 },
366366 load : function(callback)
367367 {
@@ -589,6 +589,7 @@
590590 (secure ? "; secure" : "");
591591 }
592592 js_log("mv embed path:"+ mv_embed_path);
 593+
593594 /*
594595 * embedTypes object handles setting and getting of supported embed types:
595596 * closely mirrors OggHandler so that its easier to share efforts in this area:
@@ -959,7 +960,7 @@
960961 mvJsLoader.loadBaseLibs(function(){
961962 //load search specifc extra stuff
962963 mvJsLoader.doLoad({
963 - 'mvBaseRemoteSearch':'libAddMedia/remoteSearchDriver.js'
 964+ 'remoteSearchDriver':'libAddMedia/remoteSearchDriver.js'
964965 }, function(){
965966 initObj['instance_name']= 'rsdMVRS';
966967 rsdMVRS = new remoteSearchDriver( initObj );
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedObj/mv_baseEmbed.js
@@ -223,7 +223,7 @@
224224 }
225225 },
226226 'play_head':{
227 - 'w':0, //special case (takes up remaning space)
 227+ 'w':0, //special case (takes up remaining space)
228228 'o':function(){
229229 return '<div class="seeker" id="mv_seeker_'+ctrlBuilder.id+'" style="width: ' + (ctrlBuilder.avaliable_width - 18) + 'px;">'+
230230 ' <div id="seeker_bar_'+ctrlBuilder.id+'" class="seeker_bar">'+
@@ -306,8 +306,7 @@
307307 this[ attr ] = $j(element).attr( attr );
308308 }
309309 }
310 -
311 -
 310+
312311 if ( $j(element).attr('type'))
313312 this.mime_type = $j(element).attr('type');
314313 else if ($j(element).attr('content-type'))
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mvwScriptLoader.php
@@ -123,7 +123,7 @@
124124 //cache forever:
125125 //(the point is we never have to re validate since we should always change the request url based on the svn version)
126126 $one_year = 60*60*24*365;
127 - //header("Expires: " . gmdate( "D, d M Y H:i:s", time() + $one_year ) . " GM");
 127+ header("Expires: " . gmdate( "D, d M Y H:i:s", time() + $one_year ) . " GM");
128128 }
129129 /*
130130 * updates the proc Request
Index: trunk/extensions/MetavidWiki/skins/mv_embed/flvServer/MvFlv.php
@@ -2,149 +2,184 @@
33
44 include_once 'FLV/FLV.php';
55
6 -define( 'MAX_FLV_TS', 16777.216 );// it appears tag times restart after 16777.216 seconds;
7 -define( 'KEY_FRAME_DISTANCE', 2 ); // max keyframe distance
 6+define('MAX_FLV_TS', 16777.216);//it appears tag times restart after 16777.216 seconds;
 7+define('KEY_FRAME_DISTANCE', 2); //max keyframe distance
88
9 -// define('META_KFDATA_EXT', '.KfMeta'); //file extension for cached keframe metadata
10 -define( 'META_DATA_EXT', '.meta' ); // basic cached meta
 9+//define('META_KFDATA_EXT', '.KfMeta'); //file extension for cached keframe metadata
 10+define('META_DATA_EXT', '.meta'); //basic cached meta
1111
1212 class MyFLV extends FLV {
13 -
 13+
1414 /**
15 - * On audio-only files the frame index will use this as minimum gap
 15+ * On audio-only files the frame index will use this as minimum gap
1616 */
1717 private $audioFrameGap = 3;
18 -
 18+
1919 private $origMetaOfs = 0;
2020 private $origMetaSize = 0;
2121 private $origMetaData;
2222 private $compMetaData;
23 -
24 - // added segment vars:
25 - private $fullMeta = null;
26 - private $mDuration = null;
27 - private $wrapTimeCount = 0;
28 -
29 - function getByteTimeReq( $start_time_sec, $end_time_sec = null ) {
30 - // print "play $start_time_sec to $end_time_sec";
31 - // @@todo cache byte offsets in memcache if avaliable
32 - if ( $end_time_sec )
 23+
 24+ //added segment vars:
 25+ private $fullMeta=null;
 26+ private $mDuration=null;
 27+ var $wrapTimeCount=0;
 28+
 29+ function getKeyFrameByteTimes( $start_time_sec, $end_time_sec=null ){
 30+ //print "play $start_time_sec to $end_time_sec";
 31+ //@@todo cache byte offsets in memcache if available
 32+ if( $end_time_sec)
3333 $this->mDuration = $end_time_sec - $start_time_sec;
34 - // print "SET metaDuration to: " . $this->metaDuration . "\n";
35 - // print_r($fullMeta);
36 - $meta =& $this->getKeyFrameMetaData();
37 - // die;
38 - $start_byte = $end_byte = null;
39 - if ( $start_time_sec == 0 && $end_time_sec == null )$this->play();
40 - $start_time_ms = $start_time_sec * 1000;
41 - $end_time_ms = ( $end_time_sec == null ) ? null:$end_time_sec * 1000;
42 -
43 - for ( $i = 0; $i < count( $meta['times'] ); $i++ ) {
44 - // set to the keyframe right before a keyframe of the requested start time
45 - if ( $meta['times'][$i] >= $start_time_ms && $start_byte == null ) {
46 - $start_byte = ( isset( $meta['times'][$i - 1] ) ) ? $meta['filepositions'][$i - 1]:$meta['filepositions'][$i];
47 - if ( $end_time_ms == null )break;
 34+ //print "SET metaDuration to: " . $this->metaDuration . "\n";
 35+ //print_r($fullMeta);
 36+ $meta =& $this->getKeyFrameMetaData();
 37+ //die;
 38+ $start_byte=$end_byte=null;
 39+ if($start_time_sec==0 && $end_time_sec==null)$this->play();
 40+ $start_time_ms = $start_time_sec*1000;
 41+ $end_time_ms = ($end_time_sec==null)?null:$end_time_sec*1000;
 42+
 43+ for($i=0; $i < count($meta['times']); $i++){
 44+ //set to the keyframe right before a keyframe of the requested start time
 45+ if($meta['times'][$i] >= $start_time_ms && $start_byte==null){
 46+ $start_byte=(isset($meta['times'][$i-1]))?$meta['filepositions'][$i-1]:$meta['filepositions'][$i];
 47+ if($end_time_ms==null)break;
4848 }
49 - // set to the keyframe right after the keyframe of the end time:
50 - if ( $end_time_ms != null ) {
51 - if ( $meta['times'][$i] >= $end_time_ms ) {
52 - $end_byte = $meta['filepositions'][$i];
 49+ //set to the keyframe right after the keyframe of the end time:
 50+ if($end_time_ms!=null){
 51+ if($meta['times'][$i] >= $end_time_ms){
 52+ $end_byte= $meta['filepositions'][$i];
5353 break;
54 - }
 54+ }
 55+ }
 56+ }
 57+ return array($start_byte, $end_byte);
 58+ }
 59+ function playTimeReq( $start_time_sec, $end_time_sec=null ){
 60+ //print "play $start_time_sec to $end_time_sec";
 61+ //@@todo cache byte offsets in memcache if available
 62+ if( $end_time_sec)
 63+ $this->mDuration = $end_time_sec - $start_time_sec;
 64+ //print "SET metaDuration to: " . $this->metaDuration . "\n";
 65+ //print_r($fullMeta);
 66+ $meta =& $this->getKeyFrameMetaData();
 67+ //die;
 68+ $start_byte=$end_byte=null;
 69+ if($start_time_sec==0 && $end_time_sec==null)$this->play();
 70+ $start_time_ms = $start_time_sec*1000;
 71+ $end_time_ms = ($end_time_sec==null)?null:$end_time_sec*1000;
 72+
 73+ for($i=0; $i < count($meta['times']); $i++){
 74+ //set to the keyframe right before a keyframe of the requested start time
 75+ if($meta['times'][$i]>=$start_time_ms && $start_byte==null){
 76+ $start_byte=(isset($meta['times'][$i-1]))?$meta['filepositions'][$i-1]:$meta['filepositions'][$i];
 77+ if($end_time_ms==null)break;
5578 }
56 - }
57 - return array( $start_byte, $end_byte );
58 - }
 79+ //set to the keyframe right after the keyframe of the end time:
 80+ if($end_time_ms!=null){
 81+ if($meta['times'][$i]>=$end_time_ms){
 82+ $end_byte= $meta['filepositions'][$i];
 83+ break;
 84+ }
 85+ }
 86+ }
 87+ $this->play($start_byte, $end_byte);
 88+ }
5989 function computeMetaData()
6090 {
61 - ini_set( "max_execution_time", "0" );// computeMetaData can take some time
 91+ ini_set("max_execution_time","0");//computeMetaData can take some time
6292 $this->compMetaData = array();
6393 $this->compMetaData['metadatacreator'] = 'FLV Tools';
64 - $this->compMetaData['metadatadate'] = gmdate( 'Y-m-d\TH:i:s' ) . '.000Z';
 94+ $this->compMetaData['metadatadate'] = gmdate('Y-m-d\TH:i:s') . '.000Z';
6595 $this->compMetaData['keyframes'] = array();
6696 $this->compMetaData['keyframes']['filepositions'] = array();
6797 $this->compMetaData['keyframes']['times'] = array();
68 -
 98+ $this->compMetaData['lasttimestamp'] = -1;
 99+
69100 $this->origMetaOfs = 0;
70101 $this->origMetaSize = 0;
71102 $this->origMetaData = null;
72 - $oldTs = 0;
73 - $this->compMetaData['lasttimestamp'] = 0;
74 -
 103+
75104 $skipTagTypes = array();
76 - while ( $tag = $this->getTag( $skipTagTypes ) )
 105+ while ($tag = $this->getTag( $skipTagTypes ))
77106 {
78107 // pre-calculate the timestamp as seconds
79 - $ts = $tag->timestamp / 1000;
80 - if ( $tag->timestamp > 0 && $tag->type == FLV_Tag::TYPE_VIDEO ) {
81 - $ts = ( MAX_FLV_TS * $this->wrapTimeCount ) + $ts;
82 - if ( $ts < $this->compMetaData['lasttimestamp'] ) {
 108+ $ts = $tag->timestamp/1000;
 109+ if ($tag->timestamp > 0 && $tag->type==FLV_Tag::TYPE_VIDEO ){
 110+ $ts = (MAX_FLV_TS*$this->wrapTimeCount) + $ts;
 111+ if($ts < $this->compMetaData['lasttimestamp']){
83112 $this->wrapTimeCount++;
84113 $ts = MAX_FLV_TS + $ts;
85 - }
86 - // print "set end time to $ts \n";
87 - $this->compMetaData['lasttimestamp'] = $ts;
88 - }
89 - switch ( $tag->type )
 114+ }
 115+ //print "set end time to $ts \n";
 116+ $this->compMetaData['lasttimestamp'] = $ts;
 117+ }
 118+
 119+ switch ($tag->type)
90120 {
91 - case FLV_Tag::TYPE_VIDEO :
92 - // Optimization, extract the frametype without analyzing the tag body
93 - if ( ( ord( $tag->body[0] ) >> 4 ) == FLV_Tag_Video::FRAME_KEYFRAME )
 121+ case FLV_Tag::TYPE_VIDEO :
 122+ //Optimization, extract the frametype without analyzing the tag body
 123+ if ((ord($tag->body[0]) >> 4) == FLV_Tag_Video::FRAME_KEYFRAME)
94124 {
95125 $this->compMetaData['keyframes']['filepositions'][] = $this->getTagOffset();
96126 $this->compMetaData['keyframes']['times'][] = $ts;
97127 }
98 -
99 - if ( !in_array( FLV_TAG::TYPE_VIDEO, $skipTagTypes ) )
 128+
 129+ if ( !in_array(FLV_TAG::TYPE_VIDEO, $skipTagTypes) )
100130 {
101131 $this->compMetaData['width'] = $tag->width;
102132 $this->compMetaData['height'] = $tag->height;
103133 $this->compMetaData['videocodecid'] = $tag->codec;
104 - // Processing one video tag is enough
 134+ //Processing one video tag is enough
105135 array_push( $skipTagTypes, FLV_Tag::TYPE_VIDEO );
106 - }
 136+ }
107137 break;
 138+
108139 case FLV_Tag::TYPE_AUDIO :
109 - // Save audio frame positions when there is no video
110 - if ( $ts - $oldTs > $this->audioFrameGap )
 140+
 141+ //Save audio frame positions when there is no video
 142+ /*if (!$flv->hasVideo && $ts - $oldTs > $this->audioFrameGap)
111143 {
112144 $this->compMetaData['keyframes']['filepositions'][] = $this->getTagOffset();
113145 $this->compMetaData['keyframes']['times'][] = $ts;
114146 $oldTs = $ts;
115147 }
116 - if ( !in_array( FLV_Tag::TYPE_AUDIO, $skipTagTypes ) )
 148+
 149+ if ( !in_array( FLV_Tag::TYPE_AUDIO, $skipTagTypes) )
117150 {
118151 $this->compMetaData['audiocodecid'] = $tag->codec;
119152 $this->compMetaData['audiofreqid'] = $tag->frequency;
120153 $this->compMetaData['audiodepthid'] = $tag->depth;
121154 $this->compMetaData['audiomodeid'] = $tag->mode;
122 -
123 - // Processing one audio tag is enough
 155+
 156+ //Processing one audio tag is enough
124157 array_push( $skipTagTypes, FLV_Tag::TYPE_AUDIO );
125 - }
126 - break;
 158+ } */
 159+
 160+ break;
 161+
127162 case FLV_Tag::TYPE_DATA :
128 - if ( $tag->name == 'onMetaData' )
 163+ if ($tag->name == 'onMetaData')
129164 {
130165 $this->origMetaOfs = $this->getTagOffset();
131166 $this->origMetaSize = $tag->size + self::TAG_HEADER_SIZE;
132167 $this->origMetaData = $tag->value;
133168 }
134 - break;
 169+ break;
135170 }
136 -
137 - // Does this actually help with memory allocation?
138 - unset( $tag );
 171+
 172+ //Does this actually help with memory allocation?
 173+ unset($tag);
139174 }
140 -
141 - if ( ! empty( $this->compMetaData['keyframes']['times'] ) )
142 - $this->compMetaData['lastkeyframetimestamp'] = $this->compMetaData['keyframes']['times'][ count( $this->compMetaData['keyframes']['times'] ) - 1 ];
143 -
 175+
 176+ if (! empty($this->compMetaData['keyframes']['times']))
 177+ $this->compMetaData['lastkeyframetimestamp'] = $this->compMetaData['keyframes']['times'][ count($this->compMetaData['keyframes']['times'])-1 ];
 178+
144179 $this->compMetaData['duration'] = $this->compMetaData['lasttimestamp'];
145 -
 180+
146181 return $this->compMetaData;
147182 }
148 -
 183+
149184 function setMetaData( $metadata, $origMetaOfs = 0, $origMetaSize = 0 )
150185 {
151186 $this->compMetaData = $metadata;
@@ -154,111 +189,112 @@
155190 /* returns merged metadata*/
156191 function getMetaData()
157192 {
158 - if ( $this->fullMeta )return $this->fullMeta;
159 - if ( is_file( $this->fname . META_DATA_EXT ) ) {
160 - $this->fullMeta = unserialize( file_get_contents ( $this->fname . META_DATA_EXT ) );
161 - } else {
 193+ if($this->fullMeta)return $this->fullMeta;
 194+ if(is_file($this->fname . META_DATA_EXT)){
 195+ $this->fullMeta = unserialize(file_get_contents ($this->fname . META_DATA_EXT));
 196+ }else{
162197 $this->computeMetaData();
163 - if ( ! is_array( $this->origMetaData ) ) {
 198+ if (! is_array($this->origMetaData)){
164199 $this->fullMeta = $this->compMetaData;
165 - } else {
 200+ }else{
166201 $this->fullMeta = array_merge( $this->origMetaData, $this->compMetaData );
167 - }
168 - // free non-merged arrays:
169 - unset( $this->origMetaData );
170 - unset( $this->compMetaData );
171 - // convert floats to int
172 - foreach ( $this->fullMeta['keyframes']['times'] as $inx => & $ts ) {
173 - $ts = (int)( $ts * 1000 );
174 - }
175 - if ( !file_put_contents( $this->fname . META_DATA_EXT, serialize( $this->fullMeta ) ) ) {
176 - throw( new FLV_FileException( 'Unable to write out cached keyframe output' ) );
177 - }
178 - }
 202+ }
 203+ //free non-merged arrays:
 204+ unset($this->origMetaData);
 205+ unset($this->compMetaData);
 206+ //convert floats to int
 207+ foreach($this->fullMeta['keyframes']['times'] as $inx=>& $ts){
 208+ $ts = (int)($ts*1000);
 209+ }
 210+ if(!file_put_contents($this->fname . META_DATA_EXT, serialize($this->fullMeta))){
 211+ throw( new FLV_FileException('Unable to write out cached keyframe output to '.$this->fname) );
 212+ }
 213+ }
179214 return $this->fullMeta;
180215 }
181 - function getKeyFrameMetaData() {
 216+ function getKeyFrameMetaData(){
182217 $meta = & $this->getMetaData();
183218 return $meta['keyframes'];
184219 }
185 - function getSegmentMetaData() {
186 - // pull base cached metadata
187 - // update duration & return new array
 220+ function getSegmentMetaData(){
 221+ //pull base cached metadata
 222+ //update duration & return new array
188223 $meta = & $this->getMetaData();
189 - $meta['keyframes'] = array();
190 - // @@todo update all the other metadata to match segment outupt
 224+ $meta['keyframes'] = array();
 225+ //@@todo update all the other metadata to match segment outupt
191226 return $meta;
192 - }
193 - function play( $from = 0, $play_to = null )
 227+ }
 228+ function play( $from = 0, $play_to=null )
194229 {
195 - fseek( $this->fp, 0 );
196 -
 230+ fseek($this->fp, 0);
 231+
197232 // get original file header just in case it has any special flag
198 - echo fread( $this->fp, $this->bodyOfs + 4 );
199 -
 233+ echo fread($this->fp, $this->bodyOfs + 4);
 234+
200235 // output the metadata if available
201 - $meta = $this->getSegmentMetaData();
202 - // $meta = $this->getMetaData();
203 -
204 - if ( ! empty( $meta ) )
 236+ $meta = $this->getSegmentMetaData();
 237+ //$meta = $this->getMetaData();
 238+
 239+ if (! empty($meta))
205240 {
206 - // serialize the metadata as an AMF stream
 241+ //serialize the metadata as an AMF stream
207242 include_once 'FLV/Util/AMFSerialize.php';
208243 $amf = new FLV_Util_AMFSerialize();
209244
210 - $serMeta = $amf->serialize( 'onMetaData' );
211 - $serMeta .= $amf->serialize( $meta );
 245+ $serMeta = $amf->serialize('onMetaData');
 246+ $serMeta.= $amf->serialize($meta);
212247
213 - // Data tag mark
214 - $out = pack( 'C', FLV_Tag::TYPE_DATA );
215 - // Size of the data tag (BUG: limited to 64Kb)
216 - $out .= pack( 'Cn', 0, strlen( $serMeta ) );
217 - // Timestamp
218 - $out .= pack( 'N', 0 );
219 - // StreamID
220 - $out .= pack( 'Cn', 0, 0 );
221 -
 248+ //Data tag mark
 249+ $out = pack('C', FLV_Tag::TYPE_DATA);
 250+ //Size of the data tag (BUG: limited to 64Kb)
 251+ $out.= pack('Cn', 0, strlen($serMeta));
 252+ //Timestamp
 253+ $out.= pack('N', 0);
 254+ //StreamID
 255+ $out.= pack('Cn', 0, 0);
 256+
222257 echo $out;
223258 echo $serMeta;
224 -
 259+
225260 // PrevTagSize for the metadata
226 - echo pack( 'N', strlen( $serMeta ) + strlen( $out ) );
 261+ echo pack('N', strlen($serMeta) + strlen($out) );
227262 }
228 -
 263+
229264 $chunkSize = 4096;
230 - $skippedOrigMeta = empty( $this->origMetaSize );
231 - // seek to offset point:
232 - fseek( $this->fp, $from );
233 - while ( ! feof( $this->fp ) )
 265+ $skippedOrigMeta = empty($this->origMetaSize);
 266+ //seek to offset point:
 267+ fseek($this->fp, $from);
 268+ while (! feof($this->fp))
234269 {
235 - // if the original metadata is pressent and not yet skipped...
236 - if ( ! $skippedOrigMeta )
237 - {
238 - $pos = ftell( $this->fp );
239 -
 270+ // if the original metadata is present and not yet skipped...
 271+ if (! $skippedOrigMeta)
 272+ {
 273+ $pos = ftell($this->fp);
 274+
240275 // check if we are going to output it in this loop step
241276 if ( $pos <= $this->origMetaOfs &&
242277 $pos + $chunkSize > $this->origMetaOfs )
243278 {
244279 // output the bytes just before the original metadata tag
245 - if ( $this->origMetaOfs - $pos > 0 )
246 - echo fread( $this->fp, $this->origMetaOfs - $pos );
247 -
 280+ if ($this->origMetaOfs - $pos > 0)
 281+ echo fread($this->fp, $this->origMetaOfs - $pos);
 282+
248283 // position the file pointer just after the metadata tag
249 - fseek( $this->fp, $this->origMetaOfs + $this->origMetaSize );
250 -
 284+ fseek($this->fp, $this->origMetaOfs + $this->origMetaSize);
 285+
251286 $skippedOrigMeta = true;
252287 continue;
253288 }
254289 }
255 - if ( $play_to != null ) {
256 - if ( ftell( $this->fp ) + $chunkSize > $play_to ) {
257 - $read_amount = ( ftell( $this->fp ) + $chunkSize ) - $play_to;
258 - echo fread( $this->fp, $read_amount );
 290+ if($play_to!=null){
 291+ if(ftell($this->fp)+$chunkSize > $play_to){
 292+ $read_amount = (ftell($this->fp)+$chunkSize)-$play_to;
 293+ echo fread($this->fp, $read_amount);
259294 break;
260295 }
261296 }
262 - echo fread( $this->fp, $chunkSize );
 297+ echo fread($this->fp, $chunkSize);
263298 }
264299 }
265300 }
 301+?>
\ No newline at end of file
Index: trunk/extensions/MetavidWiki/skins/mv_embed/flvServer/mvFlvServer.php
@@ -1,108 +1,111 @@
22 <?php
33 /*
4 - * mv_flvServer.php
 4+ * mv_flvServer.php
55 *
66 * @date Jul 25, 2008
7 - *
 7+ *
88 * this should enable serving segments of flv files
9 - *
 9+ *
1010 * called with: mv_flvServer.php?file=myClip.flv&t=0:01:00/0:02:00
11 - *
 11+ *
1212 * flash does not like get arguments in media files? so best to use mod-rewrite
13 - * something like:
 13+ * something like:
1414 * /flvserver/my_file/start_time/end_time
1515 */
16 -define( 'BASE_LOCAL_CLIP_PATH', '/metavid/video_archive' );
 16+define('BASE_LOCAL_CLIP_PATH', '/metavid/video_archive');
 17+//define('BASE_LOCAL_CLIP_PATH', '/tmp');
1718
18 -define( 'WEB_CLIP_PATH', '/flv_cips' );
19 -define( 'FLASH_VIDEO_CONTENT_TYPE', 'video/x-flv' );
 19+define('WEB_CLIP_PATH', '/flv_cips');
 20+define('FLASH_VIDEO_CONTENT_TYPE', 'video/x-flv');
2021
21 -define( 'AUDIO_FRAME_INTERVAL', 3 );
22 -// what to append to the flv file name to store serialized meta tags:
 22+define('AUDIO_FRAME_INTERVAL', 3);
 23+//what to append to the flv file name to store serialized meta tags:
2324
24 -if ( !function_exists( 'filter_input' ) ) {
25 - die( 'you version of php lacks <b>filter_input()</b> function</br>' );
 25+if(!function_exists('filter_input')){
 26+ die('you version of php lacks <b>filter_input()</b> function</br>');
2627 }
27 -$file_req = filter_input( INPUT_GET, 'file', FILTER_SANITIZE_STRING );
28 -$time_req = filter_input( INPUT_GET, 't', FILTER_SANITIZE_STRING );
2928
30 -// try to grab the file from /filename format
31 -if ( $file_req == '' ) {
32 - if ( isset( $_SERVER['PHP_SELF'] ) ) {
33 - $pathparts = explode( '/', $_SERVER['PHP_SELF'] );
34 - $file_req = ( strpos( $pathparts[count( $pathparts ) - 1], '?' ) !== false ) ?
35 - substr( $pathparts[count( $pathparts ) - 1], 0, strpos( $pathparts[count( $pathparts ) - 1], '?' ) ):
36 - $pathparts[count( $pathparts ) - 1];
 29+do_request();
 30+function do_request(){
 31+ $file_req = filter_input(INPUT_GET, 'file', FILTER_SANITIZE_STRING);
 32+ $time_req = filter_input(INPUT_GET, 't', FILTER_SANITIZE_STRING);
 33+
 34+ //try to grab the file from /filename format
 35+ if($file_req==''){
 36+ if(isset($_SERVER['PHP_SELF'])){
 37+ $pathparts = explode('/',$_SERVER['PHP_SELF']);
 38+ $file_req = (strpos($pathparts[count($pathparts)-1], '?')!==false)?
 39+ substr($pathparts[count($pathparts)-1],0, strpos($pathparts[count($pathparts)-1],'?')):
 40+ $pathparts[count($pathparts)-1];
 41+ }
3742 }
38 -}
39 -// additional filtering to avoid directory traversing:
40 -$file_req = str_replace( array( '../', './' ), '', $file_req );
41 -if ( $file_req == '' )die( 'error: missing file name' );
42 -$file_loc = BASE_LOCAL_CLIP_PATH . '/' . $file_req;
43 -if ( !is_file( $file_loc ) )die( 'error: requested file not found' );
44 -
45 -// if 't' is empty no seeking nessesary:
46 -if ( $time_req == '' ) {
47 - output_full_file( $file_loc );
48 -} else {
49 - // @@todo support more time request formats
50 - if ( strpos( $time_req, '/' ) !== false ) {
51 - list( $start_time_ntp, $end_time_ntp ) = explode( '/', $time_req );
52 - $start_sec = ntp2seconds( $start_time_ntp );
53 - $end_sec = ntp2seconds( $end_time_ntp );
54 - } else {
55 - $start_sec = ntp2seconds( $time_req );
56 - $end_sec = null;
57 - if ( $start_sec == 0 )output_full_file( $file_loc );
 43+ //additional filtering to avoid directory traversing:
 44+ $file_req = str_replace(array('../','./'), '', $file_req);
 45+ if($file_req=='')die('error: missing file name');
 46+ $file_loc =BASE_LOCAL_CLIP_PATH.'/'.$file_req;
 47+ if(!is_file($file_loc))die('error: requested file not found');
 48+
 49+ //if 't' is empty no seeking necessary:
 50+ if($time_req==''){
 51+ output_full_file($file_loc);
 52+ }else{
 53+ //@@todo support more time request formats
 54+ if(strpos( $time_req,'/')!==false){
 55+ list($start_time_ntp, $end_time_ntp)=explode('/',$time_req);
 56+ $start_sec = ntp2seconds($start_time_ntp);
 57+ $end_sec = ntp2seconds($end_time_ntp);
 58+ }else{
 59+ $start_sec = ntp2seconds($time_req);
 60+ $end_sec = null;
 61+ if($start_sec==0)output_full_file($file_loc);
 62+ }
 63+ if($start_sec > $end_sec)die('error: requested invalid time range');
 64+ //print "DO: $start_sec $end_sec \n";
 65+ require_once('MvFlv.php');
 66+ //open up the metavid Flv object:
 67+ $flv = new MyFLV();
 68+ try {
 69+ $flv->open( $file_loc );
 70+ } catch (Exception $e) {
 71+ die("<pre>The following exception was detected while trying to open a FLV file:\n" . $e->getMessage() . "</pre>");
 72+ }
 73+ header('Content-type: '.FLASH_VIDEO_CONTENT_TYPE);
 74+ $one_year = 60*60*24*365;
 75+ header("Expires: " . gmdate( "D, d M Y H:i:s", time() + $one_year ) . " GM");
 76+ //small meta file to parse no big deal:
 77+ list($start_byte, $end_byte) = $flv->getKeyFrameByteTimes($start_sec, $end_sec);
 78+ //send out content length:
 79+ header('Content-Length: ' . ($end_byte - $start_byte) );
 80+ $flv->play($start_byte, $end_byte);
 81+ //$end = microtime(true);
 82+ //file_put_contents('/tmp/time.log', "<hr/>EXTRACT METADATA PROCESS TOOK " . number_format(($end-$start), 2) . " seconds<br/>");
 83+ $flv->close();
5884 }
59 - if ( $start_sec > $end_sec )die( 'error: requested invalid time range' );
60 - // print "DO: $start_sec $end_sec \n";
61 - require_once( 'MvFlv.php' );
62 - // open up the metavid Flv object:
63 - $flv = new MyFLV();
64 - try {
65 - $flv->open( $file_loc );
66 - } catch ( Exception $e ) {
67 - die( "<pre>The following exception was detected while trying to open a FLV file:\n" . $e->getMessage() . "</pre>" );
68 - }
69 - header( 'Content-type: ' . FLASH_VIDEO_CONTENT_TYPE );
70 - // $flv->computeMetaData();
71 - // $start = microtime(true);
72 - list( $start_byte, $end_byte ) = $flv->getByteTimeReq( $start_sec, $end_sec );
73 -
74 - // print "start $start_byte, $end_byte cl:" . ($end_byte-$start_byte);
75 - // die;
76 - header( 'Content-Length: ' . ( $end_byte - $start_byte ) );
77 -
78 - $flv->play( $start_byte, $end_byte );
79 - // $end = microtime(true);
80 - // file_put_contents('/tmp/time.log', "<hr/>EXTRACT METADATA PROCESS TOOK " . number_format(($end-$start), 2) . " seconds<br/>");
81 - $flv->close();
82 -
8385 }
8486
8587
86 -function output_full_file( $file_loc ) {
87 - header( 'Content-Type: ' . FLASH_VIDEO_CONTENT_TYPE );
88 - while ( ob_get_level() > 0 ) {
 88+function output_full_file($file_loc){
 89+ header('Content-Type: '.FLASH_VIDEO_CONTENT_TYPE);
 90+ while (ob_get_level() > 0) {
8991 ob_end_flush();
90 - } // turn off output buffering
91 - @readfile( $file_loc );
 92+ } //turn off output buffering
 93+ @readfile($file_loc);
9294 die();
9395 }
9496
95 -function ntp2seconds( $str_time ) {
96 - $time_ary = explode( ':', $str_time );
97 - $hours = $min = $sec = 0;
98 - if ( count( $time_ary ) == 3 ) {
99 - $hours = $time_ary[0];
100 - $min = $time_ary[1];
101 - $sec = $time_ary[2];
102 - } else if ( count( $time_ary ) == 2 ) {
103 - $min = $time_ary[0];
104 - $sec = $time_ary[1];
105 - } else if ( count( $time_ary ) == 1 ) {
106 - $sec = $time_ary[0];
107 - }
108 - return ( $hours * 3600 ) + ( $min * 60 ) + $sec;
 97+function ntp2seconds($str_time){
 98+ $time_ary = explode(':', $str_time);
 99+ $hours=$min=$sec=0;
 100+ if(count($time_ary)==3){
 101+ $hours=$time_ary[0];
 102+ $min=$time_ary[1];
 103+ $sec=$time_ary[2];
 104+ }else if(count($time_ary)==2){
 105+ $min=$time_ary[0];
 106+ $sec=$time_ary[1];
 107+ }else if(count($time_ary)==1){
 108+ $sec=$time_ary[0];
 109+ }
 110+ return ($hours*3600) + ($min*60) + $sec;
109111 }
 112+?>

Status & tagging log