1

For context, I have a video player written in Electron that allows users to load video files from their local machine. It does this by setting the src of the file to a local file path. This "reference" to the file is required because video files often exceed 5gb in size.

I know using the File System Access API it is possible to grab a reference to a local file but using the file appears to require creating an object URL, for example:

const src = URL.createObjectURL(await fileHandle.getFile())

After testing, it seems that it is not possible to use videos larger than 2gb with this method.

Am I missing something obvious about the usage of the File System API? Would it be possible to use an alternative workaround with this (perhaps streaming the files contents somehow?)

Samuel
  • 2,331
  • 1
  • 22
  • 40
  • "After testing, it seems that it is not possible to use videos larger than 2gb with this method." Really? Which browser? The File you get should only be a pointer to the actual file on disk, and the blob: URL should only be a pointer to the File's data, so there shouldn't be any limit because the – Kaiido Apr 26 '22 at 03:17
  • @Kaiido Hmm. I first tried this in Chrome 9x - I can't remember the exact version. I could have messed this up somehow though. Do you have the code you've written handy in a codepen or similar? – Samuel Apr 26 '22 at 10:00
  • 1
    fiddles are hard to make (cross origin iframes) but just type `handle = await showOpenFilePicker(); file = await handle[0].getFile(); v = document.createElement("video"); v.controls = true; document.body.prepend(v); v.src = URL.createObjectURL(file)` in your console, that should do it. – Kaiido Apr 26 '22 at 10:53

0 Answers0