render-media icon indicating copy to clipboard operation
render-media copied to clipboard

Analyze file type rather than guess from filename

Open notgne2 opened this issue 8 years ago • 3 comments

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?

notgne2 avatar Nov 27 '17 00:11 notgne2

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?

feross avatar Apr 30 '18 07:04 feross

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:

btzr-io avatar Jul 03 '18 19:07 btzr-io

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

subins2000 avatar Apr 29 '20 10:04 subins2000