Release status: beta
|Description||Integrated support for server side transcoding, WebM, Ogg Theora, Vorbis, Speex and Timed Text|
|Author(s)||Michael Dale, Jan Gerber, Tim Starling, James Heinrich and Brion Vibber|
|Latest version||0.4.0 (2014-04-02)|
Translate the TimedMediaHandler extension if it is available at translatewiki.net
|Check usage and version matrix; code metrics|
|Open tasks · Report a bug|
The TimedMediaHandler extension allows you to display audio and video files in wiki pages, using the same syntax as for image files. It includes the Kaltura HTML5 Player, which supports integrated standard timed text support, real time stream switching between multiple WebM and Ogg derivatives and many other features. TMH server side support includes multiple transcode profiles, php based medata parsing via PEAR Ogg / OggHandler and getID3 for WebM files, and integrates with mediaWiki's jobQueue system for scheduling transcoding jobs.
Feature Overview[edit | edit source]
Syntax synopsis[edit | edit source]
In addition to the image embed syntax, Timed Media Handler supports:
- Display a video at its nominal size. Displays a still image from the midpoint with a play button to start an embedded player.
- Show a placeholder for a sound file, with a play button to start an embedded player.
- Show a video in a floating thumbnail box
- Show a video embedded in an image gallery ( each clip will popup a dialog for the full player )
- Use a frame from 1 minute 25 seconds into the video as the placeholder image. A single number is taken as an offset in seconds.
- Temporal media fragments Displays a video clip starting at 1 minute 25 seconds into the video. A single number is taken as an offset in seconds. You can also include an end time of the form
end=1:30Which would result in a clip of 5 seconds playing from 1:25 to 1:30. If thumbtime is not provided, the start time will be used for the displayed thumbnail.
Client support[edit | edit source]
Third-party users of MediaWiki may also wish to manually enable MP4 H.264/AAC support for native video and audio playback in Safari/IE/Edge, but when using these formats you may need a patent license from MPEG-LA for internet broadcasting.
Installation[edit | edit source]
Also see the README for detailed install instructions.
You will want a recent version of ffmpeg in order to support encoding to WebM ( with the latest version of VP8) and a copy of ffmpeg2theora to encode ogg videos. j^ supplies up-to-date static builds of ffmpeg with WebM support and of ffmpeg2theora for major OSs at firefogg.org/nightly/
- Download and place the file(s) in a directory called
- Add the following code at the bottom of your LocalSettings.php:
// TimedMediaHandler is dependent on mwEmbedSupport require_once "$IP/extensions/MwEmbedSupport/MwEmbedSupport.php"; // TimedMediaHandler require_once( "$IP/extensions/TimedMediaHandler/TimedMediaHandler.php" );
- Run the update script which will automatically create the necessary database tables that this extension needs.
- Special:Version on your wiki to verify that the extension is successfully installed. Done - Navigate to
The extension will automatically add supported file types (except mp4) to $wgFileExtensions, so you do not need to manually add video file types.
Comparison of Wikipedia media encoding options[edit | edit source]
Sorted by bandwidth tier (grayed items are not currently enabled):
|Bitrate||Mbit/s||Ogg Theora||WebM VP8||WebM VP9|
|Max width (pixels)||288||426||640||854||1280||1920||288||640||854||1280||1920||4096||640||854||1280||1920||4096|
|Max height (pixels)||160||240||360||480||720||1080||160||360||480||720||1080||2160||360||480||720||1080||2160|
|Sampling rate (Hz)||44100|
Configuration[edit | edit source]
Here are the configuration variables and their default settings:
// 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 );
For transcoding, make sure you have $wgMaxShellMemory, $wgMaxShellTime, $wgMaxShellFileSize are large enough to allow encoding jobs to run and save output. Default values are most likely too low.
Running transcode jobs[edit | edit source]
Because transcode jobs are resource intensive they will not run as part of normal job queue ( see bug 27336 ) Instead they must be requested by the --type argument:
php runJobs.php --type webVideoTranscode
Encoding nodes[edit | edit source]
To be able to transcode many videos you might want to run multiple encoding nodes that connect to the master db and access your file store directly. If you are using ubuntu lucid (10.04) you should add this ppa and install php5-cli php-pear imagemagick ffmpeg ffmpeg2theora.
Minimal install under Ubuntu 12.04[edit | edit source]
add-apt-repository ppa:j/timedmediahandler apt-get install php5-cli php-pear imagemagick ffmpeg ffmpeg2theora
In Localsettings.php, add the path for PEAR !
ini_set( "include_path", ".:$IP:$IP/includes:$IP/languages:/usr/share/php");
Road Map[edit | edit source]
Add api module for listing of derivatives( done in TimedMediaHandler )
- Add support for transcoding from arbitrary format uploads.
Improve transcoding tracking with database tables for registering failed transcodes, time taken per transcode, allow users to flag files as not playable or a visually broken transcodes.
- Improve mobile support for uploading and playback ( via native aps if the browser html5 support does not include WebM )
- Add support for WebM flattening of edited sequences
- Add support for mp3 uploads and audio transcoding to mp3 and ogg. ( Off by default until mp3 patents expire in 2012 )
- Add support for IE9 video tag WebM components
Add support for 1080p videos Add support for 4k videos
- Add support for 8k videos
- Upgrade to 2.x branch. (On hold. Planning on switching to video.js.)
- Change Kaultra player to Video.js as our main video player.
Notes[edit | edit source]
These notes about the status of TimedMediaHandler were shared by Jan Gerber at the end of his consulting agreement for WMF on 27 September, 2013:
Since you asked in the last meeting to write up an overview of the current state of TimedMediaHandler, here we go:
- setup like jobrunners, but only processing video transcode jobs (configuration of jobs/memory/threads in puppet and wikimedia-config)
- extract frames from videos, using avconv for all videos reading videos via http from swift backend
- proxy caches:
- must support HTTP 206 Range Requests for video urls (currently requires custom code that is managed in puppet)
- custom packages for video transcoding (apt.wikimedia.org):
- ffmpeg2theora (new upstream version to reduce memory by only using one thread)
- libav (ubuntu version with patch to fix memory leak in ogg decoder)
- libvpx (new upstream version fixing various issues and quality improvements)
- custom packages for image scaling (apt.wikimedia.org):
- vips (new upstream version addressing various performance issues)
- Upstream coded included in TMH:
- mwEmbed (https://github.com/kaltura/mwEmbed) has local changes needs to be merged during next update
- PEAR File_Ogg (http://pear.php.net/package/File_Ogg) has local changes was part of OggHandler, Tim is upstream maintainer
- getID3 (http://getid3.org) has small local changes but merged upstream
- Statistics and monitoring:
- Transcoding queue and errors:
- Ganglia for video scalers:
August 2015 update[edit | edit source]
Brion and TheDJ are starting up some new maintenance on TImedMediaHandler:
- fixed some regressions in transcode handling
- increasing Ogg transcode quality (increased bandwidth)
- support subtitles in ogv.js
- finish killing broken Cortado Java compatibility shim
- retooling TMH's ResourceLoader modules for better compatibility
- fix more transcode issues
- fix ogv.js issues
- missing volume control
- get transcoding from VP9/Opus working on Wikimedia servers...
- transcoding to VP9/Opus WebM with decreased bandwidth
- add Ogg skeleton to ogg audio transcodes for better seeking
- integrate lightweight video player into Extension:MobileFrontend
- rework serving Timed Text
- replace Kaltura player with VideoJS
- integrate video player into Extension:MultimediaViewer
- integrate audio/video into Extension:VisualEditor
- DASH or DASH-like adaptive streaming
- get VP9 working fast enough on ogv.js to replace Ogg Theora transcodes
See also[edit | edit source]
|This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page.|