I have media files without extension but i cant server them using php as Apache needs Addtype directive which is based on file extensions but I cant use them so i have to let Apache auto detect mime types. I think mod_mime_magic can do that i have enabled it but it is not detecting mp4 files.
What values can i use in conf/magic file so Apache can detect mp4, flv, webm etc ? MimeMagicFile conf/magic
My conf/magic file has only these entries for media
# Quicktime video, from Linus Walleij <triad#df.lth.se>
# from Apple quicktime file format documentation.
4 string moov video/quicktime
4 string mdat video/quicktime
Try:
4 string ftypmp4 video/mp4
Related
Hi I am having an issue where the client side is unable to connect/play video content from a .mp4 asset file located on an Apache Server.
I am suspecting the issue has to do with the Content-Type parameter in the HTTP Headers.
How can I modify this Content-Type parameter to see if this is the issue?
I'd like to try video/mp4, audio/mp4, audio/m4a, audio/aac, etc.
To fix this issue on Apache you need to add the following content to the ‘.htaccess‘ file which is found in your document root (public_html or htdocs).
just paste this to your .htaccess (required mime types)
AddType video/mp4 mp4 m4v
AddType audio/mp4 m4a
You can also add these mime types directly in the Apache configuration file ‘mime.types’
/etc/httpd/conf/mime.types
add required mime.types.
video/mp4 mp4 m4v
audio/mp4 m4a
then restart apache.
I have a page that is using JWPlayer to serve a video in a variety of format choices (mp4, m4v, ogv, webm). However, when accessing the page from Firefox (23.0.1) or with PHP curl, Apache is returning a header indicating the content-type as text/plain. Firefox (and newer IE versions, unless in compatibility mode) will not play the video. I have tried adding the mime types in mime.types, httpd.conf, and in an .htaccess file in the directory.
mime.types
video/mp4 mp4 m4v
video/ogg ogv
video/webm webm
httpd.conf
AddType video/mp4 mp4 m4v
AddType video/ogg ogv
AddType video/webm webm
.htaccess
AddType video/mp4 mp4 m4v
AddType video/ogg ogv
AddType video/webm webm
I have tried with and without the dot in front of the extensions (which as I understand should work either way). I have restarted Apache. I have verified that I am editing the right configuration files. Still Apache continues to return the text/plain type. Where have I gone wrong?
UPDATE: Tried FilesMatch and ForceType directive as suggested by rekire in httpd.conf, virtualhost, and .htaccess. Tried renaming files and changing links to match in case of middleman caching. Going straight to the URL downloads the video and allows to play it in desktop player normally.
In the official documentation for AddType of mod_mime are the file extensions listed with a leading dot so try this:
AddType video/mp4 .mp4 .m4v
AddType video/ogg .ogv
AddType video/webm .webm
Or try ForceType together with FilesMatch:
<FilesMatch "\.(mp4|m4v)$">
ForceType video/mp4
</FilesMatch>
Answering my own question, over 2 years later. It turned out to be an issue that was not determinable from the information I gave in the question, and a relatively simple problem. There was an .htaccess file that was routing ALL requests - existing resource files or not - to a PHP file, which was then handling all file requests itself, including returning a MIME type, effectively bypassing all of the handling I was attempting to do in Apache.
I am getting an error in Firefox (ver 22/23) that says:
Specified "type" attribute of "video/mp4" is not supported. Load of media resource xxxxx failed.
Is this repairable?
It's all about MIME types. When you specify type attribute on your video source - you also need to make sure your server understands what that types of files actually mean.
AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm
Add these lines to your server's .htaccess file and you'll be up'n'running.
For any additional information related to video conversion/playback - check out this article
I have download directory on apache webserver. Files in this directory have specific extensions. For example *.yyy and *.zzz. But all these files are renamed .zip or .tar.gz
I've tested in different brawsers and havn't got any problems.
But some users tell that they get source of packages, not download.
I've created.htaccess
AddType application/zip .zzz
AddType application/x-gzip .yyy
But when I try to download aaa.yyy in MS Internet Explorer it try to save not aaa.yyy but aaa.gz
How to force browsers download files and not to change extensions?
<FilesMatch "\.(zzz|yyy)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
Force type tell browsers that you dont know file type. So they are not going to do any thing stupid. Second line will tell them to download this file.
I'm developing a website that has a HTML5 video. It looks like when ogg files are served with other mime types than video/ogg firefox flips. I've updated the mime.types file inside the mamp/apache/config folder and have restarted the MAMP server multiple times, but ogg files are still served with plain/text context-type.
Can someone point out what I need to do?
UPDATE
The only time I'm able to change the mime type is if I change the DefaultType text/plain to DefaultType video/ogg which is stupid.
The mime.types file is in Applications/MAMP/conf/apache
There you can alter your mime types.
Reset server after changing the file for it to take effect.
Do you have mod_mime_magic installed and enabled? Is your mime magic working correctly? When you do file -m on one of your OGG files, does it say it is a plain text file? Are the file extensions correct?
Adding mime-type is the same for all, it's just you need to understand how the types will be applied and what's the mime-type point is. In this answer I'll how I tried to add WebAssembly mime-type application/wasm in MAMP.
Here it goes:
I recently tried WebAssembly in MAMP and configured out the below mime-type that works for me.
First, we need to navigate the folder of MAMP in MacOS's Applications/MAMP/conf/apache, And then open the file mime.types in any editor.
After opening the file, add the following line anywhere in the mime.types file:
application/wasm wasm
Here is the example wasm mime type in my mime.types file:
#application/wasm
application/wasm wasm
In MAMP Pro these days you can add <VirtualHost> parameters using the gui. Here's a screenshot showing how I add MIME types for .mjs and .wasm as:
AddType application/javascript .mjs
AddType application/wasm wasm
screenshot
Don't forget to restart the server after adding.