@nxtedition/mime
v1.0.1
Published
MIME type lookup and extension resolution with built-in support for broadcast and professional media formats missing from the standard `mime` package.
Keywords
Readme
@nxtedition/mime
MIME type lookup and extension resolution with built-in support for broadcast and professional media formats missing from the standard mime package.
Install
npm install @nxtedition/mimeUsage
Lookup MIME type by filename
import { lookup } from '@nxtedition/mime'
lookup('video.mxf') // 'application/mxf'
lookup('video.mp4') // 'video/mp4'
lookup('video.nut') // 'video/x-nut'
lookup('audio.ac3') // 'audio/ac3'
lookup('subs.stl') // 'application/x-ebu-stl'
lookup('subs.scc') // 'text/x-scc'Get extension from MIME type
import { extension } from '@nxtedition/mime'
extension('video/mp4') // 'mp4'
extension('video/x-dnxhd') // 'dnxhd'
extension('audio/ac3') // 'ac3'
extension('application/x-ebu-stl') // 'stl'
extension('video/quicktime', 'clip.mov') // 'mov'Broadcast & media types
Types handled beyond the standard mime package:
| Extension | MIME Type | Format |
| ------------ | ----------------------------- | ------------------------- |
| .nut | video/x-nut | NUT container |
| .dnxhd | video/x-dnxhd | Avid DNxHD/DNxHR |
| .dv | video/x-dv | DV video |
| .h265 | video/h265 | Raw HEVC stream |
| .av1 | video/av1 | Raw AV1 stream |
| .ffv1 | video/ffv1 | FFV1 archival codec |
| .vc1 | video/vc1 | VC-1 video |
| .ac3 | audio/ac3 | Dolby Digital |
| .eac3 | audio/eac3 | Dolby Digital Plus |
| .opus | audio/opus | Opus audio |
| .flac | audio/flac | FLAC lossless |
| .pcm-s16le | audio/x-pcm-s16le | Raw 16-bit PCM |
| .pcm-s24le | audio/x-pcm-s24le | Raw 24-bit PCM |
| .pcm-s32le | audio/x-pcm-s32le | Raw 32-bit PCM |
| .stl | application/x-ebu-stl | EBU STL subtitles |
| .scc | text/x-scc | Scenarist Closed Captions |
| .cap | application/x-cap | Softel CAP captions |
| .890 | application/x-890 | Cavena 890 subtitles |
| .pac | application/x-pac | Screen Electronics PAC |
| .ass | text/x-ass | Advanced SubStation Alpha |
| .ssa | text/x-ssa | SubStation Alpha |
| .exr | image/x-exr | OpenEXR |
| .cin | image/x-cin | Cineon |
| .ism | application/vnd.ms-sstr+xml | Smooth Streaming |
API
lookup(name: string): string | null
Returns the MIME type for the given filename or path, or null if unknown.
extension(mimeType: string, fileName?: string): string | null
Returns the file extension for the given MIME type, or null if unknown. The optional fileName parameter is used to disambiguate (e.g. video/quicktime → mov when the filename ends in .mov).
License
MIT
