How to map ffmpeg formats to MIME types and file extensions?
Asked Answered
Q

1

18

Anyone know of a reference for mapping ffmpeg format values to MIME types and recommended file extension? My google attempt failed to turn up anything.

I did manually put together a small list with guess-work and clues from Wikipedia, IANA, and the Mozilla Developer Network 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
m4v                       m4v        video/x-m4v
mov,mp4,m4a,3gp,3g2,mj2   mp4        video/mp4
mpeg                      mpeg       video/mpeg
mpegts                    mpeg       video/mpeg
mpegvideo                 mpeg       video/mpeg
ogg                       ogv        video/ogg
matroska                  mkv        video/x-matroska
webm                      webm       video/webm

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 that the file should be renamed based on ffprobe and intelligent mapping...)

Quaker answered 17/5, 2017 at 21:57 Comment(0)
B
7

Unfortunately there doesn't seem to be a straightforward way to do this so I combined a short list of MIME types myself using multiple different methods - you can try the same approach for extensions:

https://gist.github.com/DusanBrejka/35238dccb5cefcc804de1c5a218ee004

Although this question is over 3 years old, I'm sure someone will find this useful in the future.

Bewail answered 12/8, 2020 at 13:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.