How do I get the Mime type I need to pass to MediaSource.isTypeSupported
with ffprobe/ffmpeg?
For instance, on my computer, that returns true
:
MediaSource.isTypeSupported('video/mp4; codecs="avc1.64000d,mp4a.40.2"')
while that doesn't
MediaSource.isTypeSupported('video/mp4')
I'm not sure how to get what would correspond to the avc1.64000d,mp4a.40.2
part for a given video. Here is a larger list of what this part may look like.
ffprobe -show_streams -i video.mp4
returns a number of interesting informations, including
codec_type=video
codec_time_base=1/40
codec_tag_string=avc1
codec_tag=0x31637661
and
codec_type=audio
codec_time_base=1/48000
codec_tag_string=mp4a
codec_tag=0x6134706d
I'm not sure I should go with 'video/mp4; codecs="avc1.0x31637661,mp4a.0x6134706d"'
since this returns false
and I don't know if it's because it's not the excepted argument or because the video is indeed not supported.
A MIME type consists of two parts: a type and a subtype. Currently, there are ten registered types: application, audio, example, font, image, message, model, multipart, text, and video.
What is a Video MIME Type? MIME type stands for multipurpose internet mail extensions and is a format for a video file that is transmitted across the internet. MIME types were originally created so that emails could send more than just text.
I realize this is a super old questions, but I recently ran into this myself. I had a hard time finding an easy way to get the proper MIME string so I wrote a simple Node.js CLI program to do it using the excellent mp4box.js.
You use it like this:
$ npx get-video-mime your-video-file.mp4
[22:28:37] Getting MIME for 1 file(s)...
[22:28:38] MIME for your-video-file.mp4 detected as: video/mp4; codecs="hev1.1.6.L120.90,mp4a.6b"; profiles="isom,iso2,mp41"
[22:28:38] Finished processing all files.
Hopefully it will help someone else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With