[FFmpeg-user] mapping formats to file extensions and MIME types

Carl Eugen Hoyos ceffmpeg at gmail.com
Sun May 21 15:03:15 EEST 2017

2017-05-21 1:07 GMT+02:00 Ofer Nave <odigity at gmail.com>:
> Maybe I wasn't clear enough about my situation.

No, you were not.

Top-posting is not welcome here, your email is a good
example why.

>  My process is this:
> 1) User uploads file.
> 2) I ignore the file's current extension (if any) and use

Just to make sure: There are file-types that are detected
by the file extension (targa for example).

> ffprobe to determine the format name.

So you only use the demuxer formats, never the muxer
formats (there is no 1:1 relationship), the muxers in your
list therefore make no sense.
You can use "ffmpeg -demuxers" to see all existing

> 3) I then consult my mapping table to decide:

> 3a) What extension to rename the file.

As said, this is generally difficult because for typical
file types like asf and mkv, different extensions
(depending on the file content) should be chosen.

> 3b) What contentType to serve the file with.

Demuxers like "mov...." and "matroska..." are used for
files with different mime-types, so I am not sure what
you want can be achieved with libavformat (that was
not written with the intention of mapping its formats
to mime-types).

Of course, if you don't require to be more exact than
libavformat, there is no issue.
As said, the source code may help you:
If you grep for ff_*_demuxer, you will find structs some
of which contain a field ".mime_type" with fields of
strings you can use.

Carl Eugen

More information about the ffmpeg-user mailing list