Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get mime type for MediaSource.isTypeSupported

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.

like image 391
Guig Avatar asked Feb 25 '16 01:02

Guig


People also ask

What are the different mime types?

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 MIME type 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.


1 Answers

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.

like image 119
Dominic P Avatar answered Sep 19 '22 18:09

Dominic P