Extension talk:FlvHandler

From mediawiki.org
Jump to navigation Jump to search

Any way to change this to .jpg rendering thumbs?[edit]

With quality settings too? Some of the png created seem to be extreme size for a thumbnail, depending on size of the video of course. Also just fyi this extension seems incompatible with lastest 1.19.0 beta2, no thumbs are created, and no errors are given. I hope to see updates, this is good work done here! 08:56, 9 April 2012 (UTC)

The player loads by won't play the video files[edit]

The player loads by won't play the video files. It says 200 Stream not found. NetStream.Play.StreamNotFound, clip:'[Clip]

Then it displays the directory of where the file is.-

Is this a PHP error or a Flash applet error? What is the name of the FLV file? If you look at the article for the video file itself, do you see the preview image? Do you have a URL for your wiki I can look at to see the error? -- Malvineous 10:58, 14 May 2009 (UTC)
Here's a link with the videos. http://www.wikiaudio.org/index.php?title=Sandbox
I don't know what kind of error this is, I am a novice when it comes to development. I just follow instructions.
Btw I have another FLV extension installed and it seems to be doing roughly the same thing...not finding the FLV file to play but I know for a fact it's uploaded and in the directory the player is looking in -
Well the problem is that the FlvHandler code is trying to load the movie from http://www.wikiaudio.orgimages/e/eb/TEST.flv (note the missing slash between the 'org' and 'images'.) My guess is that you've changed the image path or upload path somewhere in your config (LocalSettings.php?) but left off a trailing slash somewhere. I'm surprised you don't have the same problem uploading images to the wiki. If you can find where that change has been made, both extensions should start working. -- Malvineous 22:28, 14 May 2009 (UTC)
I went to the localsetting.php file and on $wgUploadPath = "images"; and $wgUploadDirectory = "images"; I add a slash / before images.
It still didn't work and wouldn't allow for regular image uploads when I did this.
The other video player (the black one) showed a / slash before the word images in it's error display , so I know it recognized the change I made to LocalSettings.php
Is there anywhere else on the LogicSetting.php file you can think of? -
That's a tricky one. What's your $wgScriptPath set to? That should start with a slash. Otherwise can you stick your LocalSettings.php somewhere as a text file so I can see it? (with any passwords removed of course) -- Malvineous 10:32, 15 May 2009 (UTC)
The $wgScriptPath is set to = "";
So in full it looks like this $wgScriptPath = "";
In short it looks like it isn't set to anything. What should it be set to ?
The LocalSetting.php: http://www.yousendit.com/transfer.php?action=batch_download&batch_id=MnFqTkFsSWhtMExIRGc9PQ
Well it's the path to your index.php, so try setting it to a single slash and let me know if that makes a difference. (By the way, you can sign your messages here with ~~~~ which automatically puts your name and the time in.) -- Malvineous 12:11, 15 May 2009 (UTC)
It kinda screwed up the site altogether, it made it look different and the sandbox and other pages wouldn't load. - 12:31, 15 May 2009 (UTC)
Actually just looking at your LocalSettings.php, you have all the extension require_once() lines right at the top, before all the options are set. Does it make a difference moving those lines right to the end of LocalSettings.php? Otherwise I'm afraid I'm out of ideas, I don't think MediaWiki is designed to install into the root directory of the webserver - you'll probably have to make a "wiki" folder and install into that (so your site is at http://www.wikiaudio.org/wiki/index.php instead.) You can still "hide" this to make articles appear at nice addresses like http://www.wikiaudio.org/Main_Page, but I think the wiki itself needs to be in a subdirectory. -- Malvineous 12:57, 15 May 2009 (UTC)
Thanks for the help - suffice to say moving the required once messages didn't do anything. I will see about reinstalling in a WIKI folder sub directory. Could you keep this thread alive ( don't delete) and as I try and figure this out I will update for future troubleshooting etc. 13:09, 15 May 2009 (UTC)
BTW - can you think of anyway to modify the extension to accommodate the fact that we didn't install in a Wiki folder?? - 13:12, 15 May 2009 (UTC)
No problem, sorry I couldn't come up with a solution. There shouldn't be a need to reinstall the wiki, just moving it into a subfolder and setting $wgScriptPath, $wgUploadPath, etc. should be enough. It might be possible to modify the extension though, in FlvHandler.php line 110 is where it generates the full URL to the .flv file. If you change this from $strURL = $wgServer . $file->getUrl(); to $strURL = $wgServer . '/' . $file->getUrl(); then it should add in the extra slash that's missing from somewhere. I've tried to follow the getUrl() function but I can't see exactly where it gets the path from. At any rate that change should make it work on your wiki, and break on everyone else's :-) -- Malvineous 00:52, 16 May 2009 (UTC)
We changed the directory to "Wiki" and still doesn't want to work. http://www.wikiaudio.org/wiki/index.php?title=Sandbox Could you tell me exactly what to change the $wgScriptPath, $wgUploadPath and other LocalSettings to ? - 08:24, 16 May 2009 (UTC)
$wgScriptPath = "/wiki"; and the defaults should then be fine (so comment out any changes to $wgUploadPath, $wgUploadDirectory, $wgMath*) and it should work. You might need to purge the cache of any existing pages as they might still show old URLs (broken images) but the easiest way to check this is to edit the page and do a preview - if the image etc. works in the preview then all is well. Don't forget to undo any changes to FlvHandler.php if you've applied my suggestion from above! -- Malvineous 08:35, 16 May 2009 (UTC)
I did both suggestions and still no dice. I tried changing the Flvhandler.php and it DID show an extra slash in the players window - but it still didn't play the file. The error simply displayed the slash.I also moved everything to a folder called Wiki and updated the localsetting.php file - didn't work. Anyway, thanks for your help. I appreciate it. - 08:49, 16 May 2009 (UTC)
That's very strange. The only other thing I can suggest is to try upgrading MediaWiki. You're running 1.13.1 but I've only tested FlvHandler on 1.13.3 and 1.14. If upgrading is too difficult (it's really quite easy though) you could try setting $wgUploadPath to "/wiki/images" but that should happen automatically. The reason why modifying FlvHandler showed the slash but didn't work is because it was loading the file from "/images" but by that time you had moved everything into "/wiki/images". If you modify FlvHandler.php again and set $strURL = $wgServer . '/wiki/' . $file->getUrl(); then it will probably work, but again, it's a bit dodgy ;-) -- Malvineous 08:57, 16 May 2009 (UTC)
I upgraded to mediawiki 1.14 , I made sure the directory was "Wiki" and then I modified the $strURL = $wgServer.'/wiki/'.$file->getUrl(); to read accordingly and..holy crap..apparently it works! Thanks. If you ever have any audio related stuff you think I can help with feel free to ask. I appreciate this a lot! - 12:29, 16 May 2009 (UTC)
No worries, glad you got it working! That's a bit odd that you still had to modify the PHP file to get it to work, I might have to look into it in case I've generated the URL incorrectly (although it does work fine on my own MW installation.) Would you mind posting an updated version of your LocalSettings.php again? If I can replicate your config locally I might be able to see why it's not working. -- Malvineous 12:46, 16 May 2009 (UTC)
Is there any way to have the movies go to the right. When I type [[image:MOVE.flv|right]] or [[image:MOVE.flv|thumb]] it doesn't behave like a conventional image. I will upload my localsettings in a bit and add a link.
Local settings http://www.yousendit.com/download/MnFnUGhkbThqV0IzZUE9PQ - 15:01, 16 May 2009 (UTC)
Thanks for that, I've worked out what the problem is. In your LocalSettings.php you've set $wgUploadPath to "images" but this variable must start with a slash. The default value is "${wgScriptPath}/images" which expands to "/wiki/images". Since this is the default, if you remove both $wgUploadPath and $wgUploadDirectory from your LocalSettings.php, both FLV extensions will start working again. I have also just released version r3 of FlvHandler, which includes a fix (so it will work, just like images do, even if you leave $wgUploadPath set incorrectly) and it also implements left and right floating alignment. -- Malvineous 02:24, 17 May 2009 (UTC)
Cool. I added it and it works too. If I wanted to generate the thumbnail ( it isn't generating) what exactly would I have to do? 10:32, 17 May 2009 (UTC)
You'll need to contact your hosting provider and ask them to install FFmpeg on your webserver. -- Malvineous 10:56, 17 May 2009 (UTC)

Great job ! Although I noticed a bug in FlvHandler.php : variables $fp and $hp should be replaced with $frameParams and $handlerParams, respectively. -- 12:04, 12 May 2009 (UTC)

Well spotted, thanks for letting me know! I've uploaded version r2 which incorporates your fix. -- Malvineous 12:40, 12 May 2009 (UTC)

Add your extension to mediawiki svn[edit]

Hello, It looks like you may have done the best job in incorporating FlowPlayer into MediaWiki. However, we would all benefit even more if you would add it to MediaWiki SVN instead of hosting it at your own site. Thanks. --Alterego 18:54, 14 June 2009 (UTC)

Hi, thanks for the positive feedback! I'd be more than happy to add it to MW SVN, but I'm not sure what benefit that would provide - or even whether the current devs would consider this extension worthwhile! -- Malvineous 21:53, 14 June 2009 (UTC)
Having an extension SVN makes it easier to download, makes it more trustworthy-looking, provides version control, and ensures that it will still be available if you get run over by a bus. Important considerations, I know. You can request commit access or ask a committer to add your extension for you. —Emufarmers(T|C) 20:56, 16 June 2009 (UTC)

Thumbnail generation[edit]

Works great, but I had to edit the following line:

$wgFLVConverters = array(
        'ffmpeg' => '$path/ffmpeg -vcodec png -i $input -ss 0 -vframes 1 -s $widthx$height -f image2 $output'


$wgFLVConverters = array(
        'ffmpeg' => '$path/ffmpeg -i $input -ss 0 -vframes 1 -s $widthx$height -f image2 $output'

(removed the -vcodec png) so it can generate the thumbnails properly.

Here is my ffmpeg -version:

FFmpeg version SVN-r19689-snapshot, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  libavutil     50. 3. 0 / 50. 3. 0
  libavcodec    52.32. 0 / 52.32. 0
  libavformat   52.38. 0 / 52.38. 0
  libavdevice   52. 2. 0 / 52. 2. 0
  libswscale     0. 7. 1 /  0. 7. 1
  built on Aug 24 2009 09:46:57, gcc: 4.2.1 (SUSE Linux)
FFmpeg SVN-r19689-snapshot
libavutil     50. 3. 0 / 50. 3. 0
libavcodec    52.32. 0 / 52.32. 0
libavformat   52.38. 0 / 52.38. 0
libavdevice   52. 2. 0 / 52. 2. 0
libswscale     0. 7. 1 /  0. 7. 1

Great extension, btw! Rafael Vargas 14:30, 24 August 2009 (UTC)

Ah ok, thanks for that. Looks like my web host (where the original ffmpeg string works) is using a really old version of ffmpeg:
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --prefix=/usr --libdir=${prefix}/lib --shlibdir=${prefix}/lib --incdir=${prefix}/include/ffmpeg ...
  libavutil version: 49.4.0
  libavcodec version: 51.40.2
  libavformat version: 51.11.0
  built on Feb  4 2008 14:49:27, gcc: 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
ffmpeg      SVN-rUNKNOWN
libavutil   3212288
libavcodec  3352578
libavformat 3345152
I'll add your string to the main page. -- Malvineous 21:57, 24 August 2009 (UTC)
Hmm, just thinking - if you remove this parameter how does FFmpeg know to generate a .png file, as opposed to say a .jpg? Is there some other option that should be used instead? -- Malvineous 22:03, 24 August 2009 (UTC)

Thumbnail generation not even trying to generate?[edit]

Hi Malvineous, I am trying to get thumbnails work but even after hours no success. It seems that there is not even a try to generate a thumbnail (the player works fine). In FlvHandler.php $strThumbURL=$thumb->getURL(); always returns fileicon.png.

I added a die("HERE"); in FlvImageHandler.php at the beginning of function dotransform to see if I ever get there but this is never being executed. In the page source I added the video with basic [[Image:Test,flv]] without any further parameters.

Can you give a clue where to look for the problem? --Mathias, 8. September 2009

What version of MediaWiki are you using? It's possible that if it's too old it's not calling the necessary functions. Also I assume that's a typo in your example (a comma "," instead of a dot "." in "Test,flv"). Do other thumbnails work if you upload a large image? -- Malvineous 11:35, 10 September 2009 (UTC)
Hi, I am using the actual stable version, 1.15. You are right with the typo but this happened only here in my posting - it is a dot of course. Other thumbnails are working well and thats the point I do not understand. --Mathias 14 September 2009
Do you mean to say that using [[Image:Test.flv]] doesn't display the Flash video either? That would indicate that the extension hasn't been installed or loaded correctly. Can you run through the installation steps on the main page and double-check you haven't missed anything? -- Malvineous 23:32, 14 September 2009 (UTC)
No, it displays the Flash Video and plays it well. No php errors, no clue. I installed this extension several times to be sure to have no mistake. I am a php programmer but I am new to MediaWiki and ... let's say to stupid for this at the moment. ;) --Mathias, 16. September 2009
Hmm, very strange. Can you put an 'echo' command at the front of each of the functions in FlvImageHandler.php? That might indicate which functions are being called, if any. If isEnabled() returns false it could prevent the rest of the code from running. (By the way, if you sign your comment with ~~~~ it will put the date and time in for you automatically.) -- Malvineous 22:12, 16 September 2009 (UTC)
Okay, maybe we are a little further now: I added an echo to the top of every function in FlvImageHandler.php. Only isenabled() is beeing executed and it returns "true". 21:42, 21 September 2009 (UTC)
Could you post a link to your LocalSettings.php? The only thing I can think of is that something in there is conflicting, because otherwise it should work fine. -- Malvineous 22:27, 22 September 2009 (UTC)
Sure, here it is, I replaced some entries like mail adresses with "removed". 22:09, 28 September 2009 (UTC)
Sorry about the delay getting back to you. It looks fine, all I can suggest is making sure you declare the options *after* you include the file. Most extensions will reset any variables when running the include/require line for security reasons, and although the version you're running shouldn't do that, someone has already fixed that bug in the SVN version... Have you tried disabling the other FLV (or indeed *all* the other) extensions to see if there's a conflict? -- Malvineous 11:52, 10 October 2009 (UTC)
Hi! So I tried using a "fresh" LocalSettings.php without any other extension and with options after inclusion of flvhandler but still no change. I think for me it is time to give up now. Thanks a lot, Malvineous. I will watch this page if someone finds a clue of what could be wrong with my setup. Mathias

Small Hack to show videplayer in article page[edit]


In your TODO there is to read: Preview on the .flv's article page, so you can watch the video from there (currently you have to embed it in a page before you can watch it.)

Also i've missed that feature.

Add the following code in file extensions/FlvHandler/FlvHandler.php before the last line ("?>"):

$wgHooks['ImageOpenShowImageInlineBefore'][] = 'efFlvHandlerShowImage';

function efFlvHandlerShowImage($imagepage, $out)
    efFlvHandlerRender($skin, $imagepage->img->title->mDbkeyform, $imagepage->img, $fp, $hp, $time, $res);
    return true;

If you call the article page (file page) then before the preview-image of the video you will see the videoplayer ! --Folke 11:21, 10 September 2009 (UTC)

Hey that's great, thanks for letting me know! I'll add it in this weekend and upload a new version. -- Malvineous 11:35, 10 September 2009 (UTC)

Modified/improved version[edit]


I've modified FlvHandler slightly, so it now has the following features:

  • Video player code is embedded anywhere (including Image Page) except Image Galleries and when size is set less than $wgMinFLVSize[] = array(180,180) by default. In Image Galleries, a "filmstrip" icon is also shown below each video to distinguish between videos and images.
  • Some error message formatting.
  • English+Russian i18n.
  • Removed commented out legacy-code (no hooks at all!).
  • Ability to set $wgFLVConverters and $wgFLVProbes before the inclusion of FlvHandler.php.
  • Automatic prepending of $wgFlashPlayer with MediaWiki script path ($wgScriptPath).
  • Support for any Unicode video file names (r3 can not download files with non-latin1 filenames).
  • Collages of 4 frames as previews when size is more than $wgMinFLVSize.
  • Modified FlvHandler is free of errors "frame size must be a multiple of 2" generated by ffmpeg, because the frame is extracted, and THEN resized using ImageMagick.
  • Flow player 3.1.3 bundled.
Important note: to disable embedding of video player code on image galleries, you need to apply 1-string patch to ImageGallery.php.

See http://svn.yourcmc.ru/viewvc.py/vitalif/trunk/MediaWiki-FlvHandler and http://yourcmc.ru/wiki/index.php/FlvHandler_(MediaWiki) as an extension page in my wiki.

http://yourcmc.ru/wiki/index.php/Категория:Видео is an example.

I wish these to be accepted into the trunk. Is it possible?

-- VitaliyFilippov 12:09, 14 September 2009 (UTC)

That's great, thanks for posting your changes! I'd be happy to include your improvements into the official release. Would you be able to post a diff between the latest release and your changes? That'd make it much easier for me to review and integrate the changes. -- Malvineous 23:32, 14 September 2009 (UTC)
Files ffmpeg4i, film6x10.gif, ImageGallery.php.diff are new. You can see diffs for other files in FlvHandler.i18n.php Diff, FlvHandler.php Diff, FlvImageHandler.php Diff or download something like patch. -- VitaliyFilippov 12:26, 18 September 2009 (UTC)
This version of FlvHandler is now included into our Mediawiki4Intranet (http://wiki.4intra.net/Mediawiki4Intranet, russian description) MW distribution. ffmpeg4i is replaced by PHP code because it adds an unneeded dependency on Perl now. You can see the code at http://svn.yourcmc.ru/viewvc.py/vitalif/trunk/ or at Google Code. -- VitaliyFilippov 12:52, 12 April 2011 (UTC)

FFmpeg error in creating thumbnails[edit]

After installing FFmpeg I encounter "Error creating thumbnail" in place of the thumbnails. It is part of the html output:

<table class="MediaTransformError" style="width: 85px; height: 120px;"><tr><td>Error creating thumbnail: </td></tr></table></div></div> <div class="gallerytext"> etc...

Prior to installing FFmpeg there was no such error written on the thumbs (it was just white) meaning FlvHandler must now be using the FFmpeg program but which fails for some reason to generated the thumbs.

ffmpeg is in the system path and I've not set any configuration parameters as they should fall back to the defaults. Are there any temporary directories that FFmpeg writes to which needs to be world-writeable, or any dependencies that FFmpeg uses to generate the thumbs graphics?

Any ideas what possible misconfiguration to search for would be greatly appreciated.

Many thanks, --Yellowdog 07:16, 22 March 2010 (UTC)

PS: This is my ffmpeg version:

bash-2.05a$ ffmpeg -version
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2006 Fabrice Bellard, et al.
  configuration:  --enable-mp3lame --disable-vhook --disable-network --disable-altivec --disable-ffserver
--disable-ffplay --enable-memalign-hack --disable-mmx --enable-static --extra-cflags=-I/usr/local/include 
--extra-ldflags=-L/usr/local/lib --disable-shared 
  libavutil version: 49.0.1
  libavcodec version: 51.21.0
  libavformat version: 50.6.0
  built on Apr 29 2007 21:10:43, gcc: 2.95.3 20010315 (release) [FreeBSD]
ffmpeg      SVN-rUNKNOWN
libavutil   3211265
libavcodec  3347712
libavformat 3278336

Update 1:

After adding the $wgFLVConverterPath explicitly, although it should be in the system path, thumbnailing now works on videos. However, the thumbs that should appear in <gallery>gallery</gallery> as well as those which should be displayed in Special:NewFiles, ie. the gallery of new files, do not work. This is the output on the Special:NewFiles page where the thumbs should normally appear:

Error creating thumbnail: FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2006 Fabrice Bellard, et al.
configuration: --enable-mp3lame --disable-vhook --disable-network --disable-altivec --disable-ffserver
 --disable-ffplay --enable-memalign-hack --disable-mmx --enable-static --extra-cflags=-I/usr/local/include 
--extra-ldflags=-L/usr/local/lib --disable-shared
libavutil version: 49.0.1
libavcodec version: 51.21.0
libavformat version: 50.6.0
built on Apr 29 2007 21:10:43, gcc: 2.95.3 20010315 (release) [FreeBSD]

Seems that stream 1 comes from film source: 1000.00 (1000/1) -> 20.00 (20/1)
Input #0, flv, from '/usr/home/wiki/images/video.flv':
Duration: 00:08:46.4, start: 0.000000, bitrate: 128 kb/s
Stream #0.0: Audio: mp3, 44100 Hz, mono, 128 kb/s
Stream #0.1: Video: flv, yuv420p, 192x272, 20.00 fps(r)
Frame size must be a multiple of 2

Any ideas what the error or my misconfiguration may be? The last line of output, ie. Frame size must be a multiple of 2, doesn't tell me anything I know how to fix.... Maybe I should try another video size.

Thanks --Yellowdog 16:50, 22 March 2010 (UTC)

Update 2:

The video that a thumbnail failed to generate itself from had been previously modified/encoded rotated 90 degrees from 640 pixels width times 480 pixels height to 480 pixels width times 640 pixels height, so in other words, from landscape format to portrait format. For this I was using Avidemux. Testing again but with a different (landscape) format video the thumbnails in <gallery>File:video.flv</gallery> and on the Special:NewFiles page now work fine. The fact that thumbs are not generated on the odd portait formatted video is no a big deal, however, the errors thrown back on the Special:NewFiles page are a bit ugly and muck up the otherwise nice page layout. Is there a way to suppress the errors by tweaking the code inFlvHandler?

Alternatively and maybe better, I simply added a style rule in MediaWiki:Common.css: ...

 .MediaTransformError td {

... which took care of the display problem while the errors are of course still viewable in the page source.

--Yellowdog 18:44, 22 March 2010 (UTC)

Possible Solution

I had the "Frame size must be a multiple of 2" problem om som of my files so I made two changes in FlvImageHandler.php in the doTransform function.


$physicalWidth = $params['physicalWidth'];
$physicalHeight = $params['physicalHeight']


$physicalWidth = floor($params['physicalWidth']/2)*2;
$physicalHeight = floor($params['physicalHeight']/2)*2;

-- Nilsy 07:37, 26 September 2011 (UTC)

Mime type matching on older systems[edit]

On my mediawiki 1.13 on ubuntu 8.04 imageHandler would find "text/plain" for flv. Add to LocalSettings.php

$wgMimeDetectorCommand = "file -bi";

Add below lines to /etc/magic.mime

# FLV video format
0       string          FLV                             video/x-flv

extracting frames from H.264[edit]

thanks for this awesome plugin. it works flawlessly with most video files. but it does not generate thumbnails (or an error message) from newer video files that are encoded with H.264. do you have any idea why? -philip 07:16, 6 April 2011 (UTC)

Which version of flowplayer and ffmpeg[edit]

does it handle deep linking[edit]

"Deep linking" of videos is the process of including a starting position for the video in the link to the video.

Can this extension support "Deep Linking" of embedded videos in mediawiki?

It doesn't at present, no. It should be possible to add, if flowplayer supports it. -- Malvineous 21:42, 9 November 2011 (UTC)

Fix for mediaviki version 1.20.2[edit]


From: $srcPath = $image->getPath();

To: $srcPath = $image->getLocalRefPath();

Fix for some video thumbnails generation[edit]


Wrong regex.

From: 'regex' => '/Stream.*Video.* (\d+)x(\d+),/' // [1] == width, [2] == height

To: 'regex' => '/Stream.*Video.* (\d+)x(\d+)/' // [1] == width, [2] == height