Topic on Extension talk:TimedMediaHandler

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

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

78.54.53.70 (talkcontribs)

Hi,

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

77.11.15.116 (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"