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 :
- 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 ).
- In includes/TimedMediaHandlerHooks.php , I added several mime types support, and modified an if-clauses accordingly :
70,88d69 < $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 292,293c273 < if ( ( $mediaType == 'webm' || $mediaType == 'ogg' || $mediaType == 'mp4' || $mediaType == 'othervideo' /*PMU*/)
- 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...)
- 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.