Opened 13 years ago

Closed 13 years ago

#429 closed defect (fixed)

Videos/muisc don't play because MediaGoblin should take care of mime-type before upload them to Rackspace Cloudfiles

Reported by: Jorge Araya Navarro Owned by: Jorge Araya Navarro
Priority: critical Milestone: 0.3.0
Component: component1 Keywords: video, mime, type, vpx, webm, rackspace, cloudfiles
Cc: jorgean@… Parent Tickets:

Description

This bug happen with some web browser which can't guess the mime type of a video and therefore, play such video. Rackspace by default set the mime type to application/octet-stream. I got a example code here:

conn = cloudfiles.get_connection(‘RACKCLOUD_USERNAME’, ‘RACKCLOUD_API_KEY’)
container = self.conn.get_container(‘container_name’)
meta_data = {}
video_object = container.create_object(‘remote_video_name.mp4′)
video_object.load_from_filename(‘/path/to/local/video.mp4′)
meta_data['mime-type'] = ‘video/mp4′
video_object.metadata = meta_data
video_object.sync_metadata()

source: http://www.jemery.com/2010/09/14/mime-type-is-really-important-to-set-for-html5-video-in-rackspace-cloudfiles/

Attachments (1)

bugfix429.patch (919 bytes ) - added by Jorge Araya Navarro 13 years ago.
the final patch for this annoying bug. It's a glorious victory, comrades!

Download all attachments as: .zip

Change History (8)

comment:1 by Christopher Allan Webber, 13 years ago

Priority: majorcritical

comment:2 by Christopher Allan Webber, 13 years ago

So there's two ways to handle this.

Solution one way is a (comparitively) super easy, super lazy approach, which doesn't require any sort of rearchitecting whatsoever. That is, when we create a cloudfiles object, we check against some database that matches file extensions to known mimetypes. Python comes with one of these, but it's not complete, I think, for some recent things like webm. Anyway, see the following:

http://docs.python.org/library/mimetypes.html

I think there's a version we can add things to, but I haven't tested it. Look at:

http://docs.python.org/library/mimetypes.html#mimetypes-objects

This is potentially unideal because it means we might say audio files are 'video/webm' since all .webm files can only look like only *one* of video/webm or audio/webm under this method... however, that's "just as bad" as the way nginx handles it currently, which is to check the extension (so all .webms look like video/webm) and that's "good enough" for that, so maybe it's good enough for this too.

... So the second solution, which is a lot more messy, is to add something to our storage system so we can do something like:

storage.save(filepath, mimetype='audio/webm')  # or whatever this syntax is, I forget

That way we can set it ourself, *if we can*. I'm not really thrilled with that route though as it requires a lot of careful rearchitecting, so in retrospect, don't do it ;)

Solution 1 is probably best for now.

comment:3 by joar, 13 years ago

The mimetypes python module looks in the following places for extension => MIMEtype mappings: http://hg.python.org/cpython/file/2.7/Lib/mimetypes.py#l40.

15/22:44.13 < joar> Shackra: Does any of these contain a .webm entry? 
                    http://hg.python.org/cpython/file/2.7/Lib/mimetypes.py#l40
15/22:44.44  * Shackra checks
15/22:45.53 < Shackra> CHET!
15/22:46.00 < Shackra> joar, no, it doesn't

comment:4 by Jorge Araya Navarro, 13 years ago

Resolution: fixed
Status: newclosed

I submit a possible bugfix :)

comment:5 by Christopher Allan Webber, 13 years ago

Resolution: fixed
Status: closedreopened

Thanks for the patch! Please don't close a bug until your code is merged though, or else it will appear that it already has been, and then it might *never* get merged! :)

by Jorge Araya Navarro, 13 years ago

Attachment: bugfix429.patch added

the final patch for this annoying bug. It's a glorious victory, comrades!

comment:6 by Jorge Araya Navarro, 13 years ago

and Boom Goes the Dynamite

I fix it, so, we can play video and audio files with any browser on Mediagoblin ;D

...

I though that until I patched my instance, because the bug still there in my public instance however my local-for-hacking instance works as expected, just watch this screenshot from my rackspace cloudfiles control panel

Last edited 13 years ago by Jorge Araya Navarro (previous) (diff)

comment:7 by Christopher Allan Webber, 13 years ago

Resolution: fixed
Status: reopenedclosed

This patch got merged actually :)

Note: See TracTickets for help on using tickets.