Index: trunk/extensions/OggHandler/OggHandler.php |
— | — | @@ -59,6 +59,9 @@ |
60 | 60 | //if we should enable iframe embedding of form ?title=File:name&iframe=true |
61 | 61 | $wgEnableIframeEmbed = true; |
62 | 62 | |
| 63 | +//Location of oggThumb binary (used over the ffmpeg version) |
| 64 | +$wgOggThumbLocation = '/usr/bin/oggThumb'; |
| 65 | + |
63 | 66 | // Location of the FFmpeg binary |
64 | 67 | $wgFFmpegLocation = '/usr/bin/ffmpeg'; |
65 | 68 | |
Index: trunk/extensions/OggHandler/OggHandler_body.php |
— | — | @@ -266,6 +266,17 @@ |
267 | 267 | return new OggVideoDisplay( $file, $targetFileUrl, $dstUrl, $width, $height, $length, $dstPath, $noIcon, $offset); |
268 | 268 | } |
269 | 269 | |
| 270 | + $thumbStatus = $this->gennerateThumb($file, $dstPath,$params, $width, $height); |
| 271 | + if( $thumbStatus !== true ) |
| 272 | + return $thumbStatus; |
| 273 | + |
| 274 | + |
| 275 | + return new OggVideoDisplay( $file, $targetFileUrl, $dstUrl, $width, $height, $length, $dstPath ); |
| 276 | + } |
| 277 | + function gennerateThumb($file, $dstPath, $params, $width, $height){ |
| 278 | + global $wgFFmpegLocation, $wgOggThumbLocation; |
| 279 | + |
| 280 | + $length = $this->getLength( $file ); |
270 | 281 | $thumbtime = false; |
271 | 282 | if ( isset( $params['thumbtime'] ) ) { |
272 | 283 | $thumbtime = $this->parseTimeString( $params['thumbtime'], $length ); |
— | — | @@ -283,6 +294,31 @@ |
284 | 295 | |
285 | 296 | wfDebug( "Creating video thumbnail at $dstPath\n" ); |
286 | 297 | |
| 298 | + //first check for oggThumb |
| 299 | + if( $wgOggThumbLocation && is_file( $wgOggThumbLocation ) ){ |
| 300 | + $cmd = wfEscapeShellArg( $wgOggThumbLocation ) . |
| 301 | + ' -t '. intval( $thumbtime ) . ' ' . |
| 302 | + ' ' . wfEscapeShellArg( $file->getPath() ) . ' 2>&1'; |
| 303 | + //@@NOTE target output file argument support is on the way |
| 304 | + //(will be in the next release of oggThumb) |
| 305 | + $orgPath = getcwd(); |
| 306 | + //change to destination path: |
| 307 | + chdir( dirname( $dstPath ) ); |
| 308 | + $retval = 0; |
| 309 | + $returnText = wfShellExec( $cmd, $retval ); |
| 310 | + //check for the file: |
| 311 | + $name = substr( $file->getName(), 0, strrpos( $file->getName(), '.')); |
| 312 | + if( is_file( $name ) . '_0.jpg' ){ |
| 313 | + rename( $name . '_0.jpg', $dstPath); |
| 314 | + } |
| 315 | + //change back to the orgPath |
| 316 | + chdir( $orgPath ); |
| 317 | + //check if it was successful or if we should try ffmpeg: |
| 318 | + if( is_file ( $dstPath ) ){ |
| 319 | + return true; |
| 320 | + } |
| 321 | + } |
| 322 | + |
287 | 323 | $cmd = wfEscapeShellArg( $wgFFmpegLocation ) . |
288 | 324 | ' -ss ' . intval( $thumbtime ) . ' ' . |
289 | 325 | ' -i ' . wfEscapeShellArg( $file->getPath() ) . |
— | — | @@ -332,11 +368,9 @@ |
333 | 369 | return new MediaTransformError( 'thumbnail_error', $width, $height, implode( "\n", $lines ) ); |
334 | 370 | } |
335 | 371 | } |
336 | | - |
337 | | - |
338 | | - return new OggVideoDisplay( $file, $targetFileUrl, $dstUrl, $width, $height, $length, $dstPath ); |
| 372 | + //if we did not return an error return true to continue media thum display |
| 373 | + return true; |
339 | 374 | } |
340 | | - |
341 | 375 | function canRender( $file ) { return true; } |
342 | 376 | function mustRender( $file ) { return true; } |
343 | 377 | |
— | — | @@ -654,8 +688,7 @@ |
655 | 689 | Xml::tags('div', array( |
656 | 690 | 'style'=>"overflow:hidden;". |
657 | 691 | "width:{$width}px;height:{$playerHeight}px;". |
658 | | - "border:solid thin black;padding:5px;", |
659 | | - 'class'=>'videonojs' |
| 692 | + "border:solid thin black;padding:5px;" |
660 | 693 | ), |
661 | 694 | wfMsg('ogg-no-player-js', $url) |
662 | 695 | ) |
— | — | @@ -829,7 +862,7 @@ |
830 | 863 | </style> |
831 | 864 | <?php |
832 | 865 | //similar to $out->headElement (but without css) |
833 | | - echo $wgUser->getSkin()->getHeadScripts( $out ); |
| 866 | + echo $out->getHeadScripts(); |
834 | 867 | echo $out->getHeadLinks(); |
835 | 868 | echo $out->getHeadItems(); |
836 | 869 | ?> |