Extension talk:TimedMediaHandler

Jump to navigation Jump to search

About this board

Fatal error: Call to undefined method ForeignDBRepo::fetchImageQuery

Wp mirror (talkcontribs)

Dear Sir,

0) Background

I develop WP-MIRROR which is a utility for building a set of mirrors of WMF wikis. Home: <http://http://www.nongnu.org/wp-mirror/>. For WP-MIRROR 0.7, my objective is this: A wiki page rendered by the mirror site, should look the same as that page rendered by the WMF site. Version 0.6 fell short in this regard because: a) it depends upon the DEB package for MediaWiki 1.19 LTS which is not able to render many features that were introduced in 2013 (e.g. wikidata, scribunto, ...); and b) it depends upon several DEB packages for extensions compatible with 1.19 LTS which do not include many extensions currently used by WMF (e.g. math w/ mathjax, score, timeline, timedmediahandler, etc.)

In support of this objective, I am preparing a DEB package of MediaWiki 1.23alpha, and a DEB package of most of the extensions listed on <http://en.wikipedia.org/wiki/Special:Version>. So far I have packaged a couple dozen extensions with good results, but have hit a snag with TimedMediaHandler.

1) Mirror

1.1) WP-MIRROR builds a mirror of <http://simple.wikipedia.org/> out of the box using dump files from <http://ftpmirror.your.org>.

1.2) For MediaWiki, I am using the latest `git pull' from the GIT repository <https://gerrit.wikimedia.org/r/p/mediawiki/core.git>. For MediaWiki extensions, I am using the latest `git pull' from the GIT repositories under <https://gerrit.wikimedia.org/r/p/mediawiki/extensions/>. MwEmbedSupport and TimedMediaHandler are installed and configured as per the README.

1.3) As Debian dependencies, I have installed: cortado 0.6.0-1, ffmpeg 6:0.8.10-1, fmpeg2theora 0.27-2, imagemagick 8:, libav-tools 6:0.8.10-1, libvpx1 1.1.0-1, oggvideotools 0.8a-1, php5-cli 5.4.4-14+deb7u7, php-getid3 1.9.3-1, php-pear 5.4.4-14+deb7u7.

1.4) `LocalSettings.php' contains:

require_once( "$IP/extensions/MwEmbedSupport/MwEmbedSupport.php" );
require_once( "$IP/extensions/TimedMediaHandler/TimedMediaHandler.php" );
ini_set( 'include_path',
	 ".:$IP:$IP/includes:$IP/languages:/usr/share/php" . 
	 ini_get( 'include_path' ) ); 
$wgVideoPlayerSkin      = 'kskin'; 
$wgEnableTranscode      = true; 
$wgEnableNiceBackgroundTranscodeJobs = true; 
$wgFFmpeg2theoraLocation= '/usr/bin/ffmpeg2theora'; 
$wgFFmpegLocation       = '/usr/bin/avconv'; 
$wgOggThumbLocation     = '/usr/bin/oggThumb'; 

2) Testing

Special pages all work: <http://simple.wikipedia.site/wiki/Special:Version>, <http://simple.wikipedia.site/wiki/Special:TimedMediaHandler>, <http://simple.wikipedia.site/wiki/Special:FileList>.

Most ordinary pages display properly: <http://simple.wikipedia.site/wiki/Apple>.

3) Errors

Ordinary pages with OGV files render as blank. Two examples:

3.1) Use Firefox to view: <http://simple.wikipedia.site/wiki/Burnout> Error message in `/var/log/apache2/wp-mirror.site-error.log':
[Wed Feb 26 12:17:30 2014] [error] [client ::1] PHP Fatal error: Call to a member function doTransform() on a non-object in /usr/share/wp-mirror-mediawiki/extensions/TimedMediaHandler/TimedMediaThumbnail.php on line 201

3.2) Use Firefox to view: <http://simple.wikipedia.site/wiki/Sintel> Error message in `/var/log/apache2/wp-mirror.site-error.log':
[Wed Feb 26 11:04:41 2014] [error] [client ::1] PHP Fatal error: Call to undefined method ForeignDBRepo::fetchImageQuery() in /usr/share/wp-mirror-mediawiki/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscode.php on line 396

Under `/tmp/', can be found many files like `/tmp/transform-aaaabbbbcccc-1.jpg', where the string `aaaabbbbcccc' is composed of hexadecimal characters.

4) Request

Any advise would be appreciated. I am now reading the code but do not yet grasp where the problem is; hence this note.

If this is not the right location to write such a note, please let me know if there is an appropriate mailing list.

Sincerely Yours,

Hardware: x86x64, 6G DRAM
OS: Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1 x86_64 GNU/Linux
Distribution: Debian 7.4 (wheezy), with back-ports
MediaWiki: most recent version (1.23alpha) obtained from GIT repository
Extensions: most recent versions obtained from GIT repository

Bawolff (talkcontribs)

Its a bug in TimedMediaHandler. TimedMediaHandler isn't compatible with ForeignDBRepo based image stores. Try using ForeignDBViaLBRepo instead (They're basically the same, One just uses a $wgLBFactoryConf instead).

Issue filed as bugzilla:61986

Wp mirror (talkcontribs)
DonPaolo (talkcontribs)

@Bawolff Could you explain better your solution? DonPaolo (talk) 20:36, 10 July 2020 (UTC)

Bawolff (talkcontribs)
Reply to "Fatal error: Call to undefined method ForeignDBRepo::fetchImageQuery"

Support for other video formats (+ issue on transcoding failing on height/width detection)

Pio~frwiki (talkcontribs)

I had a legacy bunch of hundreds of videos medias in different videoformats on my wiki, and needed all to get supported with few efforts, as long as to allow my users to continue to upload new ones. I just customized a bit TimedMediaHandler code and the magic happened.

If other people get the same interest, here the record of what I did :

  1. I created the new handler "OtherVideoHandler.php" : it basically extends Mp4Handler and simply adjust a couple of methods relying on metadatas (frequently not well recognized). I declared this new handler into extension.json (and added messages "timedmedia-other-short-video" and "timedmedia-other-long-video" into i18n (english) file for displaying descriptions that do not mention 'mp4' :D ).
  2. In includes/TimedMediaHandlerHooks.php , I added several mime types support, and modified an if-clauses accordingly :
    < 		$wgMediaHandlers['video/flv'] = 'OthervideoHandler';//PMU
    < 		$wgMediaHandlers['video/x-flv'] = 'OthervideoHandler';//PMU
    < 		$wgMediaHandlers['application/x-shockwave-flash'] = 'OthervideoHandler';//PMU
    < 		$wgMediaHandlers['video/mpeg'] = 'OthervideoHandler';//PMU
    < 		$wgMediaHandlers['video/x-m4v'] = 'OthervideoHandler';//PMU
    < 		$wgMediaHandlers['video/m4v'] = 'OthervideoHandler';//PMU
    < 		$wgMediaHandlers['video/x-mp4'] = 'OthervideoHandler';//PMU alternate for m4v
    < 		$wgMediaHandlers['application/smil'] = 'OthervideoHandler';//PMU
    < 		$wgMediaHandlers['video/3gpp'] = 'OthervideoHandler';//PMU
    < 		$wgMediaHandlers['video/avi'] = 'OthervideoHandler';//PMU
    < 		$wgMediaHandlers['video/x-ms-wmv'] = 'OthervideoHandler';//PMU
    < 		$wgMediaHandlers['video/x-ms-asf'] = 'OthervideoHandler';//PMU alternate for wmv
    < 		$wgMediaHandlers['video/x-msvideo'] = 'OthervideoHandler';//PMU
    < 		$wgMediaHandlers['video/quicktime'] = 'OthervideoHandler';//PMU mov
    < 		$wgMediaHandlers['image/vnd.wap.wbmp'] = 'OthervideoHandler';//PMU alternate for mov
    < 		$wgMediaHandlers['application/x-font-gdos'] = 'OthervideoHandler';//PMU alternate for mov
    < 		if ( ( $mediaType == 'webm' || $mediaType == 'ogg' || $mediaType == 'mp4' || $mediaType == 'othervideo' /*PMU*/)
  3. Also, I noted that transcoding and thumbnailing failed on several videos, because the height/width couple was not well detected. I don't know if it only happens on my alternate videoformats or if it is a bug. Nevertheless I mention it here so if people encounter the same issue you can debug more easily : I added a "not null not zero" test in several places of TimedMediaThumbnail.php + WebVideoTranscode.php + WebVideoTranscodeJob.php . (Note : if a video still doesn't want to trigger transcodes at all, check out in mysql its record into the image table, you may have surprises on how it was described...)
  4. And last but not least, I triggered transcodes : I re-ran the scripts "requeueTranscode --missing", "requeueTranscode --error", "runJobs --type webVideoTranscodePrioritized ", purged the related wiki-pages-cache with the general maintenance purgePage.php script.

Alex Mashin (talkcontribs)

Why don't you file a bug with Phabricator ad upload a patch? Just make the extra formats disabled by default, to calm paranoia.
Alex Mashin (talk) 04:51, 6 June 2020 (UTC)

Reply to "Support for other video formats (+ issue on transcoding failing on height/width detection)"

$wgMinimumVideoPlayerSize doesn't work on MediaWiki 1.34

Spas.Z.Spasov (talkcontribs)

Hello, I just installed the extension on our (private) MediaWiki 1.34. We do not need transcode at the moment and want to use just the video player. The problem is that: there is not any popup window, no matter the value of $wgMinimumVideoPlayerSize.

When the video is smaller than the value of $wgMinimumVideoPlayerSize, when I click on the play button (located at the upper left corner), then appears an embedded player instead of popup window.

Does this option is available for MW 1.34? And, id yes, how to achieve it?

Here is the relevant part of the LocalSettings.php file:

wfLoadExtension( 'TimedMediaHandler' );
$wgFFmpegLocation = '/usr/bin/ffmpeg'; 
$wgMaxShellMemory = 907200;
$wgEnableTranscode = false;
$wgMinimumVideoPlayerSize = 10;
$wgEnabledTranscodeSet = [];
Reply to "$wgMinimumVideoPlayerSize doesn't work on MediaWiki 1.34"

only one <source> in <video>, no derivative

Pio~frwiki (talkcontribs)

Hi, I installed and configured Ti!edMediaHandler latest version on Mediawiki 1.34. Uploading a video works fine and does transcode several derivatives.

However when inserting File:xxx.mp4 in a page, I only have the original video inserted in HTML, there is only one < source > tag inside the < video > tag. Thus I can't get any benefit of the derivatives.

In my config, I do have wgEnableTranscode=true and I do have wgEnabledTranscodeSet with the derivatives configured (hence transcoding works :) ) .

What could I possibly miss ? Or what could the plugin miss ?

TheDJ (talkcontribs)

This often happens when there is no active jobrunner to quickly take care of purging the pages that the video is included on, after the transcodes finished.

Reply to "only one <source> in <video>, no derivative"

Empty thumbnails being generated

Þjarkur (talkcontribs)

The extension correctly creates 640px thumbnails for videos, but all smaller thumbnails are empty zero byte files. What could possibly be the reason for this?

Reply to "Empty thumbnails being generated"

OGG file won't play in mobile devices, but works fine for desktop

Boxiao (talkcontribs)

I am creating a wiki for people to learn how to pronounce some difficult names in my language. I have recorded audio in OGG files and uploaded to the wiki, and they play fine in desktop browsers like Chrome and Microsoft Edge. Here is an example: https://chinesenamesinenglish.com/wiki/A

However, in mobile devices (both Safari and Chrome in iphone X), if I use MobileFrontend (I tried different skins), the audio is not played after I click the play button but the player is displayed. If I use desktop view in mobile devices, the player is not even displayed. In contrast, Wikipedia's audio plays fine in mobile devices. For example, https://en.wikipedia.org/wiki/The_Star-Spangled_Banner

Can anyone help? Thank you! I am using MediaWiki v1.33.1 and the extensions and skins are latest compatible versions.

Boxiao (talkcontribs)

For now, I bypassed this issue by replacing OGG files with mp3 files. However, I still hope to know how to solve this problem. Your help will be greatly appreciated!

Reply to "OGG file won't play in mobile devices, but works fine for desktop"

Class 'getID3' not found trying to upload a video file

Krusher (talkcontribs)

Hello, when trying to upload a video file (either webm or mp4) I get the following error:

[10f9430f9e6bc3a83ac9f5ad] /wiki/Especial:SubirArchivo Error from line 15 of /home/krusher/www.apocrypha.ovh/extensions/TimedMediaHandler/includes/handlers/ID3Handler/ID3Handler.php: Class 'getID3' not found


#0 /home/krusher/www.apocrypha.ovh/extensions/TimedMediaHandler/includes/handlers/Mp4Handler/Mp4Handler.php(12): ID3Handler->getID3(string)

#1 /home/krusher/www.apocrypha.ovh/extensions/TimedMediaHandler/includes/handlers/ID3Handler/ID3Handler.php(51): Mp4Handler->getID3(string)

#2 /home/krusher/www.apocrypha.ovh/includes/utils/MWFileProps.php(84): ID3Handler->getMetadata(FSFile, string)

#3 /home/krusher/www.apocrypha.ovh/includes/upload/UploadBase.php(506): MWFileProps->getPropsFromPath(string, string)

#4 /home/krusher/www.apocrypha.ovh/includes/upload/UploadBase.php(441): UploadBase->verifyPartialFile()

#5 /home/krusher/www.apocrypha.ovh/includes/upload/UploadBase.php(344): UploadBase->verifyFile()

#6 /home/krusher/www.apocrypha.ovh/includes/upload/UploadFromFile.php(95): UploadBase->verifyUpload()

#7 /home/krusher/www.apocrypha.ovh/includes/specials/SpecialUpload.php(506): UploadFromFile->verifyUpload()

#8 /home/krusher/www.apocrypha.ovh/includes/specials/SpecialUpload.php(204): SpecialUpload->processUpload()

#9 /home/krusher/www.apocrypha.ovh/includes/specialpage/SpecialPage.php(569): SpecialUpload->execute(NULL)

#10 /home/krusher/www.apocrypha.ovh/includes/specialpage/SpecialPageFactory.php(578): SpecialPage->run(NULL)

#11 /home/krusher/www.apocrypha.ovh/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)

#12 /home/krusher/www.apocrypha.ovh/includes/MediaWiki.php(865): MediaWiki->performRequest()

#13 /home/krusher/www.apocrypha.ovh/includes/MediaWiki.php(515): MediaWiki->main()

#14 /home/krusher/www.apocrypha.ovh/index.php(42): MediaWiki->run()

#15 {main}

Am I doing something wrong or do I lack something?


TheDJ (talkcontribs)

Did you install from git ? Because it looks like the composer dependencies of the extension were not installed.

Krusher (talkcontribs)

Correct, after executing composer update it works. Thanks! Maybe it should be noted in the installation process.

Bowdzone (talkcontribs)

I just installed the extension via downloading and extracting the tar and not using git but I received the same error message, had to install composer and run composer update --no-dev to get rid of this. Not sure whether that is intended but at the moment this step should be noted as a general requirement for the installation process

Madewild (talkcontribs)

Is this the intended behaviour and is there a workaround? I have a MW instance on a shared server with no root access so I cannot install composer.

Ciencia Al Poder (talkcontribs)

You can install composer on your local computer, use it on a copy of the extension, and then upload the whole folder to the server

TheDJ (talkcontribs)

i've update the documentation some more. Turns out the tarball versions of the extension also don't include the vendor directory (only the main tarball for core + common extensions does).

Bttfvgo (talkcontribs)

Krusher, this is a somewhat simple error that I ran into also. Just do

$ composer require james-heinrich/getid3

from your Mediawiki root directory. Glad you got it working!

Huwmanbeing (talkcontribs)

In a similar vein: with TimedMediaHandler REL1_33 installed (via the ExtensionDistributor download) I recently ran into an issue where the missing getID3 interfered with the operation of refreshImageMetadata, which in turn prevented PdfHandler from working properly. To follow up on TheDJ's point above, could someone describe what files specifically are missing from the download that are needed for the extension to operate correctly?

Ciencia Al Poder (talkcontribs)

You need to run composer install --no-dev in the extension directory

TheDJ (talkcontribs)

Yeah, it's this huge note in the page:

After downloading this extension, please note that it requires Composer.

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

Alternatively as well as preferably add the line "extensions/TimedMediaHandler/composer.json" to the "composer.local.json" file in the root directory of your wiki like e.g.

	"extra": {
		"merge-plugin": {
			"include": [
Goodman Andrew (talkcontribs)

If you are on shared hosting, follow the following steps:

1. Download James-heinrich/getid3 from [php-download.com/package/james-heinrich/getid3]

2. Go to your file manager and on the extension/TimedMediaHandler folder, upload James-...

3. Extract James

4. Go back to your wiki and run the upload again.

Goodman Andrew (talk) 14:33, 28 December 2019 (UTC)
Reply to "Class 'getID3' not found trying to upload a video file"

Transcode key [resolution].ogv not found, skipping

Scarred Sun (talkcontribs)

I'm running into an issue where upon running webVideoTranscode jobs, I wind up getting skipping and errors over any OGV files (and potentially OGG/MP3 files, though it's hard to tell with video backlogs). For what it's worth, I have all the requisite codecs (libtheora, lame, etc.) on the server. Any idea why this may be happening?

Brion VIBBER (talkcontribs)

I believe this message will come up when there's a job to run a transcode, but there's no entry in the data loaded from the transcode table that matches that id. One possibility is that the configured transcode settings are messed up... we did an incompatible config change last year or so which might be tripping up some configs that recently updated. If you're manually altering or setting $wgEnabledTranscodeSet make sure you're using the current format -- instead of a list of constants, it's an associative array of the actual string keys to a boolean which indicates whether they're on or off. If the config is damaged, it might be causing some trouble there.

If that doesn't seem to be the problem, we may need to check logs or double-check that the database table is ok. (And confirm what version you're running etc before we try debugging!)

Reply to "Transcode key [resolution].ogv not found, skipping"

HOWTO LOOP video. +Opus 44.1k failure & Same-size re-encodes

2001:2002:51ED:CEE0:DC5D:AE01:E6DE:3306 (talkcontribs)

1) Most importantly I would like TimedMediaHandler to have a "loop" video option for making short video clips (say it's just 15-20 seconds) loop automatically when they are played.

2) It would be nice to be able to set a video size of 100% instead of pixels and have it resize to whatever size the screen/browser is using. Should of course also work if the browser is resized after playbacks begun.

3) Unrelated, uploading a MP3 with 44.1k audio makes TimedMediaHandler specify 44.1k when converting to Opus which fails since it's a 48k format. That's a bug.

4) I also find it very annoying that if I upload a 1080p VP9/Opus webm TimedMediaHandler will convert the file to that same format in addition the other formats. A check to see if the file's already in the target format would be preferable and reduce server load. (talkcontribs)


for 1) as a dirty hack, to get a button below the player to replay the video sequence, one may edit the extension as shown below. This solution is just a first approach an need to be further improved regarding stability, readability etc. but its a starting point.

This adds an individual javascript function under each videoplayer tag in the document, using the specific id of the video tag. the javascript function is started by clicking the button and will restart and play the video sequence.

edit the file [PathToYourMediawiki]/extensions/TimedMediaHandler/includes/TimesMediaTransformOutput.php

search for function 'getHtmlMediaTagOutput(...'

specifically search for the following code lines:

// Build the video tag output:

$s = Html::rawElement( $this->getTagName(), $this->getMediaAttr( $sizeOverride, $autoPlay ),

        // The set of media sources:

        self::htmlTagSet( 'source', $mediaSources ) .

        // Timed text:

        self::htmlTagSet( 'track', $mediaTracks )


add the following lines below:

$s .= '<script type="text/javascript">';

$s .= 'function replayVideo'.self::$serial.'() {';

$s .= "var el = document.getElementById('";

$s .= "mwe_player_";

$s .= self::$serial-1;

$s .= "'); ";

$s .= "el.muted = 'true'; el.load(); el.play(); }</script>";

$s .= '<form><input type="button" onclick="replayVideo';

$s .= self::$serial.'()" value="(re)play"</form>';

Note: i'm sure this can be written in a nicer way, it's decades since i used php ;) (talkcontribs)

some additional notes:

1) correct filename is TimedMediaTransformOutput.php (not TimesMedia...)

2) dont use the <form> and </form> tag from the source above, it will result in errors with input button afterwards (like formlink etc.)

3) el.muted = 'true' has no effect for most browsers and is not wanted for most users (mute video)

Reply to "HOWTO LOOP video. +Opus 44.1k failure & Same-size re-encodes"

Not Working - uploaded files not found

3 (talkcontribs)

Once I activate TimedMediaHandler (and MwEmbedSupport), "[[File:XXXX]]" links simply change to red as if the file wouldn't exist (previously they were ok).

Files have been uploaded correctly.

Tested on a vanilla MW 1.27.3 (LTS) with TMH 1.27 and 1.28. (talkcontribs)

Same with MW 1.29.0

Ivan Mudrik (talkcontribs)

Same with MW 1.33

Reply to "Not Working - uploaded files not found"