Preview .webm as video instead of audio
|Assignee:||Go MAEDA||% Done:|
When I attach a WebM video to a Redmine ticket, Redmine's ticket preview uses an
<audio> tag instead of a
<video> tag to display the video. This is unfortunate because it essentially renders the video preview unusable; the
<audio> tag will only play the audio part of the video. Users currently have to download WebM videos to view them.
I've looked into the code and determined that Redmine uses the MiniMime library to determine an attachment's MIME type by looking at the extension, and MiniMime does indeed map
audio/webm. Of course, this isn't necessarily wrong as WebM is just a container format that can contain audio and/or video, so it's IMO not a MiniMime bug.
I would suggest to overwrite the
webm mapping in Redmine with
video/webm and always preview WebM files with a
<video> tag, regardless whether it contains audio or video. This will waste a bit space when previewing audio files as browsers will display an empty area for the non-existent video part, but it's probably far easier than actually detecting whether the WebM file contains a video stream or not.
I've attached a short WebM video to illustrate the problem.
redmine.iserv.eu /var/www/redmine # sudo -u www-data ruby bin/about sh: 1: svn: not found sh: 1: cvs: not found sh: 1: bzr: not found Environment: Redmine version 4.0.3.stable Ruby version 2.3.3-p222 (2016-11-21) [x86_64-linux-gnu] Rails version 220.127.116.11 Environment production Database adapter PostgreSQL Mailer queue ActiveJob::QueueAdapters::AsyncAdapter Mailer delivery sendmail SCM: Mercurial 4.0 Git 2.11.0 Filesystem Redmine plugins: redmine_agile 1.4.10 redmine_checklists 3.1.15 redmine_custom_css 0.1.7 redmine_local_avatars 1.0.3 redmine_revision_branches 0.3.2 redmineup_tags 2.0.5
#1 Updated by Martin von Wittich 15 days ago
- File Download.png added
OK, uploading that attachment to illustrate the issue didn't have the intended effect because redmine.org won't preview the attachment. Is redmine.org still running an older Redmine version...?
I've attached a screenshot how the attachment preview looks in our Redmine (using the Circle theme).
#2 Updated by Bernhard Rohloff 15 days ago
- Status changed from New to Confirmed
I can confirm the behavior and would also prefer to have a preview for video files instead of an audio player. I think it's more common for people to attach videos to their tickets.
Martin von Wittich wrote:
...Is redmine.org still running an older Redmine version...?
Yes redmine.org runs a version which is far older than the latest release.
#3 Updated by Seiei Miyagi 15 days ago
#6 Updated by Martin von Wittich 13 days ago
Go MAEDA wrote:
After applying the patch, Firefox shows the following error instead of a video. The Japanese text in the screenshot says "No video with supported format and mime type found".
Oops... I thought I had tested my WebM file both in Firefox and in Chrome, but you're right, I can reproduce the issue in Firefox. Sorry for that, I should've probably taken more care to choose an example file that works :)
I had created this file with the Chrome extension Screencastify. According to
ffmpeg, it's encoded with h264:
Input #0, matroska,webm, from 'Example Domain.webm': Metadata: encoder : w69b-mediawriter Duration: 00:00:01.85, start: 0.000000, bitrate: 154 kb/s Stream #0:0(eng): Video: h264 (Constrained Baseline), yuv420p(progressive), 746x720, SAR 1:1 DAR 373:360, 1k tbr, 1k tbn, 2k tbc (default)
But apparently, h264 isn't even an allowed video codec for the WebM container format, so Firefox isn't in the wrong here. Maybe the demo files provided by webmfiles.org are more suitable? https://www.webmfiles.org/demo-files/
I've attached http://dl5.webmfiles.org/elephants-dream.webm to a test ticket in our production Redmine and manually changed the
<audio> tag to a
<video> tag (I don't have a dev instance ready so I can't test the patch properly), and that one seems to work fine in Firefox and in Chrome.
- Subject changed from Attachment preview plays WebM video with <audio> instead of <video> to Preview .webm as video instead of audio
- Status changed from Confirmed to Closed
- Assignee set to Go MAEDA
- Resolution set to Fixed
Committed the patch. Thank you all for working on this issue.