Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyze file type rather than guess from filename #33

Open
notgne2 opened this issue Nov 27, 2017 · 3 comments
Open

Analyze file type rather than guess from filename #33

notgne2 opened this issue Nov 27, 2017 · 3 comments

Comments

@notgne2
Copy link

notgne2 commented Nov 27, 2017

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?

@feross
Copy link
Owner

feross commented Apr 30, 2018

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?

@btzr-io
Copy link
Contributor

btzr-io commented Jul 3, 2018

This module uses magic numbers:
https://github.com/sindresorhus/file-type
https://github.com/sindresorhus/first-chunk-min-size-stream

Looks promising 🙂

@subins2000
Copy link

subins2000 commented Apr 29, 2020

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' })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants