r57294 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57293‎ | r57294 | r57295 >
Date:15:57, 2 October 2009
Author:dale
Status:deferred
Tags:
Comment:
* added support for oggThumb ( alternative to ffmpeg )
Modified paths:
  • /trunk/extensions/OggHandler/OggHandler.php (modified) (history)
  • /trunk/extensions/OggHandler/OggHandler_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OggHandler/OggHandler.php
@@ -59,6 +59,9 @@
6060 //if we should enable iframe embedding of form ?title=File:name&iframe=true
6161 $wgEnableIframeEmbed = true;
6262
 63+//Location of oggThumb binary (used over the ffmpeg version)
 64+$wgOggThumbLocation = '/usr/bin/oggThumb';
 65+
6366 // Location of the FFmpeg binary
6467 $wgFFmpegLocation = '/usr/bin/ffmpeg';
6568
Index: trunk/extensions/OggHandler/OggHandler_body.php
@@ -266,6 +266,17 @@
267267 return new OggVideoDisplay( $file, $targetFileUrl, $dstUrl, $width, $height, $length, $dstPath, $noIcon, $offset);
268268 }
269269
 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 );
270281 $thumbtime = false;
271282 if ( isset( $params['thumbtime'] ) ) {
272283 $thumbtime = $this->parseTimeString( $params['thumbtime'], $length );
@@ -283,6 +294,31 @@
284295
285296 wfDebug( "Creating video thumbnail at $dstPath\n" );
286297
 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+
287323 $cmd = wfEscapeShellArg( $wgFFmpegLocation ) .
288324 ' -ss ' . intval( $thumbtime ) . ' ' .
289325 ' -i ' . wfEscapeShellArg( $file->getPath() ) .
@@ -332,11 +368,9 @@
333369 return new MediaTransformError( 'thumbnail_error', $width, $height, implode( "\n", $lines ) );
334370 }
335371 }
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;
339374 }
340 -
341375 function canRender( $file ) { return true; }
342376 function mustRender( $file ) { return true; }
343377
@@ -654,8 +688,7 @@
655689 Xml::tags('div', array(
656690 'style'=>"overflow:hidden;".
657691 "width:{$width}px;height:{$playerHeight}px;".
658 - "border:solid thin black;padding:5px;",
659 - 'class'=>'videonojs'
 692+ "border:solid thin black;padding:5px;"
660693 ),
661694 wfMsg('ogg-no-player-js', $url)
662695 )
@@ -829,7 +862,7 @@
830863 </style>
831864 <?php
832865 //similar to $out->headElement (but without css)
833 - echo $wgUser->getSkin()->getHeadScripts( $out );
 866+ echo $out->getHeadScripts();
834867 echo $out->getHeadLinks();
835868 echo $out->getHeadItems();
836869 ?>

Status & tagging log