Analyze file type rather than guess from filename
Would it possible to have a better gauge on the correct mime-codec for MediaSource APIs if you analysed the file? There are tools are tools available such as mp4box.js, and we should only need the first few bytes to figure this out. Could we read enough data from the file's readstream and use that to get the full codec data before piping that and all the rest of the data to the writeStream for MediaSource?
I think this is a promising strategy. Do you have an idea for how to accomplish this? I'd be happy to look at a PR if you want to send one.
Also, I'm curious if @jhiesey has any thoughts about this?
This module uses magic numbers:
https://github.com/sindresorhus/file-type
https://github.com/sindresorhus/first-chunk-min-size-stream
Looks promising :slightly_smiling_face:
Yeah, this please ! I've been using webtorrent and some filenames have a .svg extension but the content is actually PNG. And therefore renderTo fails to give a blank image :/
Can the mime-type passed to File object when making the file and torrent be accessed in download ?
new window.File([response.data], filename, { type: 'image/png' })