Forum Moderators: phranque

Message Too Old, No Replies

Treat .flv files as .mp4?

         

cschults

11:46 pm on Nov 3, 2010 (gmt 0)

10+ Year Member



Is there a way to define the mime type of .flv files so they are served as .mp4 files?

I ask as I need to start using .mp4 files on our site. However, we have a lot of videos saved with the .flv extension, but these are essentially .mp4 files in a .flv container. And in fact, the files started out as .mp4 and were changed to .flv.

Eventually we'll change the file extensions properly, but have to do so via a content management system and not sure when we'll get around to doing that.

sublime1

12:28 am on Nov 4, 2010 (gmt 0)

10+ Year Member



I am not an expert on Flash Video, and hope that I never need to become one :-). However, my assumption is that the .flv extension (or more properly, the FLV mime type) is used to inform the browser of how to render the content. A flash plugin on the browser would be invoked and instructions about how to render the video would be part of the <object> or <embed> code used in the HTML. The MP4 contains only the video -- the FLV may contain additional information about how to serve it.

So I don't think you could just say "Ah, request for .flv, will change extension to .mp4 and serve back to the client as a flv mime type". You might be able to configure the embedded object in the HTML to be agnostic about FLV or MP4, but I am not sure about that.

Hopefully, all of this goes away with HTML 5, having native support for video. But for now, Flash is it.

Tom

cschults

5:37 pm on Nov 4, 2010 (gmt 0)

10+ Year Member



Thanks Tom. The reason this has come up is that we're upgrading our Flash only video player to the latest version of the JW Player that is a Flash player (that plays .mp4) with a HTML5 fallback. We have a reasonable number of mobile visitors (mostly using Apple devices) and we'd like them to be able to watch the videos we produce.

So I have the new player working fine, and I can play our videos on the iPhone and iPad, but they have to be supported file types. In our case .mp4 files. Like I said, the files currently have the .flv extension and I was hoping I could instruct Apache to serve them up as .mp4.

So I just tried adding this to the .htaccess file in the video directory: AddType video/mp4 .flv

And according to the HTTP response header for my test .flv file: Content-Type: video/mp4

So it seems to work. But my iPad won't play the video via the HTML5 player or the video directly when using the .flv version as it appears the device goes by the file extension.

However, when I add this to the .htaccess file:

RewriteEngine On
RewriteRule example\.mp4 /video/example.flv [L]

So now when I play example.mp4, it is really loading example.flv, which is being treated as .mp4. And it works on my iPad. As soon as remove the AddType directive, it no longer works. (Yes, I cleared my cache each time I tested.)

With all that said, I'm going to update my file extensions as I should, but thought this was a good proof of concept.

cschults

9:35 pm on Nov 9, 2010 (gmt 0)

10+ Year Member



On a side note, after renaming all the .flv files to .mp4, I successfully deployed the new player. However, the same videos that played fine on our staging site did not work on our production site -- at least not from my office.

Turns out that our firewall is changing the HTTP header by setting "Accept-Ranges" to "none" from "bytes", which apparently Apple devices require.