Phabricator のプロジェクト名 #timedmediahandler


Jump to: navigation, search
This page is a translated version of the page Extension:TimedMediaHandler and the translation is 35% complete.

Other languages:
català • ‎Deutsch • ‎English • ‎español • ‎suomi • ‎français • ‎Frysk • ‎italiano • ‎日本語 • ‎Nederlands • ‎polski • ‎português • ‎português do Brasil • ‎русский • ‎sicilianu • ‎中文
MediaWiki 拡張機能マニュアルManual:Extensions
Crystal Clear action run.png

リリースの状態:Extension status 安定

実装Template:Extension#type Media, API
説明Template:Extension#description Provides integrated support for server side transcoding, WebM, Ogg Theora, Vorbis, MP3, Speex and Timed Text
作者Template:Extension#username Michael Dale, Jan Gerber, Tim Starling, James Heinrich, Brion Vibber, Derk-Jan Hartman
最新バージョンTemplate:Extension#version 0.5.0 (2015-12-08)
互換性ポリシーCompatibility#mediawiki_extensions リリースブランチ
MediaWikiTemplate:Extension#mediawiki 1.23+
PHPTemplate:Extension#php 5.4+
データベースの変更Template:Extension#needs-updatephp はい
ライセンスTemplate:Extension#license GNU General Public License 2.0 or later
RejectParserCacheValueManual:Hooks/RejectParserCacheValue で翻訳を利用できる場合は、TimedMediaHandler 拡張機能の翻訳にご協力ください

使用状況とバージョン マトリクスを確認してください。


未解決のタスク · バグを報告

TimedMediaHandler拡張機能を使用すると、画像ファイルと同じ構文を使用して、ウィキページにオーディオおよびビデオファイルを表示できます。それにはHTML5プレーヤーと実験的なVideoJSプレーヤーが含まれています。字幕やキャプション(別名 Timed Text)や複数のWebMとOgg派生物間のリアルタイムストリームの切り替えなどの機能があります。TMHサーバサイドのサポートには、HTML5のオーディオとビデオ、複数のトランスコードプロファイルをアップロードするオプション、OggとWebMビデオのためのMedata解析、トランスコードジョブのスケジューリングのためのMediaWikiのjobQueueシステムが組み込まれています。


See Commons:Commons:TimedText page.

Syntax synopsis

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:30 Which 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.
The syntax words noicon and noplayer are deprecated and do not function. The keyword disablecontrols will likely be deprecated soon. It takes the following values: options, timedText, fullscreen

Client support

Wider audio player, showing progress bar

The player works on most modern browsers and supports IE9 and later (The modern browsers as described in MediaWiki's support matrix). Mobile support is spotty, especially on iOS.

As of August 2015, TimedMediaHandler includes a JavaScript compatibility shim for Ogg audio/video that works in Safari, Internet Explorer 10/11, and Microsoft Edge browsers.

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.


インストールの詳しい手順について README を参照。

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

  • ダウンロードして、ファイルを extensions/ フォルダー内の TimedMediaHandler という名前のディレクトリ内に配置します。
  • 以下のコードを LocalSettings.php の末尾に追加します:
    // TimedMediaHandler is dependent on mwEmbedSupport
    require_once "$IP/extensions/MwEmbedSupport/MwEmbedSupport.php";
    // TimedMediaHandler
    require_once "$IP/extensions/TimedMediaHandler/TimedMediaHandler.php";
  • 更新スクリプトを実行します。このスクリプトは、この拡張機能が必要とするデータベース テーブルを自動的に作成します。
  • YesY 完了 - ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

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

Sorted by bandwidth tier (grayed items are not currently enabled):

Bitrate Mbit/s WebM VP8 WebM VP9
Super Low 0.08 160p
Very Low 0.16 160p 240p
Low 0.25 240p 360p
Moderate 0.5 360p 480p
Medium 1.0 480p 720p
High 2.0 720p 1080p
Very high 4.0 1080p 1440p
Super high 8.0 2160p

Detailed options:

名前 160P 240P 360P 480P 720P 1080P 160P 240P 360P 480P 720P 1080P 1440P 2160P
コンテナー WebM
動画 Encoding VP8 VP9
フレーム幅 (ピクセル) 288 426 640 854 1280 1920 288 426 640 854 1280 1920 2560 4096
フレーム高 (ピクセル) 160 240 360 480 720 1080 160 240 360 480 720 1080 1440 2160
ビットレート (Mbit/s) 0.16 0.25 0.5 1.0 2.0 4.0 0.08 0.16 0.25 0.5 1.0 2.0 4.0 8.0
音声 Encoding Vorbis Opus
チャンネル 2 (stereo) (pass-through)
サンプリング レート (Hz) 44100 48000
品質 - 1 2 3 - (default)


Here are the configuration variables and their default settings:

// 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
// 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

	// Moderate-bitrate web streamable WebM video

	// A high quality WebM stream

	// A full-HD high quality WebM stream

	// 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

	// Medium-bitrate Ogg stream

	// Moderate-bitrate Ogg stream

	// High-bitrate Ogg stream

	// 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.

	// A mid range h.264 stream; mid range phones and low end tables

	// An high quality HD stream; higher end phones, tablets, smart tvs

	// A full-HD high quality stream; higher end phones, tablets, smart tvs

$wgEnabledAudioTranscodeSet = array(

	//opus support must be available in avconv

	//avconv needs libmp3lame support

	//avconv needs libvo_aacenc support

// If mp3 source assets can be ingested:
$wgTmhEnableMp3Uploads = false;

// 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:
$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 );

// The following are deprecated or  no longer valid options in newer versions.

// Path override for cortado ( by default its false and uses hard coded paths relative to TMH
// or the predefined path on upload server:
// Removed in 1.26 and later
$wgCortadoJarFile = false;

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

Because transcode jobs are resource intensive they will not run as part of normal job queue ( see bug 29336 ) Instead they must be requested by the --type argument:

php runJobs.php --type webVideoTranscode

Encoding nodes

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.

Ubuntu 12.04での最小限のインストール

add-apt-repository ppa:j/timedmediahandler
apt-get install php5-cli php-pear imagemagick ffmpeg ffmpeg2theora


ini_set( "include_path", ".:$IP:$IP/includes:$IP/languages:/usr/share/php");


  • YesY 完了Add api module for listing of derivatives ( done in TimedMediaHandler )
  • Add support for transcoding from arbitrary format uploads.
  • YesY 完了 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
  • YesY 完了 Add support for mp3 uploads (T115170)
    • YesY 完了 Audio transcoding to mp3 and ogg (T165717)
  • Add support for IE9 video tag WebM components
  • YesY 完了 Add support for 1080p videos
  • YesY 完了 4k 動画への対応を追加
  • Add support for 8k videos
  • 2.x 枝にアップグレード。 (保留中。 video.js. への移行を計画中)
  • メインの動画再生のレイヤーを Kaltura から Video.js に変更。


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:

  • videoscalers:
    • setup like jobrunners, but only processing video transcode jobs (configuration of jobs/memory/threads in puppet and wikimedia-config)
  • imagescalers:
    • 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 (
    • 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 (
    • vips (new upstream version addressing various performance issues)


Brion と TheDJ は TImedMediaHandler の次の項目について新しく保守を始めました:


  • fixed some regressions in transcode handling
  • added /ogv.js JavaScript compatibility shim for Safari 6.1+, IE 10/11, and Edge
  • 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 ogv.js issues
    • missing volume control

Todo 'small':

  • fix more transcode issues

Todo 'medium':

  • 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

Todo 'large':

Todo 'long-term':

  • get VP9 working fast enough on ogv.js to replace Ogg Theora transcodes