扩展:TimedMediaHandler
TimedMediaHandler 发行状态: 稳定版 |
|
---|---|
实现 | 媒体, API |
描述 | 提供对于服务器端转码的集成支持,WebM、OGG Theora、Vorbis、Speex语音以及赋时文本 |
作者 | Michael Dale, Jan Gerber, Tim Starling, James Heinrich, Brooke Vibber, Derk-Jan Hartman |
最新版本 | 0.6.0 |
兼容性政策 | 快照跟随MediaWiki发布。 master分支不向后兼容。 |
MediaWiki | >= 1.43 |
数据库更改 | 是 |
表 | transcode |
许可协议 | GNU通用公眾授權條款2.0或更新版本 |
下載 | |
|
|
|
|
|
|
季度下載量 | 189 (Ranked 32nd) |
正在使用的公开wiki数 | 1,290 (Ranked 218th) |
前往translatewiki.net翻譯TimedMediaHandler扩展 | |
問題 | 开启的任务 · 报告错误 |
TimedMediaHandler擴展允許您使用與image文件相同的語法在Wiki頁面中顯示音頻和視頻文件。 它包括VideoJS Player。 支持字幕和字幕(又稱定時文本)以及在多個WebM和其他派生工具以及許多其他功能之間的實時流切換。 TMH服務器端支持包括用於上傳HTML5音頻和視頻的選項,用於傳遞內容的多個轉碼配置文件,MIDI文件的回放,用於Ogg和WebM視頻的元數據解析,以及與MediaWiki的jobQueue系統集成以安排轉碼作業。
For new and upcoming developments in 2022 and beyond, see Extension:TimedMediaHandler/2022 work.
功能预览
For the player see: VideoJS Player.
查看Commons:Timed Text页面。
语法简介
在image embed syntax基础上,Timed Media Handler支持:
- [[File:Video.ogv]]
- 用原尺寸显示一个视频。显示一个在视频中点提取的静止图像,和一个用来激活播放器的播放按钮。
- [[File:Audio.oga]]
- 为声音文件显示一个占位符,包含一个用于激活播放器的播放按钮。 The player will appear inline or as a pop-up if the audio file has closed captioning/subtitles.
- [[File:Midi.mid]]
- 根據MIDI文件中的音樂指令生成數字音頻,並顯示嵌入式音頻播放器以播放此音頻。
- [[File:Video.ogv|thumb]]
- 在一个浮动的缩略图里显示视频。
<gallery>File:Video.ogv</gallery>
- 在一个图片库(image gallery)里嵌入视频(每一个截图都会弹出一个用于完整视频的对话框)。
- [[File:Video.ogg|thumbtime=1:25]]
- 用1分25秒的一帧画面插入视频作为占位图形。一个单独的数字将默认被理解成秒数。 也可以使用HH:MM:SS,例如1:02:22将是视频的1小时2分22秒。 Floating-point seconds are supported (but broken on Wikimedia wikis: phab:T228467).
- [[File:Video.ogg|start=1:25]]
- 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. 也可以使用HH:MM:SS,例如1:02:22将是视频的1小时2分22秒。 start=
andend=
can also be used as query parameters in the URL for a video's file page.- [[File:Video.ogg|muted]]
- Start the media with muted audio. (在版本1.39引入)
- [[File:Video.ogg|loop]]
- Loop the video continuously. (在版本1.39引入)
- 弃用
- 語法字noicon和noplayer已棄用,不起作用。 關鍵字disablecontrols可能會被棄用。 (请参见任务 T135537) 它採用以下任何值的逗號分隔列表: options, timedText, fullscreen
客户端支持
[[File:Videoonwikipedia.ogv|300px|thumb|...]]
[[File:example.ogg|thumb|...]]
[[File:example.ogg|30px]]
[[File:example.ogg]]
这个播放器在大部分现代浏览器上能够工作,支持IE9及更高版本(在MediaWiki's support matrix里有关于现代浏览器的描述)。 移动端支持情况不一,尤其是在iOS上。
TimedMediaHandler包括用於Ogg音頻/視頻的JavaScript兼容性代碼,可在Safari,Internet Explorer 10/11和Microsoft Edge瀏覽器中使用。
MediaWiki的第三方用戶可能還希望為Safari / IE / Edge中的本地視頻和音頻播放手動啟用MP4 H.264 / AAC支持,但是使用這些格式時,您可能需要MPEG-LA的專利許可才能進行互聯網廣播。
安裝
You will want a recent version of ffmpeg in order to support encoding to WebM (with the latest version of VP9).
- 下载文件,并将解压后的
TimedMediaHandler
文件夹移动到extensions/
目录中。
开发者和代码贡献人员应从Git安装扩展,输入:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TimedMediaHandler - 只有從git安裝才运行Composer来安装PHP依赖,通过发行
composer install --no-dev
至扩展目录。 (参见工單T173141了解潜在问题。) - 将下列代码放置在您的LocalSettings.php 的底部:
wfLoadExtension( 'TimedMediaHandler' ); $wgFFmpegLocation = '/usr/bin/ffmpeg'; // Most common ffmpeg path on Linux
- 运行更新脚本,它将自动创建此扩展必须依赖的数据库表。
- Configure as required.
- You may need to increase the allowed memory in $wgMaxShellMemory .
- 完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。
The extension will automatically add supported file types (except for mp4) to $wgFileExtensions , so you do not need to add video file types manually.
所以,在从Git安装之后,切换到包含该扩展的目录。例如:"../extensions/TimedMediaHandler/"并运行composer install --no-dev
,或在更新时:composer update --no-dev
。
或者最好将"extensions/TimedMediaHandler/composer.json"
添加到在Wiki根目录下的"composer.local.json"文件中,例如:
{
"extra": {
"merge-plugin": {
"include": [
"extensions/TimedMediaHandler/composer.json"
]
}
}
}
维基百科媒体编码选项的比较
As of 2018, Wikimedia sites use VP9.
Sorted by bandwidth tier:
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 |
详细选项:
名称 | 160P | 240P | 360P | 480P | 720P | 1080P | 160P | 240P | 360P | 480P | 720P | 1080P | 1440P | 2160P | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
容器 | WebM | ||||||||||||||
视频 | 编码 | 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 | |
音频 | 编码 | Vorbis | Opus | ||||||||||||
频道 | 2 (stereo) | (pass-through) | |||||||||||||
采样率 (Hz) | 44100 | 48000 | |||||||||||||
品质 | - | 1 | 2 | 3 | - | (default) |
配置
此頁面已过时。 |
这里展示了一些可能有用的配置变量:
// The minimum size for an embedded video player (smaller than this size uses a pop-up player).
$wgMinimumVideoPlayerSize = 200;
// 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;
// Exclude transcoding jobs from the default job runner because they take very long to complete
$wgJobTypesExcludedFromDefaultQueue[] = 'webVideoTranscode';
$wgJobTypesExcludedFromDefaultQueue[] = 'webVideoTranscodePrioritized';
// The total amount 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)
// https://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 = [ 'commonswiki' => 102 ];
$wgTimedTextForeignNamespaces = [];
/**
* 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 a 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 uploaded
* -Derivative should be listed min to max
*/
// Starting from 1.31
// All valid string values are listed in the extension's extension.json file
$wgEnabledTranscodeSet = [
'160p.webm' => true,
'240p.webm' => true,
'360p.webm' => true,
'480p.webm' => true,
'720p.webm' => true,
'1080p.webm' => true,
];
$wgEnabledAudioTranscodeSet = [
'ogg' => true, // ogg+vorbis
'opus' => false, // ogg+opus
'mp3' => true, // raw mp3
'm4a' => false, // mp4+aac (mp4a.40.5)
];
// If mp3 source assets can be ingested:
$wgTmhEnableMp3Uploads = true;
// If mp4 source assets can be ingested:
$wgTmhEnableMp4Uploads = false;
// If you use ffmpeg 2, it can be set to true
$wgUseFFmpeg2 = false;
如果需要转码,请确认你的$wgMaxShellMemory
,$wgMaxShellTime
,$wgMaxShellFileSize
足够大而保证转码工作进行并保存输出。默认值很可能太小了。
进行转码工作
由于转码工作是资源集中型工作,它们不会再常规工作队列中运行 (查看 任务 T29336)。相反,它们必须由$2参数请求:
Configure Localsettings.php
with:
$wgJobTypesExcludedFromDefaultQueue[] = 'webVideoTranscode';
$wgJobTypesExcludedFromDefaultQueue[] = 'webVideoTranscodePrioritized';
Setup dedicated jobrunners and request running the jobs by the --type
argument:
php ./maintenance/run.php runJobs --type webVideoTranscode
php ./maintenance/run.php runJobs --type webVideoTranscodePrioritized
It is very important to run these tasks as the webserver user.
A single transcode job for a video can easily take an hour or longer, so ensure the commands have enough time and CPU to run.
编码节点
为了能够转码许多视频,你可能想要运行多个连接到主数据库并且直接访问你的文件的编码节点。您将需要安装ffmpeg。
在Debian和Ubuntu下的最小安装
apt install ffmpeg
Plus, add this to your LocalSettings.php (tested for Devuan ASCII (Archived 2018-09-23 at the Wayback Machine) only):
$wgFFmpegLocation = '/usr/bin/ffmpeg';
Troubleshooting
Please note that versions of TimedMediaHandler before MediaWiki 1.38 did not work with PostgreSQL. 参见工單T157424。
ffmpeg
– failed to map segment from shared object- You need to increase the allowed memory in $wgMaxShellMemory .
- Class 'getID3' not found
- You need to install the extension's PHP dependencies using Composer; see the installation section.
- Unrecognized option 'max_muxing_queue_size'
- You may be using ffmpeg 2. You need add
$wgUseFFmpeg2 = true;
to yourLocalSettings.php
. - Unrecognized option 'max_muxing_queue_size'
- You may be using ffmpeg 2. You need add
$wgUseFFmpeg2 = true;
to yourLocalSettings.php
. - [exception] […] /index.php?title=Special:Upload Error: Call to undefined method FSFile::getLocalRefPath()
- This extension is incompatible with 扩展:嵌入式视频 . Uninstall it. You may also need to make sure you did the composer steps properly.
See also
此扩展用于一个或多个维基媒体项目。 这可能意味着扩展足够稳定、运作足够良好,可以用在这样的高流量的网站上。 请在维基媒体的CommonSettings.php和InitialiseSettings.php配置文件中查找此扩展的名称以查看哪些网站安装了该扩展。 特定wiki上的已安装的扩展的完整列表位于Special:Version页面。 |
此扩展在以下wiki农场/托管网站和/或软件包中提供: 這不是一份權威名單。 即使某些wiki农场/托管网站和/或软件包未在这里列出,它们也可能提供此扩展。 请检查你的wiki农场/托管网站或软件包以确认提供情况。 |
- Stable extensions/zh
- Media handling extensions/zh
- API extensions/zh
- GPL licensed extensions/zh
- Extensions in Wikimedia version control/zh
- ArticleContentOnDiff extensions/zh
- ArticleFromTitle extensions/zh
- ArticlePurge extensions/zh
- BeforePageDisplay extensions/zh
- CanonicalNamespaces extensions/zh
- FileDeleteComplete extensions/zh
- FileUndeleteComplete extensions/zh
- FileUpload extensions/zh
- ImageOpenShowImageInlineBefore extensions/zh
- ImagePageAfterImageLinks extensions/zh
- ImagePageFileHistoryLine extensions/zh
- LoadExtensionSchemaUpdates extensions/zh
- MediaWikiPerformAction extensions/zh
- PageDeleteComplete extensions/zh
- PageMoveComplete extensions/zh
- PageSaveComplete extensions/zh
- ParserTestGlobals extensions/zh
- RevisionFromEditComplete extensions/zh
- SkinTemplateNavigation::Universal extensions/zh
- TitleMove extensions/zh
- WgQueryPages extensions/zh
- All extensions/zh
- Extensions requiring Composer with git/zh
- Outdated pages/zh
- Extensions used on Wikimedia/zh
- Extensions included in Canasta/zh
- Extensions included in Fandom/zh
- Extensions included in Miraheze/zh
- Extensions included in WikiForge/zh
- Video player extensions/zh
- Audio player extensions/zh