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

Question: Syntax question #50

Closed
DongDanBam opened this issue Feb 11, 2021 · 2 comments
Closed

Question: Syntax question #50

DongDanBam opened this issue Feb 11, 2021 · 2 comments
Labels

Comments

@DongDanBam
Copy link

DongDanBam commented Feb 11, 2021

Still trying to figure out how this script operates. Im trying to hardcode the file that is to be analyzed.

ive replaced const file = fileinput.files[0] with const file = "D:\videoFiles\sampleVideo.mp4

Then I call the onChangeFile class with a button <button class="btn btn-default" id="getframe" onclick="onChangeFile()">Get Frame Rate</button>

It never produces a result. The output displays "Working…"

Is there a different place that I can hardcode the file name & path?

 const onChangeFile = (filename) => {
            //const file = fileinput.files[0]
            const file = "D:\videoFiles\sampleVideo.mp4";

            if (file) {

                output.value = 'Working…'
   
                const getSize = () => file.size

                const readChunk = (chunkSize, offset) =>
                    new Promise((resolve, reject) => {
                        const reader = new FileReader()
                        reader.onload = (event) => {
                            if (event.target.error) {
                                reject(event.target.error)
                            }
                            resolve(new Uint8Array(event.target.result))
                        }
                        reader.readAsArrayBuffer(file.slice(offset, offset + chunkSize))
                    })

                mediainfo
                    .analyzeData(getSize, readChunk)
                    .then((result) => {
                        console.log("Frame: " + result.media.track[0].FrameRate);
                        output.value = result;
                    })
                    .catch((error) => {
                        output.value = `An error occured:\n${error.stack}`
                    })
            }
        }
@buzz buzz added the question label Feb 11, 2021
@buzz
Copy link
Owner

buzz commented Feb 11, 2021

The repository includes examples that do work. Just try them. If you need further assistance please check SO.

Thank you

@buzz buzz closed this as completed Feb 11, 2021
@DongDanBam
Copy link
Author

Ive got an example to work just fine. Having trouble understanding how all the hooks and snags work so running a few simple experiments to get acquainted with your creation. Ive been through SO from top to bottom and found only vague references. I couldn't find any thing on SO that provided enough of a well rounded explanation to help me learn.

How can I hard code a file name and path directly into your code example? seems like I should be able to replace const file = fileinput.files[0] with const file = "D:\videoFiles\sampleVideo.mp4";

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

No branches or pull requests

2 participants