Index: trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.inc.php |
— | — | @@ -183,9 +183,8 @@ |
184 | 184 | } |
185 | 185 | |
186 | 186 | //check archive.org paths: |
187 | | - ao_file_Ogg_Video |
188 | 187 | |
189 | | - |
| 188 | + |
190 | 189 | if ( count( $set ) == 0 ) { |
191 | 190 | // no files present (remove stream) |
192 | 191 | 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 @@ |
374 | 374 | } |
375 | 375 | |
376 | 376 | //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>" ); |
379 | 379 | |
380 | 380 | $mvCssUrl = $mvgScriptPath . '/skins/mv_custom.css'; |
381 | 381 | $wgOut->addLink( array( |
Index: trunk/extensions/MetavidWiki/includes/MV_Settings.php |
— | — | @@ -1,5 +1,222 @@ |
2 | 2 | <? |
3 | 3 | 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 | + |
6 | 223 | ?> |
\ No newline at end of file |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js |
— | — | @@ -89,17 +89,17 @@ |
90 | 90 | |
91 | 91 | "clip_linkback" : "Clip Source Page", |
92 | 92 | |
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>", |
104 | 104 | |
105 | 105 | "add_to_end_of_sequence" : "Add to End of Sequence", |
106 | 106 | |
— | — | @@ -170,8 +170,7 @@ |
171 | 171 | //two loading stages, first get jQuery |
172 | 172 | var _this = this; |
173 | 173 | 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' |
176 | 175 | },function(){ |
177 | 176 | //once jQuery is loaded set up no conflict & load plugins: |
178 | 177 | _global['$j'] = jQuery.noConflict(); |
— | — | @@ -182,7 +181,8 @@ |
183 | 182 | js_log('jquery loaded'); |
184 | 183 | //load the jQuery dependent plugins: |
185 | 184 | 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', |
187 | 187 | '$j.ui.droppable' : 'jquery/jquery.ui-1.5.2/ui/minified/ui.droppable.min.js', |
188 | 188 | '$j.ui.draggable' : 'jquery/jquery.ui-1.5.2/ui/minified/ui.draggable.min.js' |
189 | 189 | },function(){ |
— | — | @@ -229,7 +229,7 @@ |
230 | 230 | } |
231 | 231 | } |
232 | 232 | if( all_libs_loaded ){ |
233 | | - js_log('all libs already loaded skiping...' + libs); |
| 233 | + js_log('all libs already loaded skipping...' + libs); |
234 | 234 | callback(); |
235 | 235 | return ; |
236 | 236 | } |
— | — | @@ -360,7 +360,7 @@ |
361 | 361 | }, |
362 | 362 | getName : function() |
363 | 363 | { |
364 | | - return gM('ogg-player-' + this.id); |
| 364 | + return gM('mv_ogg-player-' + this.id); |
365 | 365 | }, |
366 | 366 | load : function(callback) |
367 | 367 | { |
— | — | @@ -589,6 +589,7 @@ |
590 | 590 | (secure ? "; secure" : ""); |
591 | 591 | } |
592 | 592 | js_log("mv embed path:"+ mv_embed_path); |
| 593 | + |
593 | 594 | /* |
594 | 595 | * embedTypes object handles setting and getting of supported embed types: |
595 | 596 | * closely mirrors OggHandler so that its easier to share efforts in this area: |
— | — | @@ -959,7 +960,7 @@ |
960 | 961 | mvJsLoader.loadBaseLibs(function(){ |
961 | 962 | //load search specifc extra stuff |
962 | 963 | mvJsLoader.doLoad({ |
963 | | - 'mvBaseRemoteSearch':'libAddMedia/remoteSearchDriver.js' |
| 964 | + 'remoteSearchDriver':'libAddMedia/remoteSearchDriver.js' |
964 | 965 | }, function(){ |
965 | 966 | initObj['instance_name']= 'rsdMVRS'; |
966 | 967 | rsdMVRS = new remoteSearchDriver( initObj ); |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedObj/mv_baseEmbed.js |
— | — | @@ -223,7 +223,7 @@ |
224 | 224 | } |
225 | 225 | }, |
226 | 226 | 'play_head':{ |
227 | | - 'w':0, //special case (takes up remaning space) |
| 227 | + 'w':0, //special case (takes up remaining space) |
228 | 228 | 'o':function(){ |
229 | 229 | return '<div class="seeker" id="mv_seeker_'+ctrlBuilder.id+'" style="width: ' + (ctrlBuilder.avaliable_width - 18) + 'px;">'+ |
230 | 230 | ' <div id="seeker_bar_'+ctrlBuilder.id+'" class="seeker_bar">'+ |
— | — | @@ -306,8 +306,7 @@ |
307 | 307 | this[ attr ] = $j(element).attr( attr ); |
308 | 308 | } |
309 | 309 | } |
310 | | - |
311 | | - |
| 310 | + |
312 | 311 | if ( $j(element).attr('type')) |
313 | 312 | this.mime_type = $j(element).attr('type'); |
314 | 313 | else if ($j(element).attr('content-type')) |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mvwScriptLoader.php |
— | — | @@ -123,7 +123,7 @@ |
124 | 124 | //cache forever: |
125 | 125 | //(the point is we never have to re validate since we should always change the request url based on the svn version) |
126 | 126 | $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"); |
128 | 128 | } |
129 | 129 | /* |
130 | 130 | * updates the proc Request |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/flvServer/MvFlv.php |
— | — | @@ -2,149 +2,184 @@ |
3 | 3 | |
4 | 4 | include_once 'FLV/FLV.php'; |
5 | 5 | |
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 |
8 | 8 | |
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 |
11 | 11 | |
12 | 12 | class MyFLV extends FLV { |
13 | | - |
| 13 | + |
14 | 14 | /** |
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 |
16 | 16 | */ |
17 | 17 | private $audioFrameGap = 3; |
18 | | - |
| 18 | + |
19 | 19 | private $origMetaOfs = 0; |
20 | 20 | private $origMetaSize = 0; |
21 | 21 | private $origMetaData; |
22 | 22 | 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) |
33 | 33 | $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; |
48 | 48 | } |
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]; |
53 | 53 | 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; |
55 | 78 | } |
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 | + } |
59 | 89 | function computeMetaData() |
60 | 90 | { |
61 | | - ini_set( "max_execution_time", "0" );// computeMetaData can take some time |
| 91 | + ini_set("max_execution_time","0");//computeMetaData can take some time |
62 | 92 | $this->compMetaData = array(); |
63 | 93 | $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'; |
65 | 95 | $this->compMetaData['keyframes'] = array(); |
66 | 96 | $this->compMetaData['keyframes']['filepositions'] = array(); |
67 | 97 | $this->compMetaData['keyframes']['times'] = array(); |
68 | | - |
| 98 | + $this->compMetaData['lasttimestamp'] = -1; |
| 99 | + |
69 | 100 | $this->origMetaOfs = 0; |
70 | 101 | $this->origMetaSize = 0; |
71 | 102 | $this->origMetaData = null; |
72 | | - $oldTs = 0; |
73 | | - $this->compMetaData['lasttimestamp'] = 0; |
74 | | - |
| 103 | + |
75 | 104 | $skipTagTypes = array(); |
76 | | - while ( $tag = $this->getTag( $skipTagTypes ) ) |
| 105 | + while ($tag = $this->getTag( $skipTagTypes )) |
77 | 106 | { |
78 | 107 | // 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']){ |
83 | 112 | $this->wrapTimeCount++; |
84 | 113 | $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) |
90 | 120 | { |
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) |
94 | 124 | { |
95 | 125 | $this->compMetaData['keyframes']['filepositions'][] = $this->getTagOffset(); |
96 | 126 | $this->compMetaData['keyframes']['times'][] = $ts; |
97 | 127 | } |
98 | | - |
99 | | - if ( !in_array( FLV_TAG::TYPE_VIDEO, $skipTagTypes ) ) |
| 128 | + |
| 129 | + if ( !in_array(FLV_TAG::TYPE_VIDEO, $skipTagTypes) ) |
100 | 130 | { |
101 | 131 | $this->compMetaData['width'] = $tag->width; |
102 | 132 | $this->compMetaData['height'] = $tag->height; |
103 | 133 | $this->compMetaData['videocodecid'] = $tag->codec; |
104 | | - // Processing one video tag is enough |
| 134 | + //Processing one video tag is enough |
105 | 135 | array_push( $skipTagTypes, FLV_Tag::TYPE_VIDEO ); |
106 | | - } |
| 136 | + } |
107 | 137 | break; |
| 138 | + |
108 | 139 | 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) |
111 | 143 | { |
112 | 144 | $this->compMetaData['keyframes']['filepositions'][] = $this->getTagOffset(); |
113 | 145 | $this->compMetaData['keyframes']['times'][] = $ts; |
114 | 146 | $oldTs = $ts; |
115 | 147 | } |
116 | | - if ( !in_array( FLV_Tag::TYPE_AUDIO, $skipTagTypes ) ) |
| 148 | + |
| 149 | + if ( !in_array( FLV_Tag::TYPE_AUDIO, $skipTagTypes) ) |
117 | 150 | { |
118 | 151 | $this->compMetaData['audiocodecid'] = $tag->codec; |
119 | 152 | $this->compMetaData['audiofreqid'] = $tag->frequency; |
120 | 153 | $this->compMetaData['audiodepthid'] = $tag->depth; |
121 | 154 | $this->compMetaData['audiomodeid'] = $tag->mode; |
122 | | - |
123 | | - // Processing one audio tag is enough |
| 155 | + |
| 156 | + //Processing one audio tag is enough |
124 | 157 | array_push( $skipTagTypes, FLV_Tag::TYPE_AUDIO ); |
125 | | - } |
126 | | - break; |
| 158 | + } */ |
| 159 | + |
| 160 | + break; |
| 161 | + |
127 | 162 | case FLV_Tag::TYPE_DATA : |
128 | | - if ( $tag->name == 'onMetaData' ) |
| 163 | + if ($tag->name == 'onMetaData') |
129 | 164 | { |
130 | 165 | $this->origMetaOfs = $this->getTagOffset(); |
131 | 166 | $this->origMetaSize = $tag->size + self::TAG_HEADER_SIZE; |
132 | 167 | $this->origMetaData = $tag->value; |
133 | 168 | } |
134 | | - break; |
| 169 | + break; |
135 | 170 | } |
136 | | - |
137 | | - // Does this actually help with memory allocation? |
138 | | - unset( $tag ); |
| 171 | + |
| 172 | + //Does this actually help with memory allocation? |
| 173 | + unset($tag); |
139 | 174 | } |
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 | + |
144 | 179 | $this->compMetaData['duration'] = $this->compMetaData['lasttimestamp']; |
145 | | - |
| 180 | + |
146 | 181 | return $this->compMetaData; |
147 | 182 | } |
148 | | - |
| 183 | + |
149 | 184 | function setMetaData( $metadata, $origMetaOfs = 0, $origMetaSize = 0 ) |
150 | 185 | { |
151 | 186 | $this->compMetaData = $metadata; |
— | — | @@ -154,111 +189,112 @@ |
155 | 190 | /* returns merged metadata*/ |
156 | 191 | function getMetaData() |
157 | 192 | { |
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{ |
162 | 197 | $this->computeMetaData(); |
163 | | - if ( ! is_array( $this->origMetaData ) ) { |
| 198 | + if (! is_array($this->origMetaData)){ |
164 | 199 | $this->fullMeta = $this->compMetaData; |
165 | | - } else { |
| 200 | + }else{ |
166 | 201 | $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 | + } |
179 | 214 | return $this->fullMeta; |
180 | 215 | } |
181 | | - function getKeyFrameMetaData() { |
| 216 | + function getKeyFrameMetaData(){ |
182 | 217 | $meta = & $this->getMetaData(); |
183 | 218 | return $meta['keyframes']; |
184 | 219 | } |
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 |
188 | 223 | $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 |
191 | 226 | return $meta; |
192 | | - } |
193 | | - function play( $from = 0, $play_to = null ) |
| 227 | + } |
| 228 | + function play( $from = 0, $play_to=null ) |
194 | 229 | { |
195 | | - fseek( $this->fp, 0 ); |
196 | | - |
| 230 | + fseek($this->fp, 0); |
| 231 | + |
197 | 232 | // 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 | + |
200 | 235 | // 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)) |
205 | 240 | { |
206 | | - // serialize the metadata as an AMF stream |
| 241 | + //serialize the metadata as an AMF stream |
207 | 242 | include_once 'FLV/Util/AMFSerialize.php'; |
208 | 243 | $amf = new FLV_Util_AMFSerialize(); |
209 | 244 | |
210 | | - $serMeta = $amf->serialize( 'onMetaData' ); |
211 | | - $serMeta .= $amf->serialize( $meta ); |
| 245 | + $serMeta = $amf->serialize('onMetaData'); |
| 246 | + $serMeta.= $amf->serialize($meta); |
212 | 247 | |
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 | + |
222 | 257 | echo $out; |
223 | 258 | echo $serMeta; |
224 | | - |
| 259 | + |
225 | 260 | // PrevTagSize for the metadata |
226 | | - echo pack( 'N', strlen( $serMeta ) + strlen( $out ) ); |
| 261 | + echo pack('N', strlen($serMeta) + strlen($out) ); |
227 | 262 | } |
228 | | - |
| 263 | + |
229 | 264 | $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)) |
234 | 269 | { |
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 | + |
240 | 275 | // check if we are going to output it in this loop step |
241 | 276 | if ( $pos <= $this->origMetaOfs && |
242 | 277 | $pos + $chunkSize > $this->origMetaOfs ) |
243 | 278 | { |
244 | 279 | // 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 | + |
248 | 283 | // 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 | + |
251 | 286 | $skippedOrigMeta = true; |
252 | 287 | continue; |
253 | 288 | } |
254 | 289 | } |
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); |
259 | 294 | break; |
260 | 295 | } |
261 | 296 | } |
262 | | - echo fread( $this->fp, $chunkSize ); |
| 297 | + echo fread($this->fp, $chunkSize); |
263 | 298 | } |
264 | 299 | } |
265 | 300 | } |
| 301 | +?> |
\ No newline at end of file |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/flvServer/mvFlvServer.php |
— | — | @@ -1,108 +1,111 @@ |
2 | 2 | <?php |
3 | 3 | /* |
4 | | - * mv_flvServer.php |
| 4 | + * mv_flvServer.php |
5 | 5 | * |
6 | 6 | * @date Jul 25, 2008 |
7 | | - * |
| 7 | + * |
8 | 8 | * this should enable serving segments of flv files |
9 | | - * |
| 9 | + * |
10 | 10 | * called with: mv_flvServer.php?file=myClip.flv&t=0:01:00/0:02:00 |
11 | | - * |
| 11 | + * |
12 | 12 | * flash does not like get arguments in media files? so best to use mod-rewrite |
13 | | - * something like: |
| 13 | + * something like: |
14 | 14 | * /flvserver/my_file/start_time/end_time |
15 | 15 | */ |
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'); |
17 | 18 | |
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'); |
20 | 21 | |
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: |
23 | 24 | |
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>'); |
26 | 27 | } |
27 | | -$file_req = filter_input( INPUT_GET, 'file', FILTER_SANITIZE_STRING ); |
28 | | -$time_req = filter_input( INPUT_GET, 't', FILTER_SANITIZE_STRING ); |
29 | 28 | |
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 | + } |
37 | 42 | } |
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(); |
58 | 84 | } |
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 | | - |
83 | 85 | } |
84 | 86 | |
85 | 87 | |
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) { |
89 | 91 | ob_end_flush(); |
90 | | - } // turn off output buffering |
91 | | - @readfile( $file_loc ); |
| 92 | + } //turn off output buffering |
| 93 | + @readfile($file_loc); |
92 | 94 | die(); |
93 | 95 | } |
94 | 96 | |
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; |
109 | 111 | } |
| 112 | +?> |