Paladox has uploaded a new change for review. https://gerrit.wikimedia.org/r/251701
Change subject: TEST: DO NOT MERGE ...................................................................... TEST: DO NOT MERGE Change-Id: Ie2ce639247bf38721b372ed3fe200fcb2d9f91d0 --- D README A README.md M TimedMediaHandler.hooks.php M TimedMediaHandler.php M WebVideoTranscode/WebVideoTranscode.php A extension.json 6 files changed, 677 insertions(+), 497 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler refs/changes/01/251701/1 diff --git a/README b/README deleted file mode 100644 index c37c5ad..0000000 --- a/README +++ /dev/null @@ -1,127 +0,0 @@ -== TimedMediaHandler == - -This extension provides a media handler for the Ogg, WebM, mp4 container format. -When enabled, a player will be automatically embedded in the file description -page, or any wiki page while still using the same syntax as for images. - -* Broad support for input file formats -* Transcoder to make video at web resolutions when embedding clips in a page -* include support for timed Text per the w3c "track" recommendation -* use embedPlayer mwEmbed javascript module for playback - -To install this extension, add the following to the end of your -LocalSettings.php: - - // You need mwEmbedSupport ( if not already added ) - require( "$IP/extensions/MwEmbedSupport/MwEmbedSupport.php" ); - - // TimedMediaHandler - require( "$IP/extensions/TimedMediaHandler/TimedMediaHandler.php" ); - - -== Running Transcodes == - -Transcoding a video to another resolution or format takes a good amount which -prevents that processing to be handled as a web service. Instead, the extension -implements an asynchronous job, named webVideoTranscode, which you must be -running regularly as your web server user. - -The job can be run using the MediaWiki maintenance/runJobs.php utility (do not -forget to su as a webserver user): - - php runJobs.php --type webVideoTranscode --maxjobs 1 - - -== Kaltura HTML5 player library == - -TimedMediaHandler uses the Kaltura HTML5 player library for video playback, it -relies on the <video> element as well as JavaScript. - -For more information about the player library visit: - http://www.html5video.org/kaltura-player/docs - - -== Libav == - -We use Libav for two purposes: - - creating still images of videos (aka thumbnails) - - transcoding WebM, H.264 videos - -Wikimedia currently uses libav as shipped in Ubuntu 12.04 (libav 0.8.x). -For best experience use that or any later release from http://libav.org. - -On Ubuntu/Debian: - apt-get install libav-tools - -For H.264 support: - apt-get install libav-tools libavcodec-extra-53 - -If you operating system does not include the required libav software, -you can download static builds for multiple platforms at: - http://firefogg.org/nightly/ - -You can also build libav/ffmpeg from source. -Guide for building ffmpeg with H.264 for Ubuntu: -https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide - -Some old versions of FFmpeg had a bug which made it extremely slow to seek in -large theora videos in order to generate a thumbnail. If you are using an old -version of FFmpeg and find that performance is extremely poor (tens of seconds) -to generate thumbnails of theora videos that are several minutes or more in -length. Please update to a more recent version. - -In MediaWiki configuration, after the require line in LocalSettings.php, you -will have to specify the FFmpeg binary location with: - - $wgFFmpegLocation = '/path/to/ffmpeg'; - -Default being `/usr/bin/avconv`. - - -== ffmpeg2theora == - -We use ffmpeg2theora for extract metadata from videos, you will need a copy on -your server. For best experience, use the latest release of ffmpeg2theora. At a -minimum you need to use ffmpeg2thoera 0.27. - -You can download static ffmpeg2theora builds for multiple platforms at: -http://firefogg.org/nightly/ - -Set the ffmpeg2theora binary location with: - - $wgFFmpeg2theoraLocation = '/path/to/ffmpeg2theora'; - -Default being `/usr/bin/ffmpeg2theora`. - -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 - -== PEAR File_Ogg == - -Tim Starling, a Wikimedia developer, forked the PEAR File_Ogg package and -improved it significantly to support this extension. - -The PEAR bundle is licensed under the LGPL, you can get informations about -this package on the pear webpage: - - http://pear.php.net/package/File_Ogg - -== getID3 == - -getID3 is used for metadata of WebM files. - -getID3() by James Heinrich <i...@getid3.org> -available at http://getid3.sourceforge.net -or http://www.getid3.org/ - -getID3 code is released under the GNU GPL: -http://www.gnu.org/copyleft/gpl.html diff --git a/README.md b/README.md new file mode 100644 index 0000000..a3512ce --- /dev/null +++ b/README.md @@ -0,0 +1,321 @@ +TimedMediaHandler +========= + +This extension provides a media handler for the Ogg, WebM, mp4 container format. +When enabled, a player will be automatically embedded in the file description +page, or any wiki page while still using the same syntax as for images. + +* Broad support for input file formats +* Transcoder to make video at web resolutions when embedding clips in a page +* include support for timed Text per the w3c "track" recommendation +* use embedPlayer mwEmbed javascript module for playback + +To install this extension, add the following to the end of your +LocalSettings.php: + +For MediaWiki 1.24 or lower please add this + +```php +// You need mwEmbedSupport ( if not already added ) +require_once( "$IP/extensions/MwEmbedSupport/MwEmbedSupport.php" ); + +// TimedMediaHandler +require_once( "$IP/extensions/TimedMediaHandler/TimedMediaHandler.php" ); +``` + +For MediaWiki 1.25 or higher please add this + +```php +// TimedMediaHandler +wfLoadExtensions( array( 'TimedMediaHandler' ) ); +``` + +### Running Transcodes + +Transcoding a video to another resolution or format takes a good amount which +prevents that processing to be handled as a web service. Instead, the extension +implements an asynchronous job, named webVideoTranscode, which you must be +running regularly as your web server user. + +The job can be run using the MediaWiki maintenance/runJobs.php utility (do not +forget to su as a webserver user): + +```php +php runJobs.php --type webVideoTranscode --maxjobs 1 +``` + +### Kaltura HTML5 player library + +TimedMediaHandler uses the Kaltura HTML5 player library for video playback, it +relies on the <video> element as well as JavaScript. + +For more information about the player library visit: http://www.html5video.org/kaltura-player/docs + +### Libav + +We use Libav for two purposes: + - creating still images of videos (aka thumbnails) + - transcoding WebM, H.264 videos + +Wikimedia currently uses libav as shipped in Ubuntu 12.04 (libav 0.8.x). +For best experience use that or any later release from http://libav.org. + +On Ubuntu/Debian: + apt-get install libav-tools + +For H.264 support: + apt-get install libav-tools libavcodec-extra-53 + +If you operating system does not include the required libav software, +you can download static builds for multiple platforms at: + http://firefogg.org/nightly/ + +You can also build libav/ffmpeg from source. +Guide for building ffmpeg with H.264 for Ubuntu: +https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide + +Some old versions of FFmpeg had a bug which made it extremely slow to seek in +large theora videos in order to generate a thumbnail. If you are using an old +version of FFmpeg and find that performance is extremely poor (tens of seconds) +to generate thumbnails of theora videos that are several minutes or more in +length. Please update to a more recent version. + +In MediaWiki configuration, after the require line in LocalSettings.php, you +will have to specify the FFmpeg binary location with: +```php +$wgFFmpegLocation = '/path/to/ffmpeg'; +``` + +Default being `/usr/bin/avconv`. + +### ffmpeg2theora + +We use ffmpeg2theora for extract metadata from videos, you will need a copy on +your server. For best experience, use the latest release of ffmpeg2theora. At a +minimum you need to use ffmpeg2thoera 0.27. + +You can download static ffmpeg2theora builds for multiple platforms at: +http://firefogg.org/nightly/ + +Set the ffmpeg2theora binary location with: + +```php +$wgFFmpeg2theoraLocation = '/path/to/ffmpeg2theora'; +``` + +Default being `/usr/bin/ffmpeg2theora`. + +oggThumb +------- + +We use oggvideotools for creating still images of videos, you will need a copy on your +server. + +Set the oggThumb binary location with: + +```php +$wgOggThumbLocation = '/path/to/oggThumb'; +``` + +Download oggThumb from: http://dev.streamnik.de/oggvideotools.html + + +### PEAR File_Ogg + +Tim Starling, a Wikimedia developer, forked the PEAR File_Ogg package and +improved it significantly to support this extension. + +The PEAR bundle is licensed under the LGPL, you can get informations about +this package on the pear webpage: http://pear.php.net/package/File_Ogg + +### getID3 + +getID3 is used for metadata of WebM files. + +getID3() by James Heinrich <i...@getid3.org> +available at http://getid3.sourceforge.net +or http://www.getid3.org/ + +getID3 code is released under the GNU GPL: +http://www.gnu.org/copyleft/gpl.html + +### Configuration settings + +The following variables can be overridden in your LocalSettings.php file: + +```php +// Path overdie for cortado ( by default its false and uses hard coded paths relative to TMH +// or the predefined path on upload server: http://upload.wikimedia.org/jars/cortado.jar +$wgCortadoJarFile = false; + +// Show a warning to the user if they are not using an html5 browser with high quality ogg support +$wgMwEmbedModuleConfig['EmbedPlayer.DirectFileLinkWarning'] = true; + +// Show the options menu: +$wgMwEmbedModuleConfig['EmbedPlayer.EnableOptionsMenu'] = true; + +// TMH needs java ( no h.264 or mp3 derivatives ) +$wgMwEmbedModuleConfig['EmbedPlayer.DisableJava' ] = true; +$wgMwEmbedModuleConfig['EmbedPlayer.DisableHTML5FlashFallback' ] = true; + +// The text interface should always be shown +// ( even if there are no text tracks for that asset at render time ) +$wgMwEmbedModuleConfig['TimedText.ShowInterface'] = 'always'; + +// Show the add text link: +$wgMwEmbedModuleConfig['TimedText.ShowAddTextLink'] = true; + +// How long you have to wait between transcode resets for non-error transcodes +$wgWaitTimeForTranscodeReset = 3600; + +// The minimum size for an embed video player ( smaller than this size uses a pop-up player ) +$wgMinimumVideoPlayerSize = 200; + +// Set the supported ogg codecs: +$wgMediaVideoTypes = array( 'Theora', 'VP8' ); +$wgMediaAudioTypes = array( 'Vorbis', 'Speex', 'FLAC', 'Opus' ); + +// Default skin for mwEmbed player +$wgVideoPlayerSkinModule = 'mw.PlayerSkinKskin'; + +// Support iframe for remote embedding +$wgEnableIframeEmbed = true; + +// If transcoding is enabled for this wiki (if disabled, no transcode jobs are added and no +// transcode status is displayed). Note if remote embedding an asset we will still check if +// the remote repo has transcoding enabled and associated flavors for that media embed. +$wgEnableTranscode = true; + +// If the job runner should run transcode commands in a background thread and monitor the +// transcoding progress. This enables more fine grain control of the transcoding process, wraps +// encoding commands in a lower priority 'nice' call, and kills long running transcodes that are +// not making any progress. If set to false, the job runner will use the more compatible +// php blocking shell exec command. +$wgEnableNiceBackgroundTranscodeJobs = false; + +// The priority to be used with the nice transcode commands. +$wgTranscodeBackgroundPriority = 19; + +// The total amout of time a transcoding shell command can take: +$wgTranscodeBackgroundTimeLimit = 3600 * 8; +// Maximum amount of virtual memory available to transcoding processes in KB +$wgTranscodeBackgroundMemoryLimit = 2 * 1024 * 1024; // 2GB avconv, ffmpeg2theora mmap resources so virtual memory needs to be high enough +// Maximum file size transcoding processes can create, in KB +$wgTranscodeBackgroundSizeLimit = 3 * 1024 * 1024; // 3GB + +// Number of threads to use in avconv for transcoding +$wgFFmpegThreads = 1; + +// The NS for TimedText (registered on MediaWiki.org) +// http://www.mediawiki.org/wiki/Extension_namespace_registration +// Note commons pre-dates TimedMediaHandler and should set $wgTimedTextNS = 102 in LocalSettings.php +$wgTimedTextNS = 710; + +// Set TimedText namespace for ForeignDBViaLBRepo on a per wikiID basis +// $wgTimedTextForeignNamespaces = array( 'commonswiki' => 102 ); +$wgTimedTextForeignNamespaces = array(); + +// Set to false to disable local TimedText, +// you still get subtitles for videos from foreign repos +// to disable all TimedText, set +// $wgMwEmbedModuleConfig['TimedText.ShowInterface'] = 'off'; +$wgEnableLocalTimedText = true; + +/** + * Default enabled transcodes + * + * -If set to empty array, no derivatives will be created + * -Derivative keys encode settings are defined in WebVideoTranscode.php + * + * -These transcodes are *in addition to* the source file. + * -Only derivatives with smaller width than the source asset size will be created + * -Regardless of source size at least one WebM and Ogg source will be created from the $wgEnabledTranscodeSet + * -Derivative jobs are added to the MediaWiki JobQueue the first time the asset is displayed + * -Derivative should be listed min to max + */ +$wgEnabledTranscodeSet = array( + + // WebM VP8/Vorbis + // primary free/open video format + // supported by Chrome/Firefox/Opera but not Safari/IE/Edge + + // Medium-bitrate web streamable WebM video + WebVideoTranscode::ENC_WEBM_360P, + + // Moderate-bitrate web streamable WebM video + WebVideoTranscode::ENC_WEBM_480P, + + // A high quality WebM stream + WebVideoTranscode::ENC_WEBM_720P, + + // A full-HD high quality WebM stream + WebVideoTranscode::ENC_WEBM_1080P, + + + // Ogg Theora/Vorbis + // Fallback for Safari/IE/Edge with ogv.js + // + // Requires twice the bitrate for same quality as VP8, + // and JS decoder can be slow, so shift to smaller sizes. + + // Low-bitrate Ogg stream + WebVideoTranscode::ENC_OGV_160P, + + // Medium-bitrate Ogg stream + WebVideoTranscode::ENC_OGV_240P, + + // Moderate-bitrate Ogg stream + WebVideoTranscode::ENC_OGV_360P, + + // High-bitrate Ogg stream + WebVideoTranscode::ENC_OGV_480P, + +/* + // MP4 H.264/AAC + // Primary format for the Apple/Microsoft world + // + // Check patent licensing issues in your country before use! + // Similar to WebM in quality/bitrate + + // A least common denominator h.264 stream; first gen iPhone, iPods, early android etc. + WebVideoTranscode::ENC_H264_320P, + + // A mid range h.264 stream; mid range phones and low end tables + WebVideoTranscode::ENC_H264_480P, + + // An high quality HD stream; higher end phones, tablets, smart tvs + WebVideoTranscode::ENC_H264_720P, + + // A full-HD high quality stream; higher end phones, tablets, smart tvs + WebVideoTranscode::ENC_H264_1080P, +*/ +); + +$wgEnabledAudioTranscodeSet = array( + WebVideoTranscode::ENC_OGG_VORBIS, + + //opus support must be available in avconv + //WebVideoTranscode::ENC_OGG_OPUS, + + //avconv needs libmp3lame support + //WebVideoTranscode::ENC_MP3, + + //avconv needs libvo_aacenc support + //WebVideoTranscode::ENC_AAC, +); + +// If mp4 source assets can be ingested: +$wgTmhEnableMp4Uploads = false; + +// Two-pass encoding for .ogv Theora transcodes is flaky as of October 2015. +// Enable this only if testing with latest theora libraries! +// See tracking bug: https://phabricator.wikimedia.org/T115883 +$wgTmhTheoraTwoPassEncoding = false; + +// List of extensions handled by Timed Media Handler since its referenced in a few places. +// you should not modify this variable + +$wgTmhFileExtensions = array( 'ogg', 'ogv', 'oga', 'flac', 'wav', 'webm', 'mp4' ); + +$wgFileExtensions = array_merge( $wgFileExtensions, $wgTmhFileExtensions ); +``` diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php index d290bf7..aa288ef 100644 --- a/TimedMediaHandler.hooks.php +++ b/TimedMediaHandler.hooks.php @@ -8,6 +8,34 @@ */ class TimedMediaHandlerHooks { + + /** + * Executed after processing extension.json + */ + public static function registerExtension() { + global $wgFileExtensions, $wgTmhFileExtensions, $wgEnabledTranscodeSet, + $wgEnabledAudioTranscodeSet; + + // List of file extensions handled by Timed Media Handler since its referenced in + // a few places. You should not modify this variable. + $wgTmhFileExtensions = array( 'ogg', 'ogv', 'oga', 'flac', 'wav', 'webm', 'mp4' ); + + $wgFileExtensions = array_merge( $wgFileExtensions, $wgTmhFileExtensions ); + + /** + * Default enabled transcodes + * + * -If set to empty array, no derivatives will be created + * -Derivative keys encode settings are defined in WebVideoTranscode.php + * + * -These transcodes are *in addition to* the source file. + * -Only derivatives with smaller width than the source asset size will be created + * -Regardless of source size at least one WebM and Ogg source will be created from the $wgEnabledTranscodeSet + * -Derivative jobs are added to the MediaWiki JobQueue the first time the asset is displayed + * -Derivative should be listed min to max + */ + } + // Register TimedMediaHandler Hooks public static function register(){ global $wgHooks, $wgJobClasses, $wgJobTypesExcludedFromDefaultQueue, diff --git a/TimedMediaHandler.php b/TimedMediaHandler.php index 040dff0..128d2ee 100644 --- a/TimedMediaHandler.php +++ b/TimedMediaHandler.php @@ -1,309 +1,18 @@ <?php -if ( !defined( 'MEDIAWIKI' ) ) { - echo "This is the TimedMediaHandler extension. Please see the README file for installation instructions.\n"; - exit( 1 ); +if ( function_exists( 'wfLoadExtension' ) ) { + wfLoadExtension( 'TimedMediaHandler' ); + // Keep i18n globals so mergeMessageFileList.php doesn't break + $wgMessagesDirs['TimedMediaHandler'] = __DIR__ . '/i18n'; + $wgMessagesDirs['MwEmbed.EmbedPlayer'] = __DIR__ . '/MwEmbedModules/EmbedPlayer/i18n'; + $wgMessagesDirs['MwEmbed.TimedText'] = __DIR__ . '/MwEmbedModules/TimedText/i18n'; + $wgExtensionMessagesFiles['TimedMediaHandlerMagic'] = __DIR__ . '/TimedMediaHandler.i18n.magic.php'; + $wgExtensionMessagesFiles['TimedMediaHandlerAliases'] = __DIR__ . '/TimedMediaHandler.i18n.alias.php'; + /* wfWarn( + 'Deprecated PHP entry point used for TimedMediaHandler extension. Please use wfLoadExtension instead, ' . + 'see https://www.mediawiki.org/wiki/Extension_registration for more details.' + ); */ + return; +} else { + die( 'This version of the TimedMediaHandler extension requires MediaWiki 1.25+' ); } - -// Set up the timed media handler dir: -$timedMediaDir = __DIR__; -// Include WebVideoTranscode (prior to config so that its defined transcode keys can be used in configuration) -$wgAutoloadClasses['WebVideoTranscode'] = "$timedMediaDir/WebVideoTranscode/WebVideoTranscode.php"; - -// Add the rest transcode right: -$wgAvailableRights[] = 'transcode-reset'; -$wgAvailableRights[] = 'transcode-status'; - - - -/*** MwEmbed module configuration: *********************************/ - -// Show a warning to the user if they are not using an html5 browser with high quality ogg support -$wgMwEmbedModuleConfig['EmbedPlayer.DirectFileLinkWarning'] = true; - -// Show the options menu: -$wgMwEmbedModuleConfig['EmbedPlayer.EnableOptionsMenu'] = true; - -$wgMwEmbedModuleConfig['EmbedPlayer.DisableHTML5FlashFallback' ] = true; - -// The text interface should always be shown -// ( even if there are no text tracks for that asset at render time ) -$wgMwEmbedModuleConfig['TimedText.ShowInterface'] = 'always'; - -// Show the add text link: -$wgMwEmbedModuleConfig['TimedText.ShowAddTextLink'] = true; - -/*** Timed Media Handler configuration ****************************/ - -// Which users can restart failed or expired transcode jobs: -$wgGroupPermissions['sysop']['transcode-reset'] = true; -$wgGroupPermissions['autoconfirmed']['transcode-reset'] = true; - -// Which users can see Special:TimedMediaHandler -$wgGroupPermissions['sysop']['transcode-status'] = true; - -// How long you have to wait between transcode resets for non-error transcodes -$wgWaitTimeForTranscodeReset = 3600; - -// The minimum size for an embed video player ( smaller than this size uses a pop-up player ) -$wgMinimumVideoPlayerSize = 200; - -// Set the supported ogg codecs: -$wgMediaVideoTypes = array( 'Theora', 'VP8' ); -$wgMediaAudioTypes = array( 'Vorbis', 'Speex', 'FLAC', 'Opus' ); - -// Default skin for mwEmbed player -$wgVideoPlayerSkinModule = 'mw.PlayerSkinKskin'; - -// Support iframe for remote embedding -$wgEnableIframeEmbed = true; - -// If transcoding is enabled for this wiki (if disabled, no transcode jobs are added and no -// transcode status is displayed). Note if remote embedding an asset we will still check if -// the remote repo has transcoding enabled and associated flavors for that media embed. -$wgEnableTranscode = true; - -// If the job runner should run transcode commands in a background thread and monitor the -// transcoding progress. This enables more fine grain control of the transcoding process, wraps -// encoding commands in a lower priority 'nice' call, and kills long running transcodes that are -// not making any progress. If set to false, the job runner will use the more compatible -// php blocking shell exec command. -$wgEnableNiceBackgroundTranscodeJobs = false; - -// The priority to be used with the nice transcode commands. -$wgTranscodeBackgroundPriority = 19; - -// The total amout of time a transcoding shell command can take: -$wgTranscodeBackgroundTimeLimit = 3600 * 8; -// Maximum amount of virtual memory available to transcoding processes in KB -$wgTranscodeBackgroundMemoryLimit = 2 * 1024 * 1024; // 2GB avconv, ffmpeg2theora mmap resources so virtual memory needs to be high enough -// Maximum file size transcoding processes can create, in KB -$wgTranscodeBackgroundSizeLimit = 3 * 1024 * 1024; // 3GB - -// Number of threads to use in avconv for transcoding -$wgFFmpegThreads = 1; - -// The location of ffmpeg2theora (transcoding) -// Set to false to use avconv/ffmpeg to produce Ogg Theora transcodes instead; -// beware this will disable Ogg skeleton metadata generation. -$wgFFmpeg2theoraLocation = '/usr/bin/ffmpeg2theora'; - -// Location of oggThumb binary ( used instead of ffmpeg ) -$wgOggThumbLocation = '/usr/bin/oggThumb'; - -// Location of the avconv/ffmpeg binary (used to encode WebM and for thumbnails) -$wgFFmpegLocation = '/usr/bin/avconv'; - -// The NS for TimedText (registered on MediaWiki.org) -// http://www.mediawiki.org/wiki/Extension_namespace_registration -// Note commons pre-dates TimedMediaHandler and should set $wgTimedTextNS = 102 in LocalSettings.php -$wgTimedTextNS = 710; - -// Set TimedText namespace for ForeignDBViaLBRepo on a per wikiID basis -// $wgTimedTextForeignNamespaces = array( 'commonswiki' => 102 ); -$wgTimedTextForeignNamespaces = array(); - -// Set to false to disable local TimedText, -// you still get subtitles for videos from foreign repos -// to disable all TimedText, set -// $wgMwEmbedModuleConfig['TimedText.ShowInterface'] = 'off'; -$wgEnableLocalTimedText = true; - -/** - * Default enabled transcodes - * - * -If set to empty array, no derivatives will be created - * -Derivative keys encode settings are defined in WebVideoTranscode.php - * - * -These transcodes are *in addition to* the source file. - * -Only derivatives with smaller width than the source asset size will be created - * -Regardless of source size at least one WebM and Ogg source will be created from the $wgEnabledTranscodeSet - * -Derivative jobs are added to the MediaWiki JobQueue the first time the asset is displayed - * -Derivative should be listed min to max - */ -$wgEnabledTranscodeSet = array( - - // WebM VP8/Vorbis - // primary free/open video format - // supported by Chrome/Firefox/Opera but not Safari/IE/Edge - - // Medium-bitrate web streamable WebM video - WebVideoTranscode::ENC_WEBM_360P, - - // Moderate-bitrate web streamable WebM video - WebVideoTranscode::ENC_WEBM_480P, - - // A high quality WebM stream - WebVideoTranscode::ENC_WEBM_720P, - - // A full-HD high quality WebM stream - WebVideoTranscode::ENC_WEBM_1080P, - - // A 4K full high quality WebM stream - // WebVideoTranscode::ENC_WEBM_2160P, - - - // Ogg Theora/Vorbis - // Fallback for Safari/IE/Edge with ogv.js - // - // Requires twice the bitrate for same quality as VP8, - // and JS decoder can be slow, so shift to smaller sizes. - - // Low-bitrate Ogg stream - WebVideoTranscode::ENC_OGV_160P, - - // Medium-bitrate Ogg stream - WebVideoTranscode::ENC_OGV_240P, - - // Moderate-bitrate Ogg stream - WebVideoTranscode::ENC_OGV_360P, - - // High-bitrate Ogg stream - WebVideoTranscode::ENC_OGV_480P, - -/* - // MP4 H.264/AAC - // Primary format for the Apple/Microsoft world - // - // Check patent licensing issues in your country before use! - // Similar to WebM in quality/bitrate - - // A least common denominator h.264 stream; first gen iPhone, iPods, early android etc. - WebVideoTranscode::ENC_H264_320P, - - // A mid range h.264 stream; mid range phones and low end tables - WebVideoTranscode::ENC_H264_480P, - - // An high quality HD stream; higher end phones, tablets, smart tvs - WebVideoTranscode::ENC_H264_720P, - - // A full-HD high quality stream; higher end phones, tablets, smart tvs - WebVideoTranscode::ENC_H264_1080P, - - // A 4K high quality stream; higher end phones, tablets, smart tvs - WebVideoTranscode::ENC_H264_2160P, -*/ -); - -$wgEnabledAudioTranscodeSet = array( - WebVideoTranscode::ENC_OGG_VORBIS, - - //opus support must be available in avconv - //WebVideoTranscode::ENC_OGG_OPUS, - - //avconv needs libmp3lame support - //WebVideoTranscode::ENC_MP3, - - //avconv needs libvo_aacenc support - //WebVideoTranscode::ENC_AAC, -); - -// If mp4 source assets can be ingested: -$wgTmhEnableMp4Uploads = false; - -// Two-pass encoding for .ogv Theora transcodes is flaky as of October 2015. -// Enable this only if testing with latest theora libraries! -// See tracking bug: https://phabricator.wikimedia.org/T115883 -// -$wgTmhTheoraTwoPassEncoding = false; - -/******************* CONFIGURATION ENDS HERE **********************/ - - -// List of extensions handled by Timed Media Handler since its referenced in a few places. -// you should not modify this variable - -$wgTmhFileExtensions = array( 'ogg', 'ogv', 'oga', 'flac', 'wav', 'webm', 'mp4' ); - -$wgFileExtensions = array_merge( $wgFileExtensions, $wgTmhFileExtensions ); - -// Timed Media Handler AutoLoad Classes: -$wgAutoloadClasses['TimedMediaHandler'] = "$timedMediaDir/TimedMediaHandler_body.php"; -$wgAutoloadClasses['TimedMediaHandlerHooks'] = "$timedMediaDir/TimedMediaHandler.hooks.php"; -$wgAutoloadClasses['TimedMediaTransformOutput'] = "$timedMediaDir/TimedMediaTransformOutput.php"; -$wgAutoloadClasses['TimedMediaIframeOutput'] = "$timedMediaDir/TimedMediaIframeOutput.php"; -$wgAutoloadClasses['TimedMediaThumbnail'] = "$timedMediaDir/TimedMediaThumbnail.php"; -// Transcode Page -$wgAutoloadClasses['TranscodeStatusTable'] = "$timedMediaDir/TranscodeStatusTable.php"; - -// Testing: -$wgAutoloadClasses['ApiTestCaseVideoUpload'] = "$timedMediaDir/tests/phpunit/ApiTestCaseVideoUpload.php"; - -// Ogg Handler -$wgAutoloadClasses['OggHandlerTMH'] = "$timedMediaDir/handlers/OggHandler/OggHandler.php"; -$wgAutoloadClasses['OggException'] = "$timedMediaDir/handlers/OggHandler/OggException.php"; -$wgAutoloadClasses['File_Ogg'] = "$timedMediaDir/handlers/OggHandler/File_Ogg/File/Ogg.php"; -$wgAutoloadClasses['File_Ogg_Bitstream'] = "$timedMediaDir/handlers/OggHandler/File_Ogg/File/Ogg/Bitstream.php"; -$wgAutoloadClasses['File_Ogg_Flac'] = "$timedMediaDir/handlers/OggHandler/File_Ogg/File/Ogg/Flac.php"; -$wgAutoloadClasses['File_Ogg_Media'] = "$timedMediaDir/handlers/OggHandler/File_Ogg/File/Ogg/Media.php"; -$wgAutoloadClasses['File_Ogg_Opus'] = "$timedMediaDir/handlers/OggHandler/File_Ogg/File/Ogg/Opus.php"; -$wgAutoloadClasses['File_Ogg_Speex'] = "$timedMediaDir/handlers/OggHandler/File_Ogg/File/Ogg/Speex.php"; -$wgAutoloadClasses['File_Ogg_Theora'] = "$timedMediaDir/handlers/OggHandler/File_Ogg/File/Ogg/Theora.php"; -$wgAutoloadClasses['File_Ogg_Vorbis'] = "$timedMediaDir/handlers/OggHandler/File_Ogg/File/Ogg/Vorbis.php"; - -// getID3 provides metadata for mp4 and webm files: -$wgAutoloadClasses['getID3'] = "$timedMediaDir/libs/getid3/getid3.php"; -$wgAutoloadClasses['getid3_exception'] = "$timedMediaDir/libs/getid3/getid3.php"; -$wgAutoloadClasses['getid3_handler'] = "$timedMediaDir/libs/getid3/getid3.php"; - -// ID3 Metadata Handler -$wgAutoloadClasses['ID3Handler'] = "$timedMediaDir/handlers/ID3Handler/ID3Handler.php"; -// Mp4 / h264 Handler -$wgAutoloadClasses['Mp4Handler'] = "$timedMediaDir/handlers/Mp4Handler/Mp4Handler.php"; -// WebM Handler -$wgAutoloadClasses['WebMHandler'] = "$timedMediaDir/handlers/WebMHandler/WebMHandler.php"; -// FLAC Handler -$wgAutoloadClasses['FLACHandler'] = "$timedMediaDir/handlers/FLACHandler/FLACHandler.php"; -// WAV Handler -$wgAutoloadClasses['WAVHandler'] = "$timedMediaDir/handlers/WAVHandler/WAVHandler.php"; - -// Text handler -$wgAutoloadClasses['ForeignApiQueryAllPages'] = "$timedMediaDir/handlers/TextHandler/TextHandler.php"; -$wgAutoloadClasses['TextHandler'] = "$timedMediaDir/handlers/TextHandler/TextHandler.php"; -$wgAutoloadClasses['TimedTextPage'] = "$timedMediaDir/TimedTextPage.php"; - -// Transcode support -$wgAutoloadClasses['WebVideoTranscodeJob'] = "$timedMediaDir/WebVideoTranscode/WebVideoTranscodeJob.php"; - -// API modules: -$wgAutoloadClasses['ApiQueryVideoInfo'] = "$timedMediaDir/ApiQueryVideoInfo.php"; -$wgAPIPropModules['videoinfo'] = 'ApiQueryVideoInfo'; - -$wgAutoloadClasses['ApiTranscodeStatus'] = "$timedMediaDir/ApiTranscodeStatus.php"; -$wgAPIPropModules['transcodestatus'] = 'ApiTranscodeStatus'; - -$wgAutoloadClasses['ApiTranscodeReset'] = "$timedMediaDir/ApiTranscodeReset.php"; -$wgAPIModules['transcodereset'] = 'ApiTranscodeReset'; - -// Localization -$wgMessagesDirs['TimedMediaHandler'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['TimedMediaHandlerMagic'] = "$timedMediaDir/TimedMediaHandler.i18n.magic.php"; -$wgExtensionMessagesFiles['TimedMediaHandlerAliases'] = "$timedMediaDir/TimedMediaHandler.i18n.alias.php"; -// Inlcude module locationlizations -$wgMessagesDirs['MwEmbed.EmbedPlayer'] = __DIR__ . '/MwEmbedModules/EmbedPlayer/i18n'; -$wgMessagesDirs['MwEmbed.TimedText'] = __DIR__ . '/MwEmbedModules/TimedText/i18n'; - -// Special Pages -$wgAutoloadClasses['SpecialTimedMediaHandler'] = "$timedMediaDir/SpecialTimedMediaHandler.php"; -$wgAutoloadClasses['SpecialOrphanedTimedText'] = "$timedMediaDir/SpecialOrphanedTimedText.php"; - -// Register all Timed Media Handler hooks right after initial setup -// This way if you set a variable like $wgTimedTextNS in LocalSettings.php after you include TimedMediaHandler -// we can still read the variable values -$wgExtensionFunctions[] = 'TimedMediaHandlerHooks::register'; - -# add Special pages -$wgSpecialPages['OrphanedTimedText'] = 'SpecialOrphanedTimedText'; -$wgSpecialPages['TimedMediaHandler'] = 'SpecialTimedMediaHandler'; - -// Extension Credits -$wgExtensionCredits['media'][] = array( - 'path' => __FILE__, - 'name' => 'TimedMediaHandler', - 'namemsg' => 'timedmediahandler-extensionname', - 'author' => array( 'Michael Dale', 'Tim Starling', 'James Heinrich', 'Jan Gerber', 'Brion Vibber' ), - 'url' => 'https://www.mediawiki.org/wiki/Extension:TimedMediaHandler', - 'descriptionmsg' => 'timedmediahandler-desc', - 'version' => '0.4.0', - 'license-name' => 'GPL-2.0+', -); diff --git a/WebVideoTranscode/WebVideoTranscode.php b/WebVideoTranscode/WebVideoTranscode.php index e3e4545..f3d9afb 100644 --- a/WebVideoTranscode/WebVideoTranscode.php +++ b/WebVideoTranscode/WebVideoTranscode.php @@ -71,7 +71,7 @@ * * http://firefogg.org/dev/index.html */ - public static $derivativeSettings = array( + public static $derivativeSettingsOGV_160P = array( WebVideoTranscode::ENC_OGV_160P => array( 'maxSize' => '288x160', @@ -88,6 +88,9 @@ 'videoCodec' => 'theora', 'type' => 'video/ogg; codecs="theora, vorbis"', ), + ); + + public static $derivativeSettingsOGV_240P = array( WebVideoTranscode::ENC_OGV_240P => array( 'maxSize' => '426x240', @@ -103,6 +106,9 @@ 'videoCodec' => 'theora', 'type' => 'video/ogg; codecs="theora, vorbis"', ), + ); + + public static $derivativeSettingsOGV_360P = array( WebVideoTranscode::ENC_OGV_360P => array( 'maxSize' => '640x360', @@ -118,6 +124,9 @@ 'videoCodec' => 'theora', 'type' => 'video/ogg; codecs="theora, vorbis"', ), + ); + + public static $derivativeSettingsOGV_480P = array( WebVideoTranscode::ENC_OGV_480P => array( 'maxSize' => '854x480', @@ -133,7 +142,9 @@ 'videoCodec' => 'theora', 'type' => 'video/ogg; codecs="theora, vorbis"', ), + ); + public static $derivativeSettingsOGV_720P = array( WebVideoTranscode::ENC_OGV_720P => array( 'maxSize' => '1280x720', @@ -146,7 +157,9 @@ 'videoCodec' => 'theora', 'type' => 'video/ogg; codecs="theora, vorbis"', ), + ); + public static $derivativeSettingsOGV_1080P = array( WebVideoTranscode::ENC_OGV_1080P => array( 'maxSize' => '1920x1080', @@ -159,7 +172,9 @@ 'videoCodec' => 'theora', 'type' => 'video/ogg; codecs="theora, vorbis"', ), + ); + public static $derivativeSettingsWEBM_160P = array( // WebM transcode: WebVideoTranscode::ENC_WEBM_160P => array( @@ -175,6 +190,9 @@ 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', ), + ); + + public static $derivativeSettingsWEBM_360P = array( WebVideoTranscode::ENC_WEBM_360P => array( 'maxSize' => '640x360', @@ -188,6 +206,9 @@ 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', ), + ); + + public static $derivativeSettingsWEBM_480P = array( WebVideoTranscode::ENC_WEBM_480P => array( 'maxSize' => '854x480', @@ -201,6 +222,9 @@ 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', ), + ); + + public static $derivativeSettingsWEBM_720P = array( WebVideoTranscode::ENC_WEBM_720P => array( 'maxSize' => '1280x720', @@ -210,6 +234,9 @@ 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', ), + ); + + public static $derivativeSettingsWEBM_1080P = array( WebVideoTranscode::ENC_WEBM_1080P => array( 'maxSize' => '1920x1080', @@ -219,6 +246,9 @@ 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', ), + ); + + public static $derivativeSettingsWEBM_1080P = array( WebVideoTranscode::ENC_WEBM_2160P => array( 'maxSize' => '4096x2160', @@ -228,7 +258,9 @@ 'videoCodec' => 'vp8', 'type' => 'video/webm; codecs="vp8, vorbis"', ), + ); + public static $derivativeSettingsVP9_360P = array( // WebM VP9 transcode: WebVideoTranscode::ENC_VP9_360P => array( @@ -243,6 +275,9 @@ 'audioCodec' => 'opus', 'type' => 'video/webm; codecs="vp9, opus"', ), + ); + + public static $derivativeSettingsVP9_480P = array( WebVideoTranscode::ENC_VP9_480P => array( 'maxSize' => '854x480', @@ -256,6 +291,9 @@ 'audioCodec' => 'opus', 'type' => 'video/webm; codecs="vp9, opus"', ), + ); + + public static $derivativeSettingsVP9_720P = array( WebVideoTranscode::ENC_VP9_720P => array( 'maxSize' => '1280x720', @@ -270,6 +308,9 @@ 'tileColumns' => '2', 'type' => 'video/webm; codecs="vp9, opus"', ), + ); + + public static $derivativeSettingsVP9_1080P = array( WebVideoTranscode::ENC_VP9_1080P => array( 'maxSize' => '1920x1080', @@ -284,6 +325,9 @@ 'tileColumns' => '4', 'type' => 'video/webm; codecs="vp9, opus"', ), + ); + + public static $derivativeSettingsVP9_2160P = array( WebVideoTranscode::ENC_VP9_2160P => array( 'maxSize' => '4096x2160', @@ -298,7 +342,9 @@ 'tileColumns' => '4', 'type' => 'video/webm; codecs="vp9, opus"', ), + ); + public static $derivativeSettingsH264_320P = array( // Losly defined per PCF guide to mp4 profiles: // https://develop.participatoryculture.org/index.php/ConversionMatrix // and apple HLS profile guide: @@ -315,7 +361,9 @@ 'audioBitrate' => '40k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', ), + ); + public static $derivativeSettingsH264_480P = array( WebVideoTranscode::ENC_H264_480P => array( 'maxSize' => '640x480', @@ -327,7 +375,9 @@ 'audioBitrate' => '64k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', ), + ); + public static $derivativeSettingsH264_720P = array( WebVideoTranscode::ENC_H264_720P => array( 'maxSize' => '1280x720', @@ -339,7 +389,9 @@ 'audioBitrate' => '128k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', ), + ); + public static $derivativeSettingsH264_1080P = array( WebVideoTranscode::ENC_H264_1080P => array( 'maxSize' => '1920x1080', @@ -350,6 +402,9 @@ 'audioBitrate' => '128k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', ), + ); + + public static $derivativeSettingsH264_2160P = array( WebVideoTranscode::ENC_H264_2160P => array( 'maxSize' => '4096x2160', @@ -360,7 +415,9 @@ 'audioBitrate' => '128k', 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', ), + ); + public static $derivativeSettingsOGG_VORBIS = array( //Audio profiles WebVideoTranscode::ENC_OGG_VORBIS => array( @@ -372,6 +429,9 @@ 'novideo' => 'true', 'type' => 'audio/ogg; codecs="vorbis"', ), + ); + + public static $derivativeSettingsOGG_OPUS = array( WebVideoTranscode::ENC_OGG_OPUS => array( 'audioCodec' => 'opus', @@ -382,6 +442,9 @@ 'novideo' => 'true', 'type' => 'audio/ogg; codecs="opus"', ), + ); + + public static $derivativeSettingsMP3 = array( WebVideoTranscode::ENC_MP3 => array( 'audioCodec' => 'mp3', @@ -392,6 +455,9 @@ 'novideo' => 'true', 'type' => 'audio/mpeg', ), + ); + + public static $derivativeSettingsAAC = array( WebVideoTranscode::ENC_AAC => array( 'audioCodec' => 'aac', @@ -474,10 +540,30 @@ global $wgEnabledTranscodeSet; $maxSize = 0; foreach( $wgEnabledTranscodeSet as $transcodeKey ){ - if( isset( self::$derivativeSettings[$transcodeKey]['videoBitrate'] ) ){ - $currentSize = self::$derivativeSettings[$transcodeKey]['maxSize']; - if( $currentSize > $maxSize ){ - $maxSize = $currentSize; + if ( $wgEnabledTranscodeSet = "OGV_160P" || $wgEnabledTranscodeSet = "WebVideoTranscode::ENC_OGV_160P" ) { + if( isset( self::$derivativeSettingsOGV_160P[$transcodeKey]['videoBitrate'] ) ){ + $currentSize = self::$derivativeSettingsOGV_160P[$transcodeKey]['maxSize']; + if( $currentSize > $maxSize ){ + $maxSize = $currentSize; + } + } + } + } + if ( $wgEnabledTranscodeSet = "OGV_240P" || $wgEnabledTranscodeSet = "WebVideoTranscode::ENC_OGV_240P" ) { + if( isset( self::$derivativeSettingsOGV_240P[$transcodeKey]['videoBitrate'] ) ){ + $currentSize = self::$derivativeSettingsOGV_240P[$transcodeKey]['maxSize']; + if( $currentSize > $maxSize ){ + $maxSize = $currentSize; + } + } + } + } + if ( $wgEnabledTranscodeSet = "OGV_360P" || $wgEnabledTranscodeSet = "WebVideoTranscode::ENC_OGV_360P" ) { + if( isset( self::$derivativeSettingsOGV_360P[$transcodeKey]['videoBitrate'] ) ){ + $currentSize = self::$derivativeSettingsOGV_360P[$transcodeKey]['maxSize']; + if( $currentSize > $maxSize ){ + $maxSize = $currentSize; + } } } } @@ -492,16 +578,18 @@ * @return number */ static public function getProjectedFileSize( $file, $transcodeKey ){ - $settings = self::$derivativeSettings[$transcodeKey]; - if( $settings[ 'videoBitrate' ] && $settings['audioBitrate'] ){ - return $file->getLength() * 8 * ( - self::$derivativeSettings[$transcodeKey]['videoBitrate'] - + - self::$derivativeSettings[$transcodeKey]['audioBitrate'] - ); + if ( $wgEnabledTranscodeSet = "OGV_160P" || $wgEnabledTranscodeSet = "WebVideoTranscode::ENC_OGV_160P" ) { + $settings = self::$derivativeSettingsOGV_160P[$transcodeKey]; + if( $settings[ 'videoBitrate' ] && $settings['audioBitrate'] ){ + return $file->getLength() * 8 * ( + self::$derivativeSettingsOGV_160P[$transcodeKey]['videoBitrate'] + + + self::$derivativeSettingsOGV_160P[$transcodeKey]['audioBitrate'] + ); + } + // Else just return the size of the source video ( we have no idea how large the actual derivative size will be ) + return $file->getLength() * $file->getHandler()->getBitrate( $file ) * 8; } - // Else just return the size of the source video ( we have no idea how large the actual derivative size will be ) - return $file->getLength() * $file->getHandler()->getBitrate( $file ) * 8; } /** @@ -888,33 +976,35 @@ $fileName = $file->getTitle()->getDbKey(); $src = self::getTranscodedUrlForFile( $file, $transcodeKey ); + if ( $wgEnabledTranscodeSet = "OGV_160P" || $wgEnabledTranscodeSet = "WebVideoTranscode::ENC_OGV_160P" ) { + if( $file->getHandler()->isAudio( $file ) ){ + $width = $height = 0; + } else { + list( $width, $height ) = WebVideoTranscode::getMaxSizeTransform( + $file, + self::$derivativeSettingsOGV_160P[$transcodeKey]['maxSize'] + ); + } - if( $file->getHandler()->isAudio( $file ) ){ - $width = $height = 0; - } else { - list( $width, $height ) = WebVideoTranscode::getMaxSizeTransform( - $file, - self::$derivativeSettings[$transcodeKey]['maxSize'] - ); + $framerate = ( isset( self::$derivativeSettingsOGV_160P[$transcodeKey]['framerate'] ) )? + self::$derivativeSettingsOGV_160P[$transcodeKey]['framerate'] : + $file->getHandler()->getFramerate( $file ); + + // Setup the url src: + $src = in_array( 'fullurl', $options) ? wfExpandUrl( $src ) : $src; + $fields = array( + 'src' => $src, + 'title' => wfMessage( 'timedmedia-derivative-desc-' . $transcodeKey )->text(), + 'type' => self::$derivativeSettingsOGV_160P[ $transcodeKey ][ 'type' ], + "shorttitle" => wfMessage( 'timedmedia-derivative-' . $transcodeKey )->text(), + "transcodekey" => $transcodeKey, + + // Add data attributes per emerging DASH / webTV adaptive streaming attributes + // eventually we will define a manifest xml entry point. + "width" => intval( $width ), + "height" => intval( $height ), + ); } - - $framerate = ( isset( self::$derivativeSettings[$transcodeKey]['framerate'] ) )? - self::$derivativeSettings[$transcodeKey]['framerate'] : - $file->getHandler()->getFramerate( $file ); - // Setup the url src: - $src = in_array( 'fullurl', $options) ? wfExpandUrl( $src ) : $src; - $fields = array( - 'src' => $src, - 'title' => wfMessage( 'timedmedia-derivative-desc-' . $transcodeKey )->text(), - 'type' => self::$derivativeSettings[ $transcodeKey ][ 'type' ], - "shorttitle" => wfMessage( 'timedmedia-derivative-' . $transcodeKey )->text(), - "transcodekey" => $transcodeKey, - - // Add data attributes per emerging DASH / webTV adaptive streaming attributes - // eventually we will define a manifest xml entry point. - "width" => intval( $width ), - "height" => intval( $height ), - ); // a "ready" transcode should have a bitrate: if ( isset( self::$transcodeState[$fileName] ) ) { @@ -1003,23 +1093,24 @@ } else { $keys = $wgEnabledTranscodeSet; } - - if ( in_array( $transcodeKey, $keys ) ) { - $settings = self::$derivativeSettings[$transcodeKey]; - if ( $audio ) { - $sourceCodecs = $file->getHandler()->getStreamTypes( $file ); - $sourceCodec = $sourceCodecs ? strtolower( $sourceCodecs[0] ) : ''; - return ( $sourceCodec !== $settings['audioCodec'] ); - } else if ( self::isTargetLargerThanFile( $file, $settings['maxSize'] ) ) { - // Are we the smallest enabled transcode for this type? - // Then go ahead and make a wee little transcode for compat. - return self::isSmallestTranscodeForCodec( $transcodeKey ); + if ( $wgEnabledTranscodeSet = "OGV_160P" || $wgEnabledTranscodeSet = "WebVideoTranscode::ENC_OGV_160P" ) { + if ( in_array( $transcodeKey, $keys ) ) { + $settings = self::$derivativeSettingsOGV_160P[$transcodeKey]; + if ( $audio ) { + $sourceCodecs = $file->getHandler()->getStreamTypes( $file ); + $sourceCodec = $sourceCodecs ? strtolower( $sourceCodecs[0] ) : ''; + return ( $sourceCodec !== $settings['audioCodec'] ); + } else if ( self::isTargetLargerThanFile( $file, $settings['maxSize'] ) ) { + // Are we the smallest enabled transcode for this type? + // Then go ahead and make a wee little transcode for compat. + return self::isSmallestTranscodeForCodec( $transcodeKey ); + } else { + return true; + } } else { - return true; + // Transcode key is invalid or has been disabled. + return false; } - } else { - // Transcode key is invalid or has been disabled. - return false; } } @@ -1147,19 +1238,23 @@ public static function isSmallestTranscodeForCodec( $transcodeKey ) { global $wgEnabledTranscodeSet; - $settings = self::$derivativeSettings[$transcodeKey]; + if ( $wgEnabledTranscodeSet = "OGV_160P" || $wgEnabledTranscodeSet = "WebVideoTranscode::ENC_OGV_160P" ) { + $settings = self::$derivativeSettingsOGV_160P[$transcodeKey]; + } $vcodec = $settings['videoCodec']; $maxSize = self::getMaxSize( $settings['maxSize'] ); - foreach ( $wgEnabledTranscodeSet as $tKey ) { - $tsettings = self::$derivativeSettings[$tKey]; - if ( $tsettings['videoCodec'] === $vcodec ) { - $tmaxSize = self::getMaxSize( $tsettings['maxSize'] ); - if ( $tmaxSize['width'] < $maxSize['width'] ) { - return false; - } - if ( $tmaxSize['height'] < $maxSize['height'] ) { - return false; + if ( $wgEnabledTranscodeSet = "OGV_160P" || $wgEnabledTranscodeSet = "WebVideoTranscode::ENC_OGV_160P" ) { + foreach ( $wgEnabledTranscodeSet as $tKey ) { + $tsettings = self::$derivativeSettingsOGV_160P[$tKey]; + if ( $tsettings['videoCodec'] === $vcodec ) { + $tmaxSize = self::getMaxSize( $tsettings['maxSize'] ); + if ( $tmaxSize['width'] < $maxSize['width'] ) { + return false; + } + if ( $tmaxSize['height'] < $maxSize['height'] ) { + return false; + } } } } diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..1eeb867 --- /dev/null +++ b/extension.json @@ -0,0 +1,154 @@ +{ + "name": "TimedMediaHandler", + "namemsg": "timedmediahandler-extensionname", + "version": "0.4.0", + "author": [ + "Michael Dale", + "Tim Starling", + "James Heinrich", + "Jan Gerber", + "Brion Vibber" + ], + "url": "https://www.mediawiki.org/wiki/Extension:TimedMediaHandler", + "descriptionmsg": "timedmediahandler-desc", + "type": "media", + "license-name": "GPL-2.0+", + "callback": "TimedMediaHandlerHooks::registerExtension", + "@doc": "Read README.md for all comments.", + "GroupPermissions": { + "autoconfirmed": { + "transcode-reset": true + }, + "sysop": { + "transcode-reset": true, + "transcode-status": true + } + }, + "AvailableRights": [ + "transcode-reset", + "transcode-status" + ], + "ExtensionFunctions": [ + "TimedMediaHandlerHooks::register" + ], + "SpecialPages": { + "OrphanedTimedText": "SpecialOrphanedTimedText", + "TimedMediaHandler": "SpecialTimedMediaHandler" + }, + "APIModules": { + "transcodereset": "ApiTranscodeReset" + }, + "APIPropModules": { + "videoinfo": "ApiQueryVideoInfo", + "transcodestatus": "ApiTranscodeStatus" + }, + "MessagesDirs": { + "TimedMediaHandler": [ + "i18n" + ], + "MwEmbed.EmbedPlayer": [ + "MwEmbedModules/EmbedPlayer/i18n" + ], + "MwEmbed.TimedText": [ + "MwEmbedModules/TimedText/i18n" + ] + }, + "ExtensionMessagesFiles": { + "TimedMediaHandlerMagic": "TimedMediaHandler.i18n.magic.php", + "TimedMediaHandlerAliases": "TimedMediaHandler.i18n.alias.php" + }, + "AutoloadClasses": { + "WebVideoTranscode": "WebVideoTranscode/WebVideoTranscode.php", + "TimedMediaHandler": "TimedMediaHandler_body.php", + "TimedMediaHandlerHooks": "TimedMediaHandler.hooks.php", + "TimedMediaTransformOutput": "TimedMediaTransformOutput.php", + "TimedMediaIframeOutput": "TimedMediaIframeOutput.php", + "TimedMediaThumbnail": "TimedMediaThumbnail.php", + "TranscodeStatusTable": "TranscodeStatusTable.php", + "ApiTestCaseVideoUpload": "tests/phpunit/ApiTestCaseVideoUpload.php", + "OggHandlerTMH": "handlers/OggHandler/OggHandler.php", + "OggException": "handlers/OggHandler/OggException.php", + "File_Ogg": "handlers/OggHandler/File_Ogg/File/Ogg.php", + "File_Ogg_Bitstream": "handlers/OggHandler/File_Ogg/File/Ogg/Bitstream.php", + "File_Ogg_Flac": "handlers/OggHandler/File_Ogg/File/Ogg/Flac.php", + "File_Ogg_Media": "handlers/OggHandler/File_Ogg/File/Ogg/Media.php", + "File_Ogg_Opus": "handlers/OggHandler/File_Ogg/File/Ogg/Opus.php", + "File_Ogg_Speex": "handlers/OggHandler/File_Ogg/File/Ogg/Speex.php", + "File_Ogg_Theora": "handlers/OggHandler/File_Ogg/File/Ogg/Theora.php", + "File_Ogg_Vorbis": "handlers/OggHandler/File_Ogg/File/Ogg/Vorbis.php", + "getID3": "libs/getid3/getid3.php", + "getid3_exception": "libs/getid3/getid3.php", + "getid3_handler": "libs/getid3/getid3.php", + "ID3Handler": "handlers/ID3Handler/ID3Handler.php", + "Mp4Handler": "handlers/Mp4Handler/Mp4Handler.php", + "WebMHandler": "handlers/WebMHandler/WebMHandler.php", + "FLACHandler": "handlers/FLACHandler/FLACHandler.php", + "WAVHandler": "handlers/WAVHandler/WAVHandler.php", + "ForeignApiQueryAllPages": "handlers/TextHandler/TextHandler.php", + "TextHandler": "handlers/TextHandler/TextHandler.php", + "TimedTextPage": "TimedTextPage.php", + "WebVideoTranscodeJob": "WebVideoTranscode/WebVideoTranscodeJob.php", + "ApiQueryVideoInfo": "ApiQueryVideoInfo.php", + "ApiTranscodeStatus": "ApiTranscodeStatus.php", + "ApiTranscodeReset": "ApiTranscodeReset.php", + "SpecialTimedMediaHandler": "SpecialTimedMediaHandler.php", + "SpecialOrphanedTimedText": "SpecialOrphanedTimedText.php" + }, + "config": { + "MwEmbedModuleConfig": { + "EmbedPlayer.DirectFileLinkWarning": true, + "EmbedPlayer.EnableOptionsMenu": true, + "EmbedPlayer.DisableHTML5FlashFallback": true, + "TimedText.ShowInterface": "always", + "TimedText.ShowAddTextLink": true + }, + "WaitTimeForTranscodeReset": 3600, + "MinimumVideoPlayerSize": 200, + "EnabledTranscodeSet": [ + "WebVideoTranscode::ENC_OGV_160P", + "WebVideoTranscode::ENC_OGV_240P", + "WebVideoTranscode::ENC_OGV_360P", + "WebVideoTranscode::ENC_OGV_480P", + "WebVideoTranscode::ENC_WEBM_160P", + "WebVideoTranscode::ENC_WEBM_360P", + "WebVideoTranscode::ENC_WEBM_480P", + "WebVideoTranscode::ENC_WEBM_720P", + "WebVideoTranscode::ENC_WEBM_1080P", + "WebVideoTranscode::ENC_WEBM_2160P", + "WebVideoTranscode::ENC_VP9_360P", + "WebVideoTranscode::ENC_VP9_720P", + "WebVideoTranscode::ENC_VP9_1080P", + "WebVideoTranscode::ENC_VP9_2160P" + ], + "EnabledAudioTranscodeSet": [ + "OGG_VORBIS" + ], + "MediaVideoTypes": [ + "Theora", + "VP8" + ], + "MediaAudioTypes": [ + "Vorbis", + "Speex", + "FLAC", + "Opus" + ], + "VideoPlayerSkinModule": "mw.PlayerSkinKskin", + "EnableIframeEmbed": true, + "EnableTranscode": true, + "EnableNiceBackgroundTranscodeJobs": false, + "TranscodeBackgroundPriority": 19, + "TranscodeBackgroundTimeLimit": 28800, + "TranscodeBackgroundMemoryLimit": 2097152, + "TranscodeBackgroundSizeLimit": 3145728, + "FFmpegThreads": 1, + "FFmpeg2theoraLocation": "/usr/bin/ffmpeg2theora", + "OggThumbLocation": "/usr/bin/oggThumb", + "FFmpegLocation": "/usr/bin/avconv", + "TimedTextNS": 710, + "EnableLocalTimedText": true, + "TmhEnableMp4Uploads": false, + "TmhTheoraTwoPassEncoding": false + }, + "manifest_version": 1 +} -- To view, visit https://gerrit.wikimedia.org/r/251701 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie2ce639247bf38721b372ed3fe200fcb2d9f91d0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: master Gerrit-Owner: Paladox <thomasmulhall...@yahoo.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits