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

Problem with MP3 files in OSX #15

Open
prajankya opened this issue Feb 23, 2019 · 3 comments
Open

Problem with MP3 files in OSX #15

prajankya opened this issue Feb 23, 2019 · 3 comments

Comments

@prajankya
Copy link

I tried to give input file as MP3, which gives a odd error as

sox FAIL formats: can't determine type of file

After debuging and also checking through the issues noted at #14, I found out that sox will understand MIME type from extensions for MP3 file only.

when I try to do

soxi ./test.mp3

I get a valid response, but when I do

soxi ./test

(obviously I renamed the file to without an extension)

thats the same error I get, i.e.

sox FAIL formats: can't determine type of file

I have tested it with various mp3 files, even files from online sources as sample mp3 for sound testing. Tested many other formats as well, but the problem seems to come only for MP3, which leads

Now the problem after looking at the source code is, as all is done through streams, it is very hard to get extension unless the input is from fs.createWriteStream or fs.createReadStream as noted in here(stackoverflow).

For my use case, I have solved it by adding an extension to the the function call for createTempFile()
as static, but Please look into this, as it is a undocumented bug.

@ArtskydJ
Copy link
Owner

The issue is that if you pipe in a stream, sox-steam and sox both will not know what type of file is being piped.

soxi ./test.mp3 # works; sox looks at the file ext
soxi ./test     # does not work

cat ./test.mp3 | soxi - # my guess is that this will not work
cat ./test | soxi       # my guess is that this will not work either

cat ./test.mp3 | soxi - --type=mp3 # my guess is that this will work
cat ./test | soxi - --type=mp3     # my guess is that this will also work

If my guesses are correct, then this is an issue with sox not detecting file types.

@prajankya
Copy link
Author

Hey, thanx, I totally overlooked the documentation and forgot I could give ext in input.

Currently using like this,

sox({
    input: {
      type: fileName.split(".").pop()
    },
    output: {
    // Other things
    }
})

So this library is working perfectly fine, only catch is if the user want to give MP3 then he has to give type in input or for generic use case something similar to my code as shown above.
Please correct me if I am wrong.

I think we can close this issue.

Also I would suggest that you should document it in README about the same(MP3 support with input.type doesn't work)

Thanks. Have a great day.

@ithustle
Copy link

ithustle commented Mar 2, 2019

Install libsox

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

No branches or pull requests

3 participants