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.
Using Bento4, I can get the Mime type with
mp4info video.mp4 | grep Codec
That will return something like
Codecs String: avc1.64001F
Codecs String: mp4a.40.2
And then do
MediaSource.isTypeSupported('video/mp4; codecs="avc1.64001F,mp4a.40.2"')
which returns true
:)
Bento4 is focussed on mp4
so I'm not sure how it'd work on other formats
Any other way to convert the 0x31637661
part to avc1.64001F
?
EDIT: since I have not installed Apple's XCode and no intention to - I have found the javascript project of MP4Box the best way to find the codec information in the right format:
http://download.tsi.telecom-paristech.fr/gpac/mp4box.js/filereader.html
来源:https://stackoverflow.com/questions/35616494/get-mime-type-for-mediasource-istypesupported