Paladox has uploaded a new change for review. https://gerrit.wikimedia.org/r/251545
Change subject: Test: DO NOT MERGE ...................................................................... Test: DO NOT MERGE Change-Id: I220e2a6fa16fadb22199107b73eabfb02fa18c6b --- D README A README.md M TimedMediaHandler.hooks.php M TimedMediaHandler.php M WebVideoTranscode/WebVideoTranscode.php A extension.json 6 files changed, 891 insertions(+), 764 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler refs/changes/45/251545/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..10ed434 100644 --- a/WebVideoTranscode/WebVideoTranscode.php +++ b/WebVideoTranscode/WebVideoTranscode.php @@ -59,9 +59,380 @@ const ENC_OGG_OPUS = 'opus'; const ENC_MP3 = 'mp3'; const ENC_AAC = 'm4a'; + const TimedMediaEncoding = ''; // Static cache of transcode state per instantiation public static $transcodeState = array() ; + + public static function TimedMediaEncoding() { + global $wgEnabledTranscodeSet, $wgEnabledAudioTranscodeSet; + + if ( $wgEnabledTranscodeSet != "OGV_160P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_OGV_160P ) { + WebVideoTranscode::ENC_OGV_160P => + array( + 'maxSize' => '288x160', + 'videoBitrate' => '160', + 'framerate' => '15', + 'audioQuality' => '-1', + 'samplerate' => '44100', + 'channels' => '2', + 'noUpscaling' => 'true', + 'twopass' => 'false', // will be overridden by $wgTmhTheoraTwoPassEncoding + 'optimize' => 'true', + 'keyframeInterval' => '128', + 'bufDelay' => '256', + 'videoCodec' => 'theora', + 'type' => 'video/ogg; codecs="theora, vorbis"', + ), + } + if ( $wgEnabledTranscodeSet != "OGV_240P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_OGV_240P ) { + WebVideoTranscode::ENC_OGV_240P => + array( + 'maxSize' => '426x240', + 'videoBitrate' => '512', + 'audioQuality' => '0', + 'samplerate' => '44100', + 'channels' => '2', + 'noUpscaling' => 'true', + 'twopass' => 'false', // will be overridden by $wgTmhTheoraTwoPassEncoding + 'optimize' => 'true', + 'keyframeInterval' => '128', + 'bufDelay' => '256', + 'videoCodec' => 'theora', + 'type' => 'video/ogg; codecs="theora, vorbis"', + ), + } + if ( $wgEnabledTranscodeSet != "OGV_360P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_OGV_360P ) { + WebVideoTranscode::ENC_OGV_360P => + array( + 'maxSize' => '640x360', + 'videoBitrate' => '1024', + 'audioQuality' => '1', + 'samplerate' => '44100', + 'channels' => '2', + 'noUpscaling' => 'true', + 'twopass' => 'false', // will be overridden by $wgTmhTheoraTwoPassEncoding + 'optimize' => 'true', + 'keyframeInterval' => '128', + 'bufDelay' => '256', + 'videoCodec' => 'theora', + 'type' => 'video/ogg; codecs="theora, vorbis"', + ), + } + if ( $wgEnabledTranscodeSet != "OGV_480P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_OGV_480P ) { + WebVideoTranscode::ENC_OGV_480P => + array( + 'maxSize' => '854x480', + 'videoBitrate' => '2048', + 'audioQuality' => '2', + 'samplerate' => '44100', + 'channels' => '2', + 'noUpscaling' => 'true', + 'twopass' => 'false', // will be overridden by $wgTmhTheoraTwoPassEncoding + 'optimize' => 'true', + 'keyframeInterval' => '128', + 'bufDelay' => '256', + 'videoCodec' => 'theora', + 'type' => 'video/ogg; codecs="theora, vorbis"', + ), + } + if ( $wgEnabledTranscodeSet != "OGV_720P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_OGV_720P ) { + WebVideoTranscode::ENC_OGV_720P => + array( + 'maxSize' => '1280x720', + 'videoQuality' => 6, + 'audioQuality' => 3, + 'noUpscaling' => 'true', + 'twopass' => 'false', // will be overridden by $wgTmhTheoraTwoPassEncoding + 'optimize' => 'true', + 'keyframeInterval' => '128', + 'videoCodec' => 'theora', + 'type' => 'video/ogg; codecs="theora, vorbis"', + ), + } + if ( $wgEnabledTranscodeSet != "OGV_1080P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_OGV_1080P ) { + WebVideoTranscode::ENC_OGV_1080P => + array( + 'maxSize' => '1920x1080', + 'videoQuality' => 6, + 'audioQuality' => 3, + 'noUpscaling' => 'true', + 'twopass' => 'false', // will be overridden by $wgTmhTheoraTwoPassEncoding + 'optimize' => 'true', + 'keyframeInterval' => '128', + 'videoCodec' => 'theora', + 'type' => 'video/ogg; codecs="theora, vorbis"', + ), + } + if ( $wgEnabledTranscodeSet != "WEBM_160P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_WEBM_160P ) { + WebVideoTranscode::ENC_WEBM_160P => + array( + 'maxSize' => '288x160', + 'videoBitrate' => '256', + 'audioQuality' => '-1', + 'samplerate' => '44100', + 'channels' => '2', + 'noUpscaling' => 'true', + 'twopass' => 'true', + 'keyframeInterval' => '128', + 'bufDelay' => '256', + 'videoCodec' => 'vp8', + 'type' => 'video/webm; codecs="vp8, vorbis"', + ), + } + if ( $wgEnabledTranscodeSet != "WEBM_360P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_WEBM_360P ) { + WebVideoTranscode::ENC_WEBM_360P => + array( + 'maxSize' => '640x360', + 'videoBitrate' => '512', + 'audioQuality' => '1', + 'samplerate' => '44100', + 'noUpscaling' => 'true', + 'twopass' => 'true', + 'keyframeInterval' => '128', + 'bufDelay' => '256', + 'videoCodec' => 'vp8', + 'type' => 'video/webm; codecs="vp8, vorbis"', + ), + } + if ( $wgEnabledTranscodeSet != "WEBM_480P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_WEBM_480P ) { + WebVideoTranscode::ENC_WEBM_480P => + array( + 'maxSize' => '854x480', + 'videoBitrate' => '1024', + 'audioQuality' => '2', + 'samplerate' => '44100', + 'noUpscaling' => 'true', + 'twopass' => 'true', + 'keyframeInterval' => '128', + 'bufDelay' => '256', + 'videoCodec' => 'vp8', + 'type' => 'video/webm; codecs="vp8, vorbis"', + ), + } + if ( $wgEnabledTranscodeSet != "WEBM_720P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_WEBM_720P ) { + WebVideoTranscode::ENC_WEBM_720P => + array( + 'maxSize' => '1280x720', + 'videoQuality' => 7, + 'audioQuality' => 3, + 'noUpscaling' => 'true', + 'videoCodec' => 'vp8', + 'type' => 'video/webm; codecs="vp8, vorbis"', + ), + } + if ( $wgEnabledTranscodeSet != "WEBM_1080P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_WEBM_1080P ) { + WebVideoTranscode::ENC_WEBM_1080P => + array( + 'maxSize' => '1920x1080', + 'videoQuality' => 7, + 'audioQuality' => 3, + 'noUpscaling' => 'true', + 'videoCodec' => 'vp8', + 'type' => 'video/webm; codecs="vp8, vorbis"', + ), + } + if ( $wgEnabledTranscodeSet != "WEBM_2160P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_WEBM_2160P ) { + WebVideoTranscode::ENC_WEBM_2160P => + array( + 'maxSize' => '4096x2160', + 'videoQuality' => 7, + 'audioQuality' => 3, + 'noUpscaling' => 'true', + 'videoCodec' => 'vp8', + 'type' => 'video/webm; codecs="vp8, vorbis"', + ), + } + if ( $wgEnabledTranscodeSet != "VP9_360P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_VP9_360P ) { + WebVideoTranscode::ENC_VP9_360P => + array( + 'maxSize' => '640x360', + 'videoBitrate' => '256', + 'samplerate' => '48000', + 'noUpscaling' => 'true', + 'twopass' => 'true', + 'keyframeInterval' => '128', + 'bufDelay' => '256', + 'videoCodec' => 'vp9', + 'audioCodec' => 'opus', + 'type' => 'video/webm; codecs="vp9, opus"', + ), + } + if ( $wgEnabledTranscodeSet != "VP9_480P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_VP9_480P ) { + WebVideoTranscode::ENC_VP9_480P => + array( + 'maxSize' => '854x480', + 'videoBitrate' => '512', + 'samplerate' => '48000', + 'noUpscaling' => 'true', + 'twopass' => 'true', + 'keyframeInterval' => '128', + 'bufDelay' => '256', + 'videoCodec' => 'vp9', + 'audioCodec' => 'opus', + 'type' => 'video/webm; codecs="vp9, opus"', + ), + } + if ( $wgEnabledTranscodeSet != "VP9_720P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_VP9_720P ) { + WebVideoTranscode::ENC_VP9_720P => + array( + 'maxSize' => '1280x720', + 'videoBitrate' => '1024', + 'samplerate' => '48000', + 'noUpscaling' => 'true', + 'twopass' => 'true', + 'keyframeInterval' => '128', + 'bufDelay' => '256', + 'videoCodec' => 'vp9', + 'audioCodec' => 'opus', + 'tileColumns' => '2', + 'type' => 'video/webm; codecs="vp9, opus"', + ), + } + if ( $wgEnabledTranscodeSet != "VP9_1080P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_VP9_1080P ) { + WebVideoTranscode::ENC_VP9_1080P => + array( + 'maxSize' => '1920x1080', + 'videoBitrate' => '2048', + 'samplerate' => '48000', + 'noUpscaling' => 'true', + 'twopass' => 'true', + 'keyframeInterval' => '128', + 'bufDelay' => '256', + 'videoCodec' => 'vp9', + 'audioCodec' => 'opus', + 'tileColumns' => '4', + 'type' => 'video/webm; codecs="vp9, opus"', + ), + } + if ( $wgEnabledTranscodeSet != "VP9_2160P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_VP9_2160P ) { + WebVideoTranscode::ENC_VP9_2160P => + array( + 'maxSize' => '4096x2160', + 'videoBitrate' => '8192', + 'samplerate' => '48000', + 'noUpscaling' => 'true', + 'twopass' => 'true', + 'keyframeInterval' => '128', + 'bufDelay' => '256', + 'videoCodec' => 'vp9', + 'audioCodec' => 'opus', + 'tileColumns' => '4', + 'type' => 'video/webm; codecs="vp9, opus"', + ), + } + if ( $wgEnabledTranscodeSet != "H264_320P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_H264_320P ) { + WebVideoTranscode::ENC_H264_320P => + array( + 'maxSize' => '480x320', + 'videoCodec' => 'h264', + 'preset' => 'ipod320', + 'videoBitrate' => '400k', + 'audioCodec' => 'aac', + 'channels' => '2', + 'audioBitrate' => '40k', + 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', + ), + } + if ( $wgEnabledTranscodeSet != "H264_480P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_H264_480P ) { + WebVideoTranscode::ENC_H264_480P => + array( + 'maxSize' => '640x480', + 'videoCodec' => 'h264', + 'preset' => 'ipod640', + 'videoBitrate' => '1200k', + 'audioCodec' => 'aac', + 'channels' => '2', + 'audioBitrate' => '64k', + 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', + ), + } + if ( $wgEnabledTranscodeSet != "H264_720P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_H264_720P ) { + WebVideoTranscode::ENC_H264_720P => + array( + 'maxSize' => '1280x720', + 'videoCodec' => 'h264', + 'preset' => '720p', + 'videoBitrate' => '2500k', + 'audioCodec' => 'aac', + 'channels' => '2', + 'audioBitrate' => '128k', + 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', + ), + } + if ( $wgEnabledTranscodeSet != "H264_1080P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_H264_1080P ) { + WebVideoTranscode::ENC_H264_1080P => + array( + 'maxSize' => '1920x1080', + 'videoCodec' => 'h264', + 'videoBitrate' => '5000k', + 'audioCodec' => 'aac', + 'channels' => '2', + 'audioBitrate' => '128k', + 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', + ), + } + if ( $wgEnabledTranscodeSet != "H264_2160P" || $wgEnabledTranscodeSet != WebVideoTranscode::ENC_H264_2160P ) { + WebVideoTranscode::ENC_H264_2160P => + array( + 'maxSize' => '4096x2160', + 'videoCodec' => 'h264', + 'videoBitrate' => '16384k', + 'audioCodec' => 'aac', + 'channels' => '2', + 'audioBitrate' => '128k', + 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', + ), + } + if ( $wgEnabledAudioTranscodeSet != "OGG_VORBIS" || $wgEnabledAudioTranscodeSet != WebVideoTranscode::ENC_OGG_VORBIS ) { + WebVideoTranscode::ENC_OGG_VORBIS => + array( + 'audioCodec' => 'vorbis', + 'audioQuality' => '1', + 'samplerate' => '44100', + 'channels' => '2', + 'noUpscaling' => 'true', + 'novideo' => 'true', + 'type' => 'audio/ogg; codecs="vorbis"', + ), + } + if ( $wgEnabledAudioTranscodeSet != "OGG_OPUS" || $wgEnabledAudioTranscodeSet != WebVideoTranscode::ENC_OGG_OPUS ) { + WebVideoTranscode::ENC_OGG_OPUS => + array( + 'audioCodec' => 'opus', + 'audioQuality' => '1', + 'samplerate' => '44100', + 'channels' => '2', + 'noUpscaling' => 'true', + 'novideo' => 'true', + 'type' => 'audio/ogg; codecs="opus"', + ), + } + if ( $wgEnabledAudioTranscodeSet != "ENC_MP3" || $wgEnabledAudioTranscodeSet != WebVideoTranscode::ENC_ENC_MP3 ) { + WebVideoTranscode::ENC_MP3 => + array( + 'audioCodec' => 'mp3', + 'audioQuality' => '1', + 'samplerate' => '44100', + 'channels' => '2', + 'noUpscaling' => 'true', + 'novideo' => 'true', + 'type' => 'audio/mpeg', + ), + } + if ( $wgEnabledAudioTranscodeSet != "ENC_AAC" || $wgEnabledAudioTranscodeSet != WebVideoTranscode::ENC_ENC_AAC ) { + WebVideoTranscode::ENC_AAC => + array( + 'audioCodec' => 'aac', + 'audioQuality' => '1', + 'samplerate' => '44100', + 'channels' => '2', + 'noUpscaling' => 'true', + 'novideo' => 'true', + 'type' => 'audio/mp4; codecs="mp4a.40.5"', + ), + } + } /** * Encoding parameters are set via firefogg encode api @@ -72,338 +443,9 @@ * http://firefogg.org/dev/index.html */ public static $derivativeSettings = array( - WebVideoTranscode::ENC_OGV_160P => - array( - 'maxSize' => '288x160', - 'videoBitrate' => '160', - 'framerate' => '15', - 'audioQuality' => '-1', - 'samplerate' => '44100', - 'channels' => '2', - 'noUpscaling' => 'true', - 'twopass' => 'false', // will be overridden by $wgTmhTheoraTwoPassEncoding - 'optimize' => 'true', - 'keyframeInterval' => '128', - 'bufDelay' => '256', - 'videoCodec' => 'theora', - 'type' => 'video/ogg; codecs="theora, vorbis"', - ), - WebVideoTranscode::ENC_OGV_240P => - array( - 'maxSize' => '426x240', - 'videoBitrate' => '512', - 'audioQuality' => '0', - 'samplerate' => '44100', - 'channels' => '2', - 'noUpscaling' => 'true', - 'twopass' => 'false', // will be overridden by $wgTmhTheoraTwoPassEncoding - 'optimize' => 'true', - 'keyframeInterval' => '128', - 'bufDelay' => '256', - 'videoCodec' => 'theora', - 'type' => 'video/ogg; codecs="theora, vorbis"', - ), - WebVideoTranscode::ENC_OGV_360P => - array( - 'maxSize' => '640x360', - 'videoBitrate' => '1024', - 'audioQuality' => '1', - 'samplerate' => '44100', - 'channels' => '2', - 'noUpscaling' => 'true', - 'twopass' => 'false', // will be overridden by $wgTmhTheoraTwoPassEncoding - 'optimize' => 'true', - 'keyframeInterval' => '128', - 'bufDelay' => '256', - 'videoCodec' => 'theora', - 'type' => 'video/ogg; codecs="theora, vorbis"', - ), - WebVideoTranscode::ENC_OGV_480P => - array( - 'maxSize' => '854x480', - 'videoBitrate' => '2048', - 'audioQuality' => '2', - 'samplerate' => '44100', - 'channels' => '2', - 'noUpscaling' => 'true', - 'twopass' => 'false', // will be overridden by $wgTmhTheoraTwoPassEncoding - 'optimize' => 'true', - 'keyframeInterval' => '128', - 'bufDelay' => '256', - 'videoCodec' => 'theora', - 'type' => 'video/ogg; codecs="theora, vorbis"', - ), - - WebVideoTranscode::ENC_OGV_720P => - array( - 'maxSize' => '1280x720', - 'videoQuality' => 6, - 'audioQuality' => 3, - 'noUpscaling' => 'true', - 'twopass' => 'false', // will be overridden by $wgTmhTheoraTwoPassEncoding - 'optimize' => 'true', - 'keyframeInterval' => '128', - 'videoCodec' => 'theora', - 'type' => 'video/ogg; codecs="theora, vorbis"', - ), - - WebVideoTranscode::ENC_OGV_1080P => - array( - 'maxSize' => '1920x1080', - 'videoQuality' => 6, - 'audioQuality' => 3, - 'noUpscaling' => 'true', - 'twopass' => 'false', // will be overridden by $wgTmhTheoraTwoPassEncoding - 'optimize' => 'true', - 'keyframeInterval' => '128', - 'videoCodec' => 'theora', - 'type' => 'video/ogg; codecs="theora, vorbis"', - ), - - // WebM transcode: - WebVideoTranscode::ENC_WEBM_160P => - array( - 'maxSize' => '288x160', - 'videoBitrate' => '256', - 'audioQuality' => '-1', - 'samplerate' => '44100', - 'channels' => '2', - 'noUpscaling' => 'true', - 'twopass' => 'true', - 'keyframeInterval' => '128', - 'bufDelay' => '256', - 'videoCodec' => 'vp8', - 'type' => 'video/webm; codecs="vp8, vorbis"', - ), - WebVideoTranscode::ENC_WEBM_360P => - array( - 'maxSize' => '640x360', - 'videoBitrate' => '512', - 'audioQuality' => '1', - 'samplerate' => '44100', - 'noUpscaling' => 'true', - 'twopass' => 'true', - 'keyframeInterval' => '128', - 'bufDelay' => '256', - 'videoCodec' => 'vp8', - 'type' => 'video/webm; codecs="vp8, vorbis"', - ), - WebVideoTranscode::ENC_WEBM_480P => - array( - 'maxSize' => '854x480', - 'videoBitrate' => '1024', - 'audioQuality' => '2', - 'samplerate' => '44100', - 'noUpscaling' => 'true', - 'twopass' => 'true', - 'keyframeInterval' => '128', - 'bufDelay' => '256', - 'videoCodec' => 'vp8', - 'type' => 'video/webm; codecs="vp8, vorbis"', - ), - WebVideoTranscode::ENC_WEBM_720P => - array( - 'maxSize' => '1280x720', - 'videoQuality' => 7, - 'audioQuality' => 3, - 'noUpscaling' => 'true', - 'videoCodec' => 'vp8', - 'type' => 'video/webm; codecs="vp8, vorbis"', - ), - WebVideoTranscode::ENC_WEBM_1080P => - array( - 'maxSize' => '1920x1080', - 'videoQuality' => 7, - 'audioQuality' => 3, - 'noUpscaling' => 'true', - 'videoCodec' => 'vp8', - 'type' => 'video/webm; codecs="vp8, vorbis"', - ), - WebVideoTranscode::ENC_WEBM_2160P => - array( - 'maxSize' => '4096x2160', - 'videoQuality' => 7, - 'audioQuality' => 3, - 'noUpscaling' => 'true', - 'videoCodec' => 'vp8', - 'type' => 'video/webm; codecs="vp8, vorbis"', - ), - - // WebM VP9 transcode: - WebVideoTranscode::ENC_VP9_360P => - array( - 'maxSize' => '640x360', - 'videoBitrate' => '256', - 'samplerate' => '48000', - 'noUpscaling' => 'true', - 'twopass' => 'true', - 'keyframeInterval' => '128', - 'bufDelay' => '256', - 'videoCodec' => 'vp9', - 'audioCodec' => 'opus', - 'type' => 'video/webm; codecs="vp9, opus"', - ), - WebVideoTranscode::ENC_VP9_480P => - array( - 'maxSize' => '854x480', - 'videoBitrate' => '512', - 'samplerate' => '48000', - 'noUpscaling' => 'true', - 'twopass' => 'true', - 'keyframeInterval' => '128', - 'bufDelay' => '256', - 'videoCodec' => 'vp9', - 'audioCodec' => 'opus', - 'type' => 'video/webm; codecs="vp9, opus"', - ), - WebVideoTranscode::ENC_VP9_720P => - array( - 'maxSize' => '1280x720', - 'videoBitrate' => '1024', - 'samplerate' => '48000', - 'noUpscaling' => 'true', - 'twopass' => 'true', - 'keyframeInterval' => '128', - 'bufDelay' => '256', - 'videoCodec' => 'vp9', - 'audioCodec' => 'opus', - 'tileColumns' => '2', - 'type' => 'video/webm; codecs="vp9, opus"', - ), - WebVideoTranscode::ENC_VP9_1080P => - array( - 'maxSize' => '1920x1080', - 'videoBitrate' => '2048', - 'samplerate' => '48000', - 'noUpscaling' => 'true', - 'twopass' => 'true', - 'keyframeInterval' => '128', - 'bufDelay' => '256', - 'videoCodec' => 'vp9', - 'audioCodec' => 'opus', - 'tileColumns' => '4', - 'type' => 'video/webm; codecs="vp9, opus"', - ), - WebVideoTranscode::ENC_VP9_2160P => - array( - 'maxSize' => '4096x2160', - 'videoBitrate' => '8192', - 'samplerate' => '48000', - 'noUpscaling' => 'true', - 'twopass' => 'true', - 'keyframeInterval' => '128', - 'bufDelay' => '256', - 'videoCodec' => 'vp9', - 'audioCodec' => 'opus', - 'tileColumns' => '4', - 'type' => 'video/webm; codecs="vp9, opus"', - ), - - // Losly defined per PCF guide to mp4 profiles: - // https://develop.participatoryculture.org/index.php/ConversionMatrix - // and apple HLS profile guide: - // https://developer.apple.com/library/ios/#documentation/networkinginternet/conceptual/streamingmediaguide/UsingHTTPLiveStreaming/UsingHTTPLiveStreaming.html#//apple_ref/doc/uid/TP40008332-CH102-DontLinkElementID_24 - - WebVideoTranscode::ENC_H264_320P => - array( - 'maxSize' => '480x320', - 'videoCodec' => 'h264', - 'preset' => 'ipod320', - 'videoBitrate' => '400k', - 'audioCodec' => 'aac', - 'channels' => '2', - 'audioBitrate' => '40k', - 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), - - WebVideoTranscode::ENC_H264_480P => - array( - 'maxSize' => '640x480', - 'videoCodec' => 'h264', - 'preset' => 'ipod640', - 'videoBitrate' => '1200k', - 'audioCodec' => 'aac', - 'channels' => '2', - 'audioBitrate' => '64k', - 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), - - WebVideoTranscode::ENC_H264_720P => - array( - 'maxSize' => '1280x720', - 'videoCodec' => 'h264', - 'preset' => '720p', - 'videoBitrate' => '2500k', - 'audioCodec' => 'aac', - 'channels' => '2', - 'audioBitrate' => '128k', - 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), - - WebVideoTranscode::ENC_H264_1080P => - array( - 'maxSize' => '1920x1080', - 'videoCodec' => 'h264', - 'videoBitrate' => '5000k', - 'audioCodec' => 'aac', - 'channels' => '2', - 'audioBitrate' => '128k', - 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), - WebVideoTranscode::ENC_H264_2160P => - array( - 'maxSize' => '4096x2160', - 'videoCodec' => 'h264', - 'videoBitrate' => '16384k', - 'audioCodec' => 'aac', - 'channels' => '2', - 'audioBitrate' => '128k', - 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', - ), - - //Audio profiles - WebVideoTranscode::ENC_OGG_VORBIS => - array( - 'audioCodec' => 'vorbis', - 'audioQuality' => '1', - 'samplerate' => '44100', - 'channels' => '2', - 'noUpscaling' => 'true', - 'novideo' => 'true', - 'type' => 'audio/ogg; codecs="vorbis"', - ), - WebVideoTranscode::ENC_OGG_OPUS => - array( - 'audioCodec' => 'opus', - 'audioQuality' => '1', - 'samplerate' => '44100', - 'channels' => '2', - 'noUpscaling' => 'true', - 'novideo' => 'true', - 'type' => 'audio/ogg; codecs="opus"', - ), - WebVideoTranscode::ENC_MP3 => - array( - 'audioCodec' => 'mp3', - 'audioQuality' => '1', - 'samplerate' => '44100', - 'channels' => '2', - 'noUpscaling' => 'true', - 'novideo' => 'true', - 'type' => 'audio/mpeg', - ), - WebVideoTranscode::ENC_AAC => - array( - 'audioCodec' => 'aac', - 'audioQuality' => '1', - 'samplerate' => '44100', - 'channels' => '2', - 'noUpscaling' => 'true', - 'novideo' => 'true', - 'type' => 'audio/mp4; codecs="mp4a.40.5"', - ), + WebVideoTranscode::TimedMediaEncoding ); - + /** * @param $file File * @param $transcodeKey string diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..87b48d9 --- /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": [ + "OGV_160P", + "OGV_240P", + "OGV_360P", + "OGV_480P", + "WEBM_160P", + "WEBM_360P", + "WEBM_480P", + "WEBM_720P", + "WEBM_1080P", + "WEBM_2160P", + "VP9_360P", + "VP9_720P", + "VP9_1080P", + "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/251545 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I220e2a6fa16fadb22199107b73eabfb02fa18c6b 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