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

Carl Eugen Hoyos ceffmpeg at gmail.com
Sat May 20 19:05:30 EEST 2017


2017-05-20 1:51 GMT+02:00 Ofer Nave <odigity at gmail.com>:

> Anyone know of a reference for mapping ffmpeg format
> values to MIME types

You can use the FFmpeg source code to produce such a
mapping but I wonder what you need it for?

> and recommended file extension?

What is "recommended"?
The answer may be possible for avi (although .divx exists
iirc) but for asf, at least three "recommended" extensions
exist, for transport streams there may be even more.
Otoh, .mpg is used for three or four different formats, can
you "recommend" it for anything?

> My google attempt failed to turn up anything.
>
> I did manually put together a small list with guess-work and
> clues from Wikipedia, IANA
> <https://www.iana.org/assignments/media-types/media-types.xhtml#video>,
> and the Mozilla Developer Network
> <https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types>
> for the subset of formats that I encountered in my video
> input test collection:
>
> ffmpeg Format             Extension  MIME Type
> ───────────────────────   ─────────  ──────────────────────
> asf                       asf        application/vnd.ms-asf
> avi                       avi        video/x-msvideo
> flv                       flv        video/x-flv

> matroska,webm             webm       video/webm

This is a demuxer that supports several formats
with different mime-types.

> m4v                       m4v        video/x-m4v

This is a muxer.

> mov,mp4,m4a,3gp,3g2,mj2   mp4        video/mp4

This is a demuxer, again with different mime-types.

> mpeg                      mpeg       video/mpeg
> mpegts                    mpeg       video/mpeg
> mpegvideo                 mpeg       video/mpeg

Both the extension list and the mime-types make
little sense, the formats are not identical.

Wikipedia claims the mime-type for mpegts is
"video/MP2T" (and MP2P for mpegps and dvd
for vob which I thought is the same).

> ogg                       ogv        video/ogg

> matroska                  mkv        video/x-matroska
> webm                      webm       video/webm

These two are muxers.

> No idea if I've made the right calls, though.

> (The test files already have file extensions, but I'm operating
> on the assumption that the extension of a file a user uploads
> is irrelevant, and

This is generally correct although a few formats exist
for which probing is impossible or at least so difficult
that FFmpeg does not support it currently.

> that the file should be renamed based on ffprobe and

> intelligent mapping...)

If you don't trust the extension (which generally makes sense)
why would you trust the mime type? And why would you trust
it more than probing?

Carl Eugen


More information about the ffmpeg-user mailing list