Closed uribes78 closed 7 years ago
Can you log out the value of data.exten.toLowerCase()
and see what it is? It looks like it's "ype"
which SoX doesn't recognize.
BTW, you might want to use sox.js
, since it looks like you are transcoding from a source file to a destination file.
Thanks for the answer, looks like sox.js is good. Just I want to understand, how the sox-stream module is filling the tempFile variable. Sorry but I'm new using the stream concept, I have been reading your code and still don't understand how the readable file is pass to the tempFile.
Any way, I will follow you advice to use the other module, because my proyect needs to be done this week.
Thanks again.
Dear @ArtskydJ , I'm trying with the sox.js module and I'm still getting the error, this is the output error:
[Error: sox: invalid option -- - sox: Unknown input file format for 'ogg': File type 'ype' is not known ] Error: sox: invalid option -- - sox: Unknown input file format for 'ogg': File type 'ype' is not known
at Socket.<anonymous> (/opt/epbx/node_modules/sox.js/index.js:26:6)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:153:18)
at Socket.Readable.push (_stream_readable.js:111:10)
at Pipe.onread (net.js:537:20)
And my code change like this:
` var sox = require('sox.js'); this.convert = (data) => { return new Promise(function(resolve, reject) { var wavFilePath = path.join(spoolPath, data.wavFile); var convertedFile = path.join(spoolPath, data.filename); var wavFileReader = null;
fs.stat( wavFilePath, (err, stats) => {
if (err) {
reject(err);
} else {
sox({
inputFile: wavFilePath,
outputFile: convertedFile,
output: { type: 'ogg' }
}, (err, fout) => {
if (err) reject(err);
else if (fout) resolve(true);
else reject(new Error("Error convertion"));
});
}
});
});
};
` Could be the sox version am I using? The version I have is sox-12.18.1-1. Hope you can help me, and thanks for your time
I put a "console.log" for the args variable you have on the code, and this is printing:
sox args: [ '/var/spool/asterisk/monitor/2017/01/13/out-82731255325-72802-20170113-150939-1484341779.301039.wav', '--type', 'ogg', '/var/spool/asterisk/monitor/out-82731255325-72802-20170113-150939-1484341779.301039.ogg' ]
taking that, I execute manually the sox command (on linux trying to use the same parameters), I'm getting this:
sox /var/spool/asterisk/monitor/2017/01/13/q-910-9018119671202-20170113-151138-1484341880.301052.WAV --type ogg /var/spool/asterisk/monitor/2017/01/13/q-910-9018119671202-20170113-151138-1484341880.301052.ogg sox: invalid option -- - sox: Unknown input file format for 'ogg': File type 'ype' is not known
So, what I'm guess is the {output: {type: 'ogg'}} is been converted to "--type ogg" and that parameter doesn't exist for sox, according this official documentacion, so I change to {output: {t: 'ogg'}}, and that works for me.
sorry if I bother you, but I was trying to make this works because I need it. Thanks anyway
Forgot to close the issue.
You didn't bother me. :)
Apparently this isn't getting tested. (Neither output: { type: 'ogg' }
nor output: { t: 'ogg' }
are getting tested.)
I re-opened the issue so I can put some tests in place, and see if I can replicate the issue. I wonder if you have an older version of SoX because in this documentation, --type is allowed.
To search for it in the documentation, do Ctrl+F
, "Gives the type". Don't do Ctrl+F
, "--type" because the dashes in the documentation are unicode dashes.
I think your documentation link was for a different sox-related application.
If you have inputFile and outputFile specified, I think sox
will figure infer the types so you don't have to specify them.
My guess is that this is related to you having sox-12.18.1-1. I use sox-14.4.2...
Glad to hear that you got it working. :grinning:
Your new code looks pretty good. It looks like you don't need wavFileReader
anymore, and probably don't need the output.type
option since you're using sox.js.
Anyway, since I actually need to test sox.js, and not sox-stream, I'm gonna close this issue again.
Tracking my lack of a test for output.type
sox.js here: https://github.com/ArtskydJ/sox.js/issues/3
Maybe you right, I can be using an older version of sox (sox-12.18.1-1.) coming on the OS repository, I'm using an old CentOS version (CentOS 5.6), and this is because the Elastix VoIP service we are working is installed on that OS.
Let me try using the "type" parameter on a new version and let you know.
Thanks again to be on touch with this issue.
You probably don't need the type
parameter at all now that you're using sox.js
. SoX should figure out the types based on the file extension names.
But if you want to try on a new version, you may. :)
By the way, if you want to learn about streams, this is a great resource: https://github.com/substack/stream-handbook
sox-stream
's codebase is sort of confusing. Due to limitations it's about as simple as I can make it.
Hi, I have been trying to convert a wav file to a ogg file, but is raising this next error
The code I'm using is the next
` this.convert = (data) => { return new Promise(function(resolve, reject) { var wavFilePath = path.join(spoolPath, data.wavFile); var convertedFile = path.join(spoolPath, data.filename); var wavFileReader = null;
`
hope you can help me with this. If I try transcode manual using the sox commando I don't have a problem.
Thanks for you time.