Extension talk:TimedMediaHandler

About this board

Asterton (talkcontribs)

Hi, i have some problem with an thumbnail creation.

I have two wikis - prod and test.

OS - Debian 11 bullseye

Wiki - 1.35

On the test, the extension works without problems, on prod, when loading some videos, an error thubnail creation. The problem is not observed with all video files. However, problematic videos load fine on the test wiki.

I can't figure out where to look for the problem.

Reinstalled the extension. LocalSettings compared. ffmpeg reinstalled. ImageMagick installed

Error creating thumbnail: '/usr/bin/ffmpeg' -nostdin -threads 1 -ss 102 -y -i '/usr/share/mediawiki/images/8/81/Vіdeo_іnstruction_configurator_of_gearboxes15.mp4' -ss 1 -s 1280x720 -f mjpeg -an -vframes 1 '/tmp/transform_75cc2215ccd5.jpg' 2>&1 wgMaxShellMemory: 307200 ffmpeg version 4.3.4-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 10 (Debian 10.2.1-6) configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat 58. 45.100 / 58. 45.100 libavdevice 58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc 55. 7.100 / 55. 7.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/usr/share/mediawiki/images/8/81/Vіdeo_іnstruction_configurator_of_gearboxes15.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.12.100 Duration: 00:03:27.01, start: 0.000000, bitrate: 1367 kb/s Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1169 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 193 kb/s (default) Metadata: handler_name : SoundHandler Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native)) [swscaler @ 0x5643c4470f40] deprecated pixel format used, make sure you did set range correctly Output #0, mjpeg, to '/tmp/transform_75cc2215ccd5.jpg': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.45.100 Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default) Metadata: handler_name : VideoHandler encoder : Lavc58.91.100 mjpeg Side data: cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A [h264 @ 0x5643c4115ec0] get_buffer() failed [h264 @ 0x5643c4115ec0] thread_get_buffer() failed [h264 @ 0x5643c4115ec0] decode_slice_header error [h264 @ 0x5643c4115ec0] no frame!

And this message repeating many times:

Error while decoding stream #0:0: Invalid data found when processing input [h264 @ 0x5643c4115ec0] get_buffer() failed [h264 @ 0x5643c4115ec0] thread_get_buffer() failed [h264 @ 0x5643c4115ec0] decode_slice_header error [h264 @ 0x5643c4115ec0] no frame!

And then

Cannot allocate memory frame= 0 fps=0.0 q=0.0 Lsize= 0kB time=00:00:00.00 bitrate=N/A speed= 0x video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used) Conversion failed!

If i run in console:

'/usr/bin/ffmpeg' -nostdin -threads 1 -ss 102 -y -i '/usr/share/mediawiki/images/8/81/Vіdeo_іnstruction_configurator_of_gearboxes15.mp4' -ss 1 -s 1280x720 -f mjpeg -an -vframes 1 '/tmp/transform_75cc2215ccd5.jpg' 2>&1

jpeg alrady created.

What else needs to be checked? I have no idea...

Tacsipacsi (talkcontribs)

The error message states that it exceeded the $wgMaxShellMemory limit—this is a MediaWiki configuration, so it of course doesn’t apply if you run ffmpeg directly from the command line, and it may be configured differently for the two wikis (although it’d be weird to do so). In any case, you’ll need to increase the limit.

Asterton (talkcontribs)

Thanks a lot!

I tried to set this parameter, but left the value 307200 and, of course, did not get a result.

Reply to "Thumbnail creation error"

Question about a placeholder

Pacha Tchernof (talkcontribs)
Bawolff (talkcontribs)
Pacha Tchernof (talkcontribs)

I'm not sure that I completely understood what you wrote, but thanks a lot for a try!

Just in case: in Russian language, words could have different forms - cases. And I would like to know if I add a GRAMMAR with prepositional case before mysterious "$1", would the language name change depending on the provided case?

For example, in Russian, the word "English" have seven forms (even if two forms are equal, they are used in the different places): английский, английского, английскому, английский, английским, английском.

You see? Most of them have different endings and to make smooth and good translation (instead of weird construction I build there) I just need to know, may I use GRAMMAR: to use cases, proper word order and syntax to contribute better translations. Dixi.

Bawolff (talkcontribs)

So the thing is, GRAMMAR is implemented differently in different languages. Some languages have a complete implementation, where it works with any word. In Other languages it doesn't work very well and only works for select words. I am not sure what the case is for russian (which is why i suggested asking at translatewiki support as they are more familiar). You could test GRAMMAR at ru:Special:expandTemplates .

If i had to guess though, i would guess the answer is yes, but i'm not 100% sure.

Reply to "Question about a placeholder"
Carloposo (talkcontribs)


I am trying to disable all the transcoding jobs as I don't need to provide different versions of the video.

I have included $wgEnableTranscode = false; in my Localsettings.php. Unfotunately it keeps on converting every time I upload an mp4.

I have also added $wgEnabledTranscodeSet = [] but didn't change much.

Thank you.

Misdre (talkcontribs)

Just edit extension.json in the extension files. This is not ideal, a bit hackish and thus not recommended but TimedMediaHandler never handled variables from LocalSettings properly - at least not this one anyway.

You may want to try setting $wgEnabledTranscodeSet = []; which might work for you - it didn't for me.

Reply to "Disable transcoding"

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)

Sm8ps (talkcontribs)

I would like to chime in on issue nr. 4. I use SimpleScreenRecorder to produce a VP8-720p video file. When uploaded, it is unnecessarily transcoded to another VP8-720p video file.

For instance, I have Video.webm of 51.3 MB with VP8-720p-15fps-398kbps and Vorbis-48kHz-112kbps. The transcoding produces Video.720p.webm with almost exactly the same specs, the only difference lying in the bitrate (581kbps) and thus an increased file size of 74.9 MB. This does not make sense as the video quality of the transcoded copy cannot get any better with an increased bitrate.

I think the extension should only mark the WEBM-video file for transcoding if any of the basic settings (frame size, fps, video/audio bit rate) of the original are (strictly) greater than the standard settings. Does that make sens? I am no expert at all with video encoding.

TheDJ (talkcontribs)

So the problem is that there can be a LOT of settings and knowing which combination works in all browsers is actually pretty hard. This is why it will always transcode, to ensure that it has a known usable version to present to browsers. (FYI: Youtube does this as well, you never see your original again after uploading it there).

Sm8ps (talkcontribs)

Thanks for your response, @TheDJ (and sorry for my late reaction)! Your explanations do make perfect sense to me.

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

TimeMediaHandler and EmbedVideo comparison

Summary by Omotecho

mp4 included as type of video to upload via any method for uploading files (Special:Upload, UploadWizard etc) : details are referred at Extension:TimedMediaHandler#Client support.

Carloposo (talkcontribs)


I am using EmbedVideo at the moment. It fits my needs 80%. I think it's an amazing extension. I am not interested in embedding videos from external sources but to upload and stream my own on a local server.

I have few questions for those of you using TMH:

- is it possible to use mp4?

- is the process of uploading and embedding the video in a page flawless?

- can I upload a video as I would upload a picture, using the VisualEditor?

- does TMH perform an encoding for every uploaded video?

- is TMH stable/future proof? (sorry for this question, I know it might sound a bit silly but I am working on a corporate wiki and need to comply to a long-term strategy)

Thank you.

Tacsipacsi (talkcontribs)

- is it possible to use mp4?

According to § Client support, yes. Support for formats not used on Wikimedia wikis can be a bit more spotty (e.g. thumbnails may not be supported), though.

- is the process of uploading and embedding the video in a page flawless?

- can I upload a video as I would upload a picture, using the VisualEditor?

TimedMediaHandler plays videos and sound files uploaded in the File namespace, so any method for uploading files (Special:Upload, UploadWizard…) should work. I don’t have experience with VisualEditor, but I don’t see any reason for it not to work.

- does TMH perform an encoding for every uploaded video?

Yes, as far as I know, for every video. See c:File:Videoonwikipedia.ogv#transcodestatus for an example.

- is TMH stable/future proof?

It’s used on public Wikimedia wikis, so probably yes. Unless something catastrophic happens, it should be supported “forever” (or if goes unsupported, there will be a proper replacement).

Carloposo (talkcontribs)

Thank you @Tacsipacsi I am testing it as we speak.

Carloposo (talkcontribs)


I am using $wgMinimumVideoPlayerSize to no success. I am using the VisualEditor to place an mp4 inside my page, and I am setting its width to be bigger than the value I put for the variable. I expect no modal window wo appear on click. Unfortunately, that does not happen.

Thank you.

Reply to "In-page video player"

Forcing use of Kaltura HTML5 Player instead of VideoJS

KevTYD (talkcontribs)

I'm struggling to get Kaltura HTML5 player working on a wiki, since it is consistently attempting to force VideoJS. This is undesirable for me, since my primary use of TimedMediaHandler is to handle OGG files, which work much better with Kaltura (it's not fullscreen!). Is it possible to force Kaltura HTML5, or otherwise just allow VideoJS to work without going fullscreen on audio files? ~~~~

Jdforrester (WMF) (talkcontribs)

Yes, add the line $wgTmhWebPlayer = "mwembed"; to your LocalSettings.php file. Note, however, that we're expecting to delete the legacy Kaltura player entirely quite soon.

Uvas magicas (talkcontribs)

exist the probably of use fullscreen in the files of video with the player kaltura html?

Lwangaman (talkcontribs)

There is currently an incompatibility between the Score extension and the VideoJS player (see phabricator:T245377), whereas the Kaltura player seems to play nicely with the Score extension. Please don't remove the Kaltura player until this compatibility issue is ironed out :)

Reply to "Forcing use of Kaltura HTML5 Player instead of VideoJS"

Is there some equivalent of $wgMinimumVideoPlayerSize?

Spas.Z.Spasov (talkcontribs)

Hello, I wonder is it possible to play video files inline without using the popup feature?

Reply to "Is there some equivalent of $wgMinimumVideoPlayerSize?"

Use a different content model?

Elli (talkcontribs)

I've noticed that pages in the TimedText namespace actually use the Wikitext content model. This is far from ideal and causes confusion and some problems with editing.

The extension should probably extend the "plain text" model instead. This would probably be a decently-hard change to make... but I think it should be considered.

Ciencia Al Poder (talkcontribs)

The intention is to get rid of the namespace altogether. See phab:T135221. I don't know when this goal will be achieved, though. May be worth a bugreport, since this can be done by config on WMF wikis.

Elli (talkcontribs)

Oh, interesting.

That is probably a good idea, because of how painful this namespace is to work with.

Reply to "Use a different content model?"
Xuanthucit (talkcontribs)

Dear all,

My wiki when install TimedMediaHandler but webm file not working, please help me. Link: https://wikigiaitri.com/wiki/T%E1%BA%ADp_tin:H%C6%B0%E1%BB%9Bng_d%E1%BA%ABn_t%E1%BA%A1o_v%C3%A0_s%E1%BB%ADa_b%C3%A0i_tr%C3%AAn_Wiki_Gi%E1%BA%A3i_Tr%C3%AD.webm

My LocalSetting.php: wfLoadExtension( 'TimedMediaHandler' ); $wgFFmpegLocation = '/usr/bin/ffmpeg'; $wgMaxShellMemory = 907200; $wgEnableTranscode = false; $wgMinimumVideoPlayerSize = 10; $wgEnabledTranscodeSet = []; $wgTmhWebPlayer = "mwembed";

Reply to "Webm file not working"