Index: trunk/extensions/OggHandler/OggHandler.php |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | $wgPlayerStatsCollection=false; |
45 | 45 | |
46 | 46 | // Location of the FFmpeg binary |
47 | | -$wgFFmpegLocation = 'ffmpeg'; |
| 47 | +$wgFFmpegLocation = '/usr/bin/ffmpeg'; |
48 | 48 | |
49 | 49 | // Filename or URL path to the Cortado Java player applet. |
50 | 50 | // |
Index: trunk/extensions/OggHandler/PEAR/File_Ogg/File/Ogg.php |
— | — | @@ -164,7 +164,7 @@ |
165 | 165 | * Total length in seconds of the entire file |
166 | 166 | */ |
167 | 167 | var $_totalLength; |
168 | | - |
| 168 | + var $_startOffset = false; |
169 | 169 | /** |
170 | 170 | * Returns an interface to an Ogg physical stream. |
171 | 171 | * |
— | — | @@ -456,8 +456,13 @@ |
457 | 457 | if (isset($groupLengths[$group])) { |
458 | 458 | $groupLengths[$group] = max($groupLengths[$group], $stream->getLength()); |
459 | 459 | } else { |
460 | | - $groupLengths[$group] = $stream->getLength(); |
| 460 | + $groupLengths[$group] = $stream->getLength(); |
461 | 461 | } |
| 462 | + //just store the startOffset for the first stream: |
| 463 | + if( $this->_startOffset === false ){ |
| 464 | + $this->_startOffset = $stream->getStartOffset(); |
| 465 | + } |
| 466 | + |
462 | 467 | } |
463 | 468 | } |
464 | 469 | $this->_groupLengths = $groupLengths; |
— | — | @@ -570,8 +575,17 @@ |
571 | 576 | else |
572 | 577 | return array(); |
573 | 578 | } |
574 | | - |
575 | 579 | /** |
| 580 | + * getStartOffset |
| 581 | + * |
| 582 | + * @return unknown |
| 583 | + */ |
| 584 | + function getStartOffset(){ |
| 585 | + if( $this->_startOffset === false) |
| 586 | + return 0; |
| 587 | + return $this->_startOffset; |
| 588 | + } |
| 589 | + /** |
576 | 590 | * Get the total length of the group of streams |
577 | 591 | */ |
578 | 592 | function getLength() { |
Index: trunk/extensions/OggHandler/PEAR/File_Ogg/File/Ogg/Media.php |
— | — | @@ -48,7 +48,9 @@ |
49 | 49 | * Length of the stream in seconds |
50 | 50 | */ |
51 | 51 | var $_streamLength; |
52 | | - |
| 52 | + |
| 53 | + /* Start offset of the stream in seconds */ |
| 54 | + var $_startOffset = 0; |
53 | 55 | /*function File_Ogg_Media($streamSerial, $streamData, $filePointer) |
54 | 56 | { |
55 | 57 | File_Ogg_Bitstream::File_Ogg_Bitstream($streamSerial, $streamData, $filePointer); |
— | — | @@ -224,4 +226,12 @@ |
225 | 227 | { |
226 | 228 | return $this->_streamLength; |
227 | 229 | } |
| 230 | + /** |
| 231 | + * Get the start offset of the stream in seconds |
| 232 | + * |
| 233 | + * @return float |
| 234 | + */ |
| 235 | + function getStartOffset(){ |
| 236 | + return $this->_startOffset; |
| 237 | + } |
228 | 238 | } |
Index: trunk/extensions/OggHandler/PEAR/File_Ogg/File/Ogg/Theora.php |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | * @version CVS: $Id: Theora.php,v 1.9 2005/11/16 20:43:27 djg Exp $ |
42 | 42 | */ |
43 | 43 | class File_Ogg_Theora extends File_Ogg_Media |
44 | | -{ |
| 44 | +{ |
45 | 45 | /** |
46 | 46 | * @access private |
47 | 47 | */ |
— | — | @@ -54,10 +54,12 @@ |
55 | 55 | $startSec = $this->getSecondsFromGranulePos( $this->_firstGranulePos ); |
56 | 56 | |
57 | 57 | //make sure the offset is worth taking into account oggz_chop related hack |
58 | | - if( $startSec > 1) |
| 58 | + if( $startSec > 1){ |
59 | 59 | $this->_streamLength = $endSec - $startSec; |
60 | | - else |
| 60 | + $this->_startOffset = $startSec; |
| 61 | + }else{ |
61 | 62 | $this->_streamLength = $endSec; |
| 63 | + } |
62 | 64 | |
63 | 65 | /*print "last gran: $this->_lastGranulePos = $endSec \n |
64 | 66 | first gran: $this->_firstGranulePos = $startSec \n |
Index: trunk/extensions/OggHandler/PEAR/File_Ogg/File/Ogg/Speex.php |
— | — | @@ -54,10 +54,12 @@ |
55 | 55 | / $this->_header['rate']; |
56 | 56 | |
57 | 57 | //make sure the offset is worth taking into account oggz_chop related hack |
58 | | - if( $startSec > 1) |
| 58 | + if( $startSec > 1){ |
59 | 59 | $this->_streamLength = $endSec - $startSec; |
60 | | - else |
| 60 | + $this->_startOffset = $startSec; |
| 61 | + }else{ |
61 | 62 | $this->_streamLength = $endSec; |
| 63 | + } |
62 | 64 | } |
63 | 65 | |
64 | 66 | /** |
Index: trunk/extensions/OggHandler/PEAR/File_Ogg/File/Ogg/Vorbis.php |
— | — | @@ -148,10 +148,13 @@ |
149 | 149 | * @access private |
150 | 150 | * @var int |
151 | 151 | */ |
152 | | - var $_streamLength; |
153 | | - |
| 152 | + var $_streamLength; |
154 | 153 | |
155 | 154 | /** |
| 155 | + * the start offset of this stream in seconds |
| 156 | + */ |
| 157 | + var $_startOffset; |
| 158 | + /** |
156 | 159 | * Constructor for accessing a Vorbis logical stream. |
157 | 160 | * |
158 | 161 | * This method is the constructor for the native-PHP interface to a Vorbis logical |
— | — | @@ -180,10 +183,12 @@ |
181 | 184 | $this->_streamLength = $stream_endLength - $stream_startLength; |
182 | 185 | |
183 | 186 | //make sure the offset is worth taking into account oggz_chop related hack |
184 | | - if( $startSec > 1) |
| 187 | + if( $startSec > 1){ |
185 | 188 | $this->_streamLength = $endSec - $startSec; |
186 | | - else |
| 189 | + $this->_startOffset = $startSec; |
| 190 | + }else{ |
187 | 191 | $this->_streamLength = $endSec; |
| 192 | + } |
188 | 193 | |
189 | 194 | $this->_avgBitrate = $this->_streamLength ? ($this->_streamSize * 8) / $this->_streamLength : 0; |
190 | 195 | } |
— | — | @@ -386,7 +391,14 @@ |
387 | 392 | { |
388 | 393 | return ($this->_streamLength); |
389 | 394 | } |
390 | | - |
| 395 | + /** |
| 396 | + * Get the start offset of the stream in seconds |
| 397 | + * @access public |
| 398 | + * @return int |
| 399 | + */ |
| 400 | + function getStartOffset(){ |
| 401 | + return ($this->_startOffset); |
| 402 | + } |
391 | 403 | /** |
392 | 404 | * States whether this logical stream was encoded in mono. |
393 | 405 | * |
Index: trunk/extensions/OggHandler/OggHandler_body.php |
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | 'group' => $stream->getGroup(), |
132 | 132 | 'type' => $stream->getType(), |
133 | 133 | 'vendor' => $stream->getVendor(), |
134 | | - 'length' => $stream->getLength(), |
| 134 | + 'length' => $stream->getLength(), |
135 | 135 | 'size' => $stream->getSize(), |
136 | 136 | 'header' => $stream->getHeader(), |
137 | 137 | 'comments' => $stream->getComments() |
— | — | @@ -138,7 +138,9 @@ |
139 | 139 | } |
140 | 140 | } |
141 | 141 | $metadata['streams'] = $streams; |
142 | | - $metadata['length'] = $f->getLength(); |
| 142 | + $metadata['length'] = $f->getLength(); |
| 143 | + //get the offset of the file (in cases where the file is a segment copy) |
| 144 | + $metadata['offset'] = $f->getStartOffset(); |
143 | 145 | } catch ( PEAR_Exception $e ) { |
144 | 146 | // File not found, invalid stream, etc. |
145 | 147 | $metadata['error'] = array( |
— | — | @@ -178,6 +180,7 @@ |
179 | 181 | $srcHeight = $file->getHeight(); |
180 | 182 | $height = $srcWidth == 0 ? $srcHeight : $width * $srcHeight / $srcWidth; |
181 | 183 | $length = $this->getLength( $file ); |
| 184 | + $offset = $this->getOffset( $file ); |
182 | 185 | $noPlayer = isset( $params['noplayer'] ); |
183 | 186 | $noIcon = isset( $params['noicon'] ); |
184 | 187 | |
— | — | @@ -206,16 +209,16 @@ |
207 | 210 | } else { |
208 | 211 | $width = $params['width']; |
209 | 212 | } |
210 | | - return new OggAudioDisplay( $file, $file->getURL(), $width, $height, $length, $dstPath, $noIcon ); |
| 213 | + return new OggAudioDisplay( $file, $file->getURL(), $width, $height, $length, $dstPath, $noIcon, $offset ); |
211 | 214 | } |
212 | 215 | |
213 | 216 | // Video thumbnail only |
214 | 217 | if ( $noPlayer ) { |
215 | | - return new ThumbnailImage( $file, $dstUrl, $width, $height, $dstPath ); |
| 218 | + return new ThumbnailImage( $file, $dstUrl, $width, $height, $dstPath , $noIcon, $offset); |
216 | 219 | } |
217 | 220 | |
218 | 221 | if ( $flags & self::TRANSFORM_LATER ) { |
219 | | - return new OggVideoDisplay( $file, $file->getURL(), $dstUrl, $width, $height, $length, $dstPath ); |
| 222 | + return new OggVideoDisplay( $file, $file->getURL(), $dstUrl, $width, $height, $length, $dstPath, $noIcon, $offset); |
220 | 223 | } |
221 | 224 | |
222 | 225 | $thumbTime = false; |
— | — | @@ -315,6 +318,14 @@ |
316 | 319 | return $metadata['length']; |
317 | 320 | } |
318 | 321 | } |
| 322 | + function getOffset( $file ){ |
| 323 | + $metadata = $this->unpackMetadata( $file->getMetadata() ); |
| 324 | + if ( !$metadata || isset( $metadata['error'] ) ) { |
| 325 | + return 0; |
| 326 | + } else { |
| 327 | + return $metadata['offset']; |
| 328 | + } |
| 329 | + } |
319 | 330 | |
320 | 331 | function getStreamTypes( $file ) { |
321 | 332 | $streamTypes = ''; |
— | — | @@ -486,7 +497,7 @@ |
487 | 498 | static $serial = 0; |
488 | 499 | |
489 | 500 | function __construct( $file, $videoUrl, $thumbUrl, $width, $height, $length, $isVideo, |
490 | | - $path, $noIcon = false ) |
| 501 | + $path, $noIcon = false, $offset ) |
491 | 502 | { |
492 | 503 | $this->file = $file; |
493 | 504 | $this->videoUrl = $videoUrl; |
— | — | @@ -494,6 +505,7 @@ |
495 | 506 | $this->width = round( $width ); |
496 | 507 | $this->height = round( $height ); |
497 | 508 | $this->length = round( $length ); |
| 509 | + $this->offset = round( $offset ); |
498 | 510 | $this->isVideo = $isVideo; |
499 | 511 | $this->path = $path; |
500 | 512 | $this->noIcon = $noIcon; |
— | — | @@ -514,6 +526,7 @@ |
515 | 527 | $url = $this->videoUrl; |
516 | 528 | } |
517 | 529 | $length = intval( $this->length ); |
| 530 | + $offset = intval( $this->offset ); |
518 | 531 | $width = intval( $this->width ); |
519 | 532 | $height = intval( $this->height ); |
520 | 533 | $alt = empty( $options['alt'] ) ? $this->file->getTitle()->getText() : $options['alt']; |
— | — | @@ -591,6 +604,7 @@ |
592 | 605 | 'width' => $width, |
593 | 606 | 'height' => $playerHeight, |
594 | 607 | 'length' => $length, |
| 608 | + 'offset' => $offset, |
595 | 609 | 'linkUrl' => $linkUrl, |
596 | 610 | 'isVideo' => $this->isVideo ) ); |
597 | 611 | |
— | — | @@ -623,14 +637,14 @@ |
624 | 638 | } |
625 | 639 | |
626 | 640 | class OggVideoDisplay extends OggTransformOutput { |
627 | | - function __construct( $file, $videoUrl, $thumbUrl, $width, $height, $length, $path ) { |
628 | | - parent::__construct( $file, $videoUrl, $thumbUrl, $width, $height, $length, true, $path, false ); |
| 641 | + function __construct( $file, $videoUrl, $thumbUrl, $width, $height, $length, $path, $noIcon=false, $offset=0 ) { |
| 642 | + parent::__construct( $file, $videoUrl, $thumbUrl, $width, $height, $length, true, $path, false, $offset ); |
629 | 643 | } |
630 | 644 | } |
631 | 645 | |
632 | 646 | class OggAudioDisplay extends OggTransformOutput { |
633 | | - function __construct( $file, $videoUrl, $width, $height, $length, $path, $noIcon = false ) { |
634 | | - parent::__construct( $file, $videoUrl, false, $width, $height, $length, false, $path, $noIcon ); |
| 647 | + function __construct( $file, $videoUrl, $width, $height, $length, $path, $noIcon = false, $offset=0 ) { |
| 648 | + parent::__construct( $file, $videoUrl, false, $width, $height, $length, false, $path, $noIcon, $offset ); |
635 | 649 | } |
636 | 650 | } |
637 | 651 | |