http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88114
Revision: 88114
Author: dale
Date: 2011-05-14 17:16:07 +0000 (Sat, 14 May 2011)
Log Message:
-----------
removed oggThumb support ( ffmpeg handles thumbnails fine )
fixed remove file support
remove log-0.log files for two pass encoding
Modified Paths:
--------------
trunk/extensions/TimedMediaHandler/README
trunk/extensions/TimedMediaHandler/TimedMediaHandler.hooks.php
trunk/extensions/TimedMediaHandler/TimedMediaHandler.i18n.php
trunk/extensions/TimedMediaHandler/TimedMediaHandler.php
trunk/extensions/TimedMediaHandler/TimedMediaThumbnail.php
trunk/extensions/TimedMediaHandler/TimedMediaTransformOutput.php
trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscode.php
trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscodeJob.php
Modified: trunk/extensions/TimedMediaHandler/README
===================================================================
--- trunk/extensions/TimedMediaHandler/README 2011-05-14 17:11:32 UTC (rev
88113)
+++ trunk/extensions/TimedMediaHandler/README 2011-05-14 17:16:07 UTC (rev
88114)
@@ -20,22 +20,33 @@
// For boxes doing transcoding you should increase the allocated shell
memory:
$wgMaxShellMemory = 102400*64;
+
+
+== Running Transcodes ==
+To transcode the video you need to run webVideoTranscode jobs. In the trunk
maintenance folder
+you can run as the web user:
+ php runJobs.php --type webVideoTranscode --maxjobs 1
+If you want to have a job runner that checks for new jobs every 5 min in the
maintenance folder
+of Timed Media Handler run:
+ WebVideoJobRunner.php
-Kaltura html5 player library
------
+
+== Kaltura html5 player library ==
TimedMediaHandler uses the Kaltura html5 player library for video playback.
For more information about the player library visit:
http://html5video.org or
http://www.kaltura.org/project/HTML5_Video_Media_JavaScript_Library
-FFmpeg
-------
+== FFmpeg ==
We use FFmpeg for creating still images of videos, and for transcoding webm
videos. You will need a copy on your server.
+You can download static ffmpeg builds for multiple platforms at:
+http://firefogg.org/nightly/
+
Download source: http://ffmpeg.mplayerhq.hu/download.html
About the bug: https://roundup.mplayerhq.hu/roundup/ffmpeg/issue159
@@ -80,12 +91,14 @@
after the require line in LocalSettings.php.
-ffmpeg2theora
-------
+== ffmpeg2theora ==
We use ffmpeg2theora for extract metadata from videos, you will need a copy on
your
server.
+You can download static ffmpeg2theora builds for multiple platforms at:
+http://firefogg.org/nightly/
+
Set the ffmpeg2theora binary location with:
$wgFFmpeg2theoraLocation = '/path/to/ffmpeg2theora';
@@ -93,22 +106,7 @@
Download ffmpeg2theora from: http://firefogg.org/nightly/
-oggThumb
-------
-
-We use oggvideotools for creating still images of videos, you will need a copy
on your
-server.
-
-Set the oggThumb binary location with:
-
- $wgOggThumbLocation = '/path/to/oggThumb';
-
-Download oggThumb from: http://dev.streamnik.de/oggvideotools.html
-
-
-Cortado
--------
-
+== Cortado ==
Wikimedia uses Cortado Java applet from Xiph.org.
A .jar file compiled from this tree is provided in the OggHandler directory for
@@ -120,9 +118,9 @@
See LICENSE.cortado, LICENSE.jheora and LICENSE.smoke for license information.
-PEAR File_Ogg
--------------
+== PEAR File_Ogg ==
+
Tim Starling forked the PEAR File_Ogg package and improved it significantly in
order to
support this extension. Tim Starling has now taken over maintainership of
File_Ogg and
merged my changes into the latest release. This extension will now work with
@@ -132,11 +130,12 @@
http://pear.php.net/package/File_Ogg
As per the usual convention, the PEAR base directory (the one with PEAR.php in
-it) must be in your include_path.
+it) must be in your include_path. Note you do not need to install PEAR, its
included
+with the TMH.
-getID3
-----------
+== getID3 ==
+
getID3 is used for metadata of WebM files.
getID3() by James Heinrich <[email protected]>
Modified: trunk/extensions/TimedMediaHandler/TimedMediaHandler.hooks.php
===================================================================
--- trunk/extensions/TimedMediaHandler/TimedMediaHandler.hooks.php
2011-05-14 17:11:32 UTC (rev 88113)
+++ trunk/extensions/TimedMediaHandler/TimedMediaHandler.hooks.php
2011-05-14 17:16:07 UTC (rev 88114)
@@ -99,20 +99,14 @@
public static function checkArticleDeleteComplete( &$article, &$user,
$reason, $id ){
// Check if the article is a file and remove transcode jobs:
if( $article->getTitle()->getNamespace() == NS_FILE ) {
- // We can't get the file since the article is deleted :(
- // so we can't:
- // $file = wfFindFile( $article->getTitle() );
- // $file->getHandler()->getMetadataType()
-
- // So we have to use this unfortunate file name
extension hack :(
- // XXX figure out a better way to do this.
- $fileName = $article->getTitle()->getDBkey();
- $ext = strtolower( pathinfo( "$fileName",
PATHINFO_EXTENSION ) );
-
- if( $ext == 'ogg' || $ext == 'webm' || $ext == 'ogv' ){
- WebVideoTranscode::removeTranscodeJobs(
$article->getTitle()->getDBkey() );
+ $file = wfFindFile( $article->getTitle() );
+ $mediaType = $file->getHandler()->getMetadataType();
+
+ if( $mediaType == 'webm' || $mediaType == 'ogg' ){
+ WebVideoTranscode::removeTranscodeJobs( $file
);
}
+
}
return true;
}
Modified: trunk/extensions/TimedMediaHandler/TimedMediaHandler.i18n.php
===================================================================
--- trunk/extensions/TimedMediaHandler/TimedMediaHandler.i18n.php
2011-05-14 17:11:32 UTC (rev 88113)
+++ trunk/extensions/TimedMediaHandler/TimedMediaHandler.i18n.php
2011-05-14 17:16:07 UTC (rev 88114)
@@ -49,7 +49,7 @@
'timedmedia-derivative-480_880kbs.ogv' => 'Ogg 480P',
'timedmedia-derivative-desc-480_880kbs.ogv' => 'Web streamable Ogg
video (480P)',
- 'timedmedia-derivative-720_VBR.ogv' => 'Ogg HQ',
+ 'timedmedia-derivative-720_VBR.ogv' => 'Ogg 720P',
'timedmedia-derivative-desc-720_VBR.ogv' => 'High quality downloadable
Ogg video (720P)',
// WebM profiles:
Modified: trunk/extensions/TimedMediaHandler/TimedMediaHandler.php
===================================================================
--- trunk/extensions/TimedMediaHandler/TimedMediaHandler.php 2011-05-14
17:11:32 UTC (rev 88113)
+++ trunk/extensions/TimedMediaHandler/TimedMediaHandler.php 2011-05-14
17:16:07 UTC (rev 88114)
@@ -41,9 +41,6 @@
// Support iframe for remote embedding
$wgEnableIframeEmbed = true;
-// Location of oggThumb binary ( used instead of ffmpeg )
-$wgOggThumbLocation = '/usr/bin/oggThumb';
-
// The location of ffmpeg2theora ( transcoding )
$wgFFmpeg2theoraLocation = '/usr/bin/ffmpeg2theora';
Modified: trunk/extensions/TimedMediaHandler/TimedMediaThumbnail.php
===================================================================
--- trunk/extensions/TimedMediaHandler/TimedMediaThumbnail.php 2011-05-14
17:11:32 UTC (rev 88113)
+++ trunk/extensions/TimedMediaHandler/TimedMediaThumbnail.php 2011-05-14
17:16:07 UTC (rev 88114)
@@ -11,60 +11,12 @@
}
wfDebug( "Creating video thumbnail at" . $options['dstPath']
. "\n" );
- // If try OggThumb:
- if( self::tryOggThumb( $options) ){
- return true;
- }
// Else try ffmpeg and return result:
return self::tryFfmpegThumb( $options );
}
- /**
- * Try to render a thumbnail using oggThumb:
- *
- * @param $file {Object} File object
- * @param $dstPath {string} Destination path for the rendered thumbnail
- * @param $dstPath {array} Thumb rendering parameters ( like size and
time )
- */
- static function tryOggThumb( $options ){
- global $wgOggThumbLocation;
- // Check that the file is 'ogg' format
- if( $options['file']->getHandler()->getMetadataType() != 'ogg'
){
- return false;
- }
-
- // Check for $wgOggThumbLocation
- if( !$wgOggThumbLocation
- || !is_file( $wgOggThumbLocation )
- ){
- return false;
- }
-
- $cmd = wfEscapeShellArg( $wgOggThumbLocation ) .
- ' -t '. intval( self::getThumbTime( $options ) ) . ' ';
-
- // Setting height to 0 will keep aspect:
- // http://dev.streamnik.de/75.html
- if( isset( $options['width'] ) ){
- $cmd.= ' -s ' . intval( $options['width'] ) . 'x0 ';
- }
-
- $cmd.= ' -n ' . wfEscapeShellArg( $options['dstPath'] ) . ' ' .
- ' ' . wfEscapeShellArg( $options['file']->getPath() ) .
' 2>&1';
-
- $returnText = wfShellExec( $cmd, $retval );
-
- // Check if it was successful
- if ( !$options['file']->getHandler()->removeBadFile(
$options['dstPath'], $retval ) ) {
- return true;
- }
- return false;
- }
static function tryFfmpegThumb( $options ){
global $wgFFmpegLocation;
- if( !$wgFFmpegLocation || !is_file( $wgFFmpegLocation ) ){
- return false;
- }
$cmd = wfEscapeShellArg( $wgFFmpegLocation ) .
' -i ' . wfEscapeShellArg( $options['file']->getPath()
);
Modified: trunk/extensions/TimedMediaHandler/TimedMediaTransformOutput.php
===================================================================
--- trunk/extensions/TimedMediaHandler/TimedMediaTransformOutput.php
2011-05-14 17:11:32 UTC (rev 88113)
+++ trunk/extensions/TimedMediaHandler/TimedMediaTransformOutput.php
2011-05-14 17:16:07 UTC (rev 88114)
@@ -147,7 +147,7 @@
// Fallback text displayed for browsers without js and
without video tag support:
/// XXX note we may want to replace this with an image
and download link play button
- wfMsg( 'timedmedia-no-player-js', $firstSource['src'] )
+ wfMsg( 'timedmedia-no-player-js', $firstSource['src'] )
);
return $s;
}
Modified:
trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscode.php
===================================================================
--- trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscode.php
2011-05-14 17:11:32 UTC (rev 88113)
+++ trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscode.php
2011-05-14 17:16:07 UTC (rev 88114)
@@ -238,9 +238,9 @@
}
- /*
+ /**
* Based on the $wgEnabledTranscodeSet set of enabled derivatives we
- * sync the database with $wgEnabledTranscodeSet
+ * sync the database with $wgEnabledTranscodeSet and return sources
that are ready
*
* If no transcode is in progress or ready add the job to the jobQueue
*
@@ -297,10 +297,9 @@
}
// Try and add the source
self::addSourceIfReady( $file, $sources, $transcodeKey,
$options );
- }
-
+ }
// Make sure we have at least one ogg and webm encode
- if( !$addOggFlag || !$addWebMFlag){
+ if( !$addOggFlag || !$addWebMFlag ){
foreach( $wgEnabledTranscodeSet as $transcodeKey ){
if( !$addOggFlag &&
self::$derivativeSettings[$transcodeKey]['videoCodec'] == 'theora' ){
self::addSourceIfReady( $file,
$sources, $transcodeKey, $options );
@@ -312,9 +311,9 @@
}
}
}
-
return $sources;
}
+
/**
* Get the transcode state for a given filename and transcodeKey
*
@@ -322,9 +321,9 @@
*/
public static function isTranscodeReady( $fileName, $transcodeKey ){
- // check if we need to populate the transcodeState cache:
+ // Check if we need to populate the transcodeState cache:
if( !self::$transcodeStateCache || !isset(
self::$transcodeStateCache[ $fileName ] ) ) {
- self::populateTranscodeStateCache( $fileName );
+ self::getTranscodeStateCache( $fileName );
}
// If no state is found the cache for this file is false:
if( !isset( self::$transcodeStateCache[ $fileName ][
$transcodeKey ])
@@ -344,12 +343,12 @@
}
/**
- * Populates the local transcoding state cache with the current DB
state of transcodes
+ * Populates the transcode table with the current DB state of
transcodes
* if transcodes are not found in the database their state is set to
"false"
*
* @param string $fileName key
*/
- public static function populateTranscodeStateCache( $fileName ){
+ public static function getTranscodeStateCache( $fileName ){
wfProfileIn( __METHOD__ );
$res = wfGetDB( DB_SLAVE )->select( 'transcode',
array( 'transcode_key',
'transcode_time_success','transcode_time_addjob','transcode_final_bitrate' ) ,
@@ -369,12 +368,28 @@
}
/**
* Remove any transcode jobs associated with a given $fileName
+ *
+ * also remove the transcode files:
*/
- public static function removeTranscodeJobs( $fileName ){
- wfGetDB( DB_MASTER )->delete( 'transcode',
+ public static function removeTranscodeJobs( &$file ){
+ $fileName = $file->getTitle()->getDbKey();
+
+ $res = wfGetDB( DB_SLAVE )->select( 'transcode',
+ array( 'transcode_key' ),
+ array( 'transcode_image_name' => $fileName )
+ );
+ // remove the file
+ foreach( $res as $transcodeRow ){
+ $filePath = self::getDerivativeFilePath($file,
$transcodeRow->transcode_key );
+ if( ! @unlink( $filePath ) ){
+ wfDebug( "Could not delete file $filePath\n" );
+ }
+ }
+ // Remove the db entries
+ wfGetDB( DB_MASTER )->delete( 'transcode',
array( 'transcode_image_name' => $fileName ),
__METHOD__
- );
+ );
}
/**
@@ -388,7 +403,7 @@
if( self::isTranscodeReady( $fileName, $transcodeKey ) ){
$sources[] = self::getDerivativeSourceAttributes(
$file, $transcodeKey, $dataPrefix );
} else {
- self::updateJobQueue( $file, $transcodeKey );
+ self::updateJobQueue( $file, $transcodeKey );
}
}
/**
@@ -473,9 +488,9 @@
$fileName = $file->getTitle()->getDbKey();
- // Check if we need to populate the transcodeState cache:
+ // Check if we need to update the transcode state:
if( !self::$transcodeStateCache || !isset(
self::$transcodeStateCache[ $fileName ] ) ) {
- self::populateTranscodeStateCache( $fileName );
+ self::getTranscodeStateCache( $fileName );
}
// Check if the job has been added:
@@ -518,7 +533,7 @@
);
}
// Update the state cache
- self::populateTranscodeStateCache( $fileName );
+ self::getTranscodeStateCache( $fileName );
}
// no jobId ? error out in some way?
}
Modified:
trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscodeJob.php
===================================================================
---
trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscodeJob.php
2011-05-14 17:11:32 UTC (rev 88113)
+++
trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscodeJob.php
2011-05-14 17:16:07 UTC (rev 88114)
@@ -77,6 +77,8 @@
// unlink the .log file used in two
pass encoding:
wfSuppressWarnings();
unlink( $destinationFile . '.log' );
+ // Sometimes ffmpeg gives the file
log-0.log extension
+ unlink( $destinationFile . 'log-0.log');
wfRestoreWarnings();
}
// remove any log files
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs