{"id":22439385,"url":"https://github.com/junka/ffmime","last_synced_at":"2025-10-24T08:24:39.517Z","repository":{"id":186540393,"uuid":"675332495","full_name":"junka/ffmime","owner":"junka","description":"Get mime type codecs for MSE in webassembly","archived":false,"fork":false,"pushed_at":"2024-08-07T05:42:59.000Z","size":5303,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-22T04:41:30.725Z","etag":null,"topics":["codecs","ffmpeg","mime-types","wasm","webassembly"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/junka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-06T15:18:21.000Z","updated_at":"2025-06-05T10:42:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"e331dd1a-1f19-4b27-bb66-54bccefe6685","html_url":"https://github.com/junka/ffmime","commit_stats":null,"previous_names":["junka/ffmime"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/junka/ffmime","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junka%2Fffmime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junka%2Fffmime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junka%2Fffmime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junka%2Fffmime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/junka","download_url":"https://codeload.github.com/junka/ffmime/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junka%2Fffmime/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266465104,"owners_count":23933067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codecs","ffmpeg","mime-types","wasm","webassembly"],"created_at":"2024-12-06T01:13:58.571Z","updated_at":"2025-10-24T08:24:34.465Z","avatar_url":"https://github.com/junka.png","language":"C++","readme":"\n### About MIME codecs\nWhen we use MSE (Media Source Extension) for developing a media player, the api **MediaSource.isTypeSupported** needs extra information about the media file.\nWe will need a MIME codec string like\n```\nvideo/mp4; codecs=\"avc1.64001E, mp4a.40.2\"\naudio/mp4; codecs=mp4a.40.42\nvideo/webm; codecs=\"vp8, vorbis\"\n```\n\n\nsee More [web format codec](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/codecs_parameter).\nsee [Wiki](https://wiki.whatwg.org/wiki/video_type_parameters)\n\nIt consists of the MIME type part and codecs string part.\n\n---\n\n### MIME type supported\nMedia files would have text(VTT subtitle), image, audio and video files, so it is supposed to recognize them like below。\n```\ntext/\nimage/\naudio/\nvideo/\n```\nAnd codecs string like below.\n```\nav01.P.LLT.DD[.M.CCC.cp.tc.mc.F]\ncccc[.pp]* (Generic ISO BMFF)\nmp4v.oo[.V] (MPEG-4 video)\nmp4a.oo[.A] (MPEG-4 audio)\navc1[.PPCCLL] (AVC video)\nhev1.P.T.Ll.Bb (HEVC video)\nand other no spec using codec name\n```\n\n### How to use\nHow to know the the mime type and codecs.\nFor those who have installed nodejs, you may run npx like below.\n```\nnpx ffmime \u003cmediafile\u003e\n```\n\nFor those who have installed the ffmpeg libraries and want to build from source, run\n```\ngit clone https://github.com/junka/ffmime.git\ncd ffmime\nmake mime\n./ffmime mediafile\n```\n\n### wasm\nWe can use it in javascript code.\n```\nnpm install ffmime\n```\nThen in the code, like in electron we can get the MIME type and codecs string. \nThe returned string can be used for the MSE API **MediaSource.isTypeSupported()**.\n\n```\nimport {GetMimeCodecs} from 'ffmime'\nconst mimeType = await GetMimeCodecs(filename)\nconsole log(mimeType)\n```\n\n\nTo build wasm from source,\n```\ndocker build -f Dockerfile --output package .\n```\nwasm js files are built into package directory and then you can publish and import the package.\nOnly muxer and demuxer configured as enabled in ffmpeg, so we could have a minified wasm binary which is less than 2MB size. This is much more reasonable than a full ffmpeg. Here we only need a probe for the mimetype and codecs string.\n\n### Extra note\nSome format could have a side effect. \n- For example, a `mkv` format could output `video/x-matroska; codecs=\"avc1.640029, mp4a.40.2\"` which is not supported by Chrome, but you can replace `x-matroska` with `mp4` to make it pass the check of the Chrome.\n\n- However, when the mimetype is `video/mp4`, if the mp4 container box is **NOT** **fragmented**, the media file would not be decoded right by MSE.\n\n- A `mp3` format could output `audio/mpeg; codecs=85` which `85` is the codec id. For use in browser, just strip the codecs. `audio/mpeg` will be supported by the browser.\n\n- Raw `pcm` can hardly probed without any hint. so it will return empty string.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunka%2Fffmime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjunka%2Fffmime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunka%2Fffmime/lists"}