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

Wrong mime type #362

Open
alssdllc opened this issue Jul 28, 2024 · 3 comments
Open

Wrong mime type #362

alssdllc opened this issue Jul 28, 2024 · 3 comments
Labels

Comments

@alssdllc
Copy link

I'm still trying to understand how all of this works. The issue is I record a video with MediaRecorder in the browser and submit it to my node server which uses multer (which uses busboy).

In chrome the content-type is: video/mp4;codecs=avc1,opus even when I specify video/mp4.
In safari the content-type is video/mp4.

busboy returns the proper mimetype for safari but returns text/plain for chrome. The safari made video is saved properly and plays. The chrome made video does not play properly. I'm assuming it's corrupt or something.

@mscdex
Copy link
Owner

mscdex commented Jul 28, 2024

I think that's an issue you'll have to dive into yourself because busboy can only give you what was given to it. It doesn't modify content types or anything like that. The most important thing to ensure is that you're giving busboy multipart/form-data data and not video data directly.

@alssdllc
Copy link
Author

You are correct that the content-type is not modified. But isn't the content-type used to determine the mime type?

When I look through some of the code. I am comparing the safari run and the chrome run.

They both hit this code (in multipart.js):

if (header['content-type']) {
    const conType = parseContentType(header['content-type'][0]);
    if (conType) {
        partType = `${conType.type}/${conType.subtype}`;
        if (conType.params && typeof conType.params.charset === 'string')
            partCharset = conType.params.charset.toLowerCase();
    }
}

For safari header['content-type'][0] is equal to video/mp4
For chrome header['content-type'][0] is equal to video/mp4;codecs=avc1,opus

For safari conType is a proper object:

params = {}
subtype = 'mp4'
type = 'video'

For chrome conType is undefined.

I would imagine that is part of the problem.

@aydincandan
Copy link

Well, how nice, Chrome gives more, it is not missing or wrong.

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

3 participants