Omeka Failing to Detect Video MIME Types on Upload

Hi, it seems that Omeka is failing to correctly detect mime types on upload. I've uploaded a video as both webm and mp4 but they are ingested as video/quicktime and application/octet-stream (rather than video/webm and video/mp4), respectively.

So, I'm wondering if this is a bug/error, or if Omeka uses more generic mime types for some reason.

I'm trying to write "HTML5-with-Flash-Fallback" video support into a theme but am having a hard time detecting mime type of each file.

I don't want to write a plugin that changes Omeka's behavior; I just want to enhance video playback at a theme level for now. Is this possible?

It seems likely that I'm missing/misunderstanding something here, so any help would be appreciated. Here's the code I'm using so far.

This is just to create download links for images and (supported) video...

<?php
		    while(loop_files_for_item()):$file = get_current_file();
		    //check mime type for VideoJS compatibility.

		    //NOTE: last item in array catches any files whose mimetype was not recorded by Omeka at ingest

		    //TROUBLESHOOT: if WebM,MP4,OggVideo files appear in the sidebar,
		    //then Omeka has not correctly recorded it's mimetype
		    // or the file was improperly encoded.  

		    $mime = $file->getMimeType;
		    $videoJS = array('video/mp4','video/ogg','video/webm','');

			//if image --> bypass display but include the download link...
		    if (item_has_thumbnail())
					{
					foreach ($item->Files as $file){
					echo '<div style="clear:both;padding:2px;"><a href="'. file_download_uri($file,'fullsize'). '" class="download-file">'. $file->original_filename. '</a></div> ';
					}
										}
			//if compatible video --> bypass display but include the download link...
			elseif ( array_search($mime, $videoJS) !== false )
					{
					echo '<div style="clear:both;padding:2px;"><a href="'. file_download_uri($file). '" class="download-file">'. $file->original_filename. '</a></div> ';
					}	

			//all others...
			else {
				display_files_for_item();
				}					

			endwhile;
			?>

The actual video player (using the VideoJS script) needs to be written like so, which is the bigger issue demanding specific mimetypes:

<!-- Begin VideoJS -->
  <div class="video-js-box">
    <!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody -->
    <video id="example_video_1" class="video-js" width="640" height="264" controls="controls" preload="auto" poster="http://video-js.zencoder.com/oceans-clip.png">
      <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
      <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm; codecs="vp8, vorbis"' />
      <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg; codecs="theora, vorbis"' />
      <!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
      <object id="flash_fallback_1" class="vjs-flash-fallback" width="640" height="264" type="application/x-shockwave-flash"
        data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">
        <param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />
        <param name="allowfullscreen" value="true" />
        <param name="flashvars" value='config={"playlist":["http://video-js.zencoder.com/oceans-clip.png", {"url": "http://video-js.zencoder.com/oceans-clip.mp4","autoPlay":false,"autoBuffering":true}]}' />
        <!-- Image Fallback. Typically the same as the poster image. -->
        <img src="http://video-js.zencoder.com/oceans-clip.png" width="640" height="264" alt="Poster Image"
          title="No video playback capabilities." />
      </object>
    </video>
    <!-- Download links provided for devices that can't play video in the browser. -->
    <p class="vjs-no-video"><strong>Download Video:</strong>
      <a href="http://video-js.zencoder.com/oceans-clip.mp4">MP4</a>,
      <a href="http://video-js.zencoder.com/oceans-clip.webm">WebM</a>,
      <a href="http://video-js.zencoder.com/oceans-clip.ogv">Ogg</a><br>
      <!-- Support VideoJS by keeping this link. -->
      <a href="http://videojs.com">HTML5 Video Player</a> by VideoJS
    </p>
  </div>
  <!-- End VideoJS -->

Thanks -- Erin

Can you post the "Mime Type / Browser", "Mime Type / OS", and "File Type / OS" strings from the files/show page for the offending files?

Omeka uses PHP features to detect the MIME type of files, and this can be highly dependent on your specific server setup. Basically, if the OS your server is running on doesn't know about WebM or MP4, Omeka usually won't either.

Here's what I'm seeing...

.webm
Mime Type / Browser:
application/octet-stream
Mime Type / OS:
blank
File Type / OS:
blank

.mp4
Mime Type / Browser:
video/quicktime
Mime Type / OS:
blank
File Type / OS:
blank

.m4v
Mime Type / Browser:
video/quicktime
Mime Type / OS:
blank
File Type / OS:
blank

By the way, on a related note, there must be some better way to sort out media types within a file loop than what I'm doing here (basically manually listing every supported rich media filetype from Media.php and grouping into variables to test against)...

<?php
	$index = 0;
	//start the loop of item files
	while(loop_files_for_item()):$file = get_current_file();
	//variables used to check mime types for VideoJS compatibility, etc.
	$mime = item_file('MIME Type');
	$videoJS = array('video/mp4','video/mpeg','video/ogg','video/quicktime','video/webm');
	$wma_video = array('audio/wma','audio/x-ms-wma');
	$wmv_video = array('video/avi','video/msvideo','video/x-msvideo','video/x-ms-wmv');
	$audio = array('application/ogg','audio/aac','audio/aiff','audio/midi','audio/mp3','audio/mp4','audio/mpeg','audio/mpeg3','audio/mpegaudio','audio/mpg','audio/ogg','audio/wav','audio/x-mp3','audio/x-mp4','audio/x-mpeg','audio/x-mpeg3','audio/x-midi','audio/x-mpegaudio','audio/x-mpg','audio/x-ogg','audio/x-wav','audio/x-aac','audio/x-aiff','audio/x-midi','audio/x-mp3','audio/x-mp4','audio/x-mpeg','audio/x-mpeg3','audio/x-mpegaudio','audio/x-mpg');
	//this loops through images for the item and returns a fullsize image for
	//the first item with square thumbs for the rest.  Images are grouped into galleries with the rel
	//fancy_group and interact with FancyBox via the class fancy_item
		if (($file->hasThumbnail()&&($index == 0)))
		echo 'Click the image to launch gallery view'.display_file($file, array('imageSize'=>'fullsize','linkAttributes'=>array('rel'=>'fancy_group', 'class'=>'fancyitem','title' => item('Dublin Core', 'Title'))),array('class' => 'fullsize', 'id' => 'item-image '));
		elseif (($file->hasThumbnail()&&($index !== 0)))
		echo display_file($file, array('imageSize'=>'square_thumbnail', 'linkToFile'=>true,'linkAttributes'=>array('rel'=>'fancy_group', 'class'=>'fancyitem','title' => item('Dublin Core', 'Title'))),array('class' => 'square_thumbnail'));
	//this is testing for rich media files and deciding what to do with them.
		//videoJS
		elseif
		(array_search($mime,$videoJS) !== false) echo 'compatible video &nbsp;#'.$index.' --> &nbsp;'.$file->original_filename.'&nbsp;('.$mime.') has a <a href="'.file_download_uri($file).'">file</a>  I can use!<br/>';
		//wma video
		elseif
		(array_search($mime,$wma_video) !== false) echo display_file($file);
		//wmv video
		elseif
		(array_search($mime,$wmv_video) !== false) echo display_file($file);
		//audio
		elseif (array_search($mime,$audio) !== false) echo display_file($file);
	$index++;
	endwhile;
	?>

Hi Erin,

You could optimize that some, but right now you would have to check against that array of MIME types. We've added some tickets—Ticket #1038 and Ticket #1039—to help with this very issue. We hope to get these done for the 1.4 release.

It seems like you've done a lot of work with displaying different kinds of files, so if you have opinions about how to make this easier, please let us know.

And, I think WebM should have the MIME type 'video/webm' or 'audio/webm' instead of 'application/octect-stream'. That could be causing you some issues with displaying those files correctly.

Thanks Jeremy. The 'octect-stream' thing is what Omeka is producing/displaying. Not sure what can be done to fix that.