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

Ofer Nave odigity at gmail.com
Sun May 21 15:30:21 EEST 2017


On Sun, May 21, 2017 at 5:03 AM, Carl Eugen Hoyos <ceffmpeg at gmail.com>
wrote:

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

If you're referring to the fact that gmail automatically quoted the
previous message in my reply, I apologize.  I can prevent that from
happening now that I know it's an issue.

Now, it seems like I'm tripping over my own ignorance of ffmpeg and video
in general.  I assumed I could probe for format_name and simply map that to
a file extension and MIME type, but apparently it's more complicated than
that, so let me take a step back:

The Problem

I am given a file that may or may not be a video file.  I know the
extension it was originally named with on the user's computer, but since
anyone can name a file anything, I conclude I should ignore that.

1) Determine if ffprobe can understand it.  (It exits with 1 if it doesn't,
so that's easy.)
2) Compare it against some kind of whitelist of formats/codecs/etc that
I've decided to allow.  (Necessary because ffmpeg will, for example,
"recognize" a text file, and even report a video stream in it.)
3) If whitelisted, do further processing.

Additionally, I was going to attempt to determine what file extension and
MIME type would be most appropriate to associate with the original file and
store those in the DB for reference purposes, as well as to set the
contentType on the original file, since it is technically serveable via our
private web server.  But I can do without either if it proves to be too
difficult.

I would also appreciate any advice on assembling such a whitelist.

-ofer


More information about the ffmpeg-user mailing list