Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

Extension:TimedMediaHandler

From mediawiki.org
Translate this page
Languages:
Support level: Pending
The support level for this extension is currently under review. TheReader Growth Team is the maintainer of last resort for the time being.


MediaWiki extensions manual
TimedMediaHandler
Release status: stable
ImplementationMedia,API
DescriptionProvides integrated support for server-side transcoding, WebM, Ogg Theora, Vorbis, MP3, Speex, and Timed Text
Author(s)Michael Dale, Jan Gerber, Tim Starling, James Heinrich, Brooke Vibber, Derk-Jan Hartman
Latest version0.6.0
Compatibility policySnapshots releases along with MediaWiki. Master is not backward compatible.
Database changesYes
  • $wgMediaAudioTypes
  • $wgMediaVideoTypes
  • $wgTimedTextNS
  • $wgTmhEnableMp4Uploads
  • $wgEnabledTranscodeSet
  • $wgEnableTranscode
  • $wgTranscodeSoftSizeLimit
  • $wgTmhPriorityResolutionThreshold
  • $wgFFmpegVP9RowMT
  • $wgEnableIframeEmbed
  • $wgParserTestMediaHandlers
  • $wgTranscodeBackgroundSizeLimit
  • $wgTimedTextForeignNamespaces
  • $wgEnabledAudioTranscodeSet
  • $wgTmhSoundfontLocation
  • $wgMinimumVideoPlayerSize
  • $wgFFmpegThreads
  • $wgTmhFluidsynthLocation
  • $wgTranscodeBackgroundMemoryLimit
  • $wgTmhFileExtensions
  • $wgFFmpegLocation
  • $wgTmhPriorityLengthThreshold
  • $wgTranscodeBackgroundTimeLimit
  • $wgWaitTimeForTranscodeReset
  • transcode-reset
  • transcode-status
LicenseGNU General Public License 2.0 or later
Download
Translate the TimedMediaHandler extension if it is available at translatewiki.net
IssuesOpen tasks ·Report a bug

TheTimedMediaHandler extension allows you to display audio and video files in wiki pages, using the same syntax as forimage files.It includes theVideoJS Player.It has support for subtitles and captions (aka Timed Text), real-time stream switching between multiple WebM and other derivatives, and many other features.TMH server-side support includes options for uploading HTML5 audio and video, multiple transcode profiles to deliver content, playback of MIDI files, metadata parsing for Ogg and WebM videos, and integration with MediaWiki'sjob queue system for scheduling transcoding jobs.

Feature overview

[edit]

For the player see:VideoJS Player.

For features of the subtitling system, seeCommons:Timed Text page.

Syntax synopsis

[edit]

In addition to theimage embed syntax, Timed Media Handler supports:

[[File:Video.ogv]]
Display a video at its nominal size. Displays a still image from the midpoint with a play button to start a pop-up video player.
[[File:Audio.oga]]
Show a placeholder for a sound file with a play button. The player will appear inline or as a pop-up if the audio file has closed captioning/subtitles.
[[File:Midi.mid]]
Generate digital audio from the music instructions in the MIDI file and show the embedded audio player to play this audio.
[[File:Video.ogv|thumb]]
Show a video in a floating thumbnail box<gallery>File:Video.ogv</gallery>
Show a video embedded in an image gallery (each clip will popup a dialog for the full player)
[[File:Video.ogg|thumbtime=1:25]]
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. One can also use HH:MM:SS, e.g., 1:02:22 will be 1 hour, 2 minutes, and 22 seconds into the video. 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 formend=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. One can also use HH:MM:SS, e.g. 1:02:22 will be 1 hour, 2 minutes, and 22 seconds into the video.
start= andend= can also be used asquery parameters in the URL for a video's file page.
[[File:Video.ogg|muted]]
Start the media with muted audio.(introduced in 1.39)
[[File:Video.ogg|loop]]
Loop the video continuously.(introduced in 1.39)
Deprecated
The syntax wordsnoicon andnoplayer are deprecated and do not function. The keyword disablecontrols will likely be deprecated. (SeeT135537) It takes a comma-separated list of any of the following values:options,timedText,fullscreen

Client support

[edit]
Example video player
Example audio player

[[File:Big Buck Bunny 4K.webm|300px|thumb|...]][[File:example.ogg|thumb|...]][[File:example.ogg|30px]][[File:example.ogg]]

The player works on most modern browsers (seeMediaWiki's support matrix).Mobile support is spotty, especially on iOS.

TimedMediaHandler includes aJavaScript 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.

Installation

[edit]

You will want a recent version offfmpeg in order to support encoding to WebM (with the latest version of VP9).

  • Download and move the extractedTimedMediaHandler folder to yourextensions/ directory.
    Developers and code contributors should install the extensionfrom Git instead, using:
    cdextensions/gitclonehttps://gerrit.wikimedia.org/r/mediawiki/extensions/TimedMediaHandler
  • Only when installing from Git, runComposer to install PHP dependencies, by issuingcomposer install --no-dev in the extension directory.(SeeT173141 for potential complications.)
  • Add the following code at the bottom of yourLocalSettings.php file:
    wfLoadExtension('TimedMediaHandler');$wgFFmpegLocation='/usr/bin/ffmpeg';// Most common ffmpeg path on Linux
  • Run theupdate script which will automatically create the necessary database tables that this extension needs.
  • Configure as required.
  • You may need to increase the allowed memory in$wgMaxShellMemory.
  • YesDone – Navigate toSpecial:Version on your wiki to verify that the extension is successfully installed.

The extension will automatically add supported file types (except for mp4) to$wgFileExtensions, so you do not need to add video file types manually.

After downloading this extension, please note that it requiresComposer.

So, after installation change to the directory containing the extension e.g., "../extensions/TimedMediaHandler/" and runcomposer install --no-dev, or when updating:composer update --no-dev.

Alternatively, as well as preferably, add the lineextensions/TimedMediaHandler/composer.json to thecomposer.local.json file in the root directory of your wiki e.g.

{"extra":{"merge-plugin":{"include":["extensions/TimedMediaHandler/composer.json"]}}}

Comparison of Wikipedia media encoding options

[edit]

As of 2018, Wikimedia sites use VP9.

Sorted by bandwidth tier:

BitrateMbit/sWebM VP8WebM VP9
Super Low0.08160p
Very Low0.16160p240p
Low0.25240p360p
Moderate0.5360p480p
Medium1.0480p720p
High2.0720p1080p
Very high4.01080p1440p
Super high8.02160p

Detailed options:

Name160P240P360P480P720P1080P160P240P360P480P720P1080P1440P2160P
ContainerWebM
VideoEncodingVP8VP9
Max width (pixels)288426640854128019202884266408541280192025604096
Max height (pixels)1602403604807201080160240360480720108014402160
Bitrate (Mbit/s)0.160.250.51.02.04.00.080.160.250.51.02.04.08.0
AudioEncodingVorbisOpus
Channels2 (stereo)(pass-through)
Sampling rate (Hz)4410048000
Quality-123-(default)

Configuration

[edit]
This page isoutdated.
It was written for an older version of MediaWiki and may not apply to the most recent version. If you have checked or updated this page and found the content to be suitable, please remove this notice. See thetalk page for a possible discussion on this.
This section is out of date -- please update me

Here are some configuration variables that may be useful:

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

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]

Because transcode jobs are resource intensive, they should not run as part of the normal job queue (seeTT29336).ConfigureLocalsettings.php with:

$wgJobTypesExcludedFromDefaultQueue[]='webVideoTranscode';$wgJobTypesExcludedFromDefaultQueue[]='webVideoTranscodePrioritized';

Setup dedicatedjobrunners and request running the jobs by the--type argument:

php./maintenance/run.phprunJobs--typewebVideoTranscodephp./maintenance/run.phprunJobs--typewebVideoTranscodePrioritized

It is very important to run these tasks as thewebserver 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.

Encoding nodes

[edit]

To transcode many videos, you might want to run multiple encoding nodes that connect to the master database and access your file store directly. You will need to install ffmpeg.

Minimal install under Debian and Ubuntu

[edit]
aptinstallffmpeg

Plus, add this to yourLocalSettings.php (tested forDevuan ASCII (Archived 2018-09-23 at theWayback Machine) only):

$wgFFmpegLocation='/usr/bin/ffmpeg';

Shellbox isolation

[edit]

For security reasons, ffmpeg runs in an isolated container usingShellbox at Wikimedia.You will need their docker image if you want to emulate the Wikimedia setup, including their Debian version, dependencies, etc.Use$wgShellboxUrls to configure MediaWiki to make use of your Shellbox nodes.

You can also create your custom docker image, of course.

$dockerpulldocker-registry.wikimedia.org/wikimedia/mediawiki-libs-shellbox:video

Troubleshooting

[edit]
This section needs expansion

Please note that versions of TimedMediaHandler before MediaWiki 1.38 did not work with PostgreSQL. SeeT157424.

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 theinstallation 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 isincompatible withExtension:EmbedVideo. Uninstall it. You may also need to make sure you did thecomposer steps properly.

See also

[edit]
This extension is being used on one or moreWikimedia 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'sCommonSettings.php andInitialiseSettings.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'sSpecial:Version page.
This extension is included in the following wiki farms/hosts and/or packages:
Retrieved from "https://www.mediawiki.org/w/index.php?title=Extension:TimedMediaHandler&oldid=8175099"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp