Topic on Extension talk:TimedMediaHandler

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

2
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 :
    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*/)
    
  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)"