-
Notifications
You must be signed in to change notification settings - Fork 14
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
Empty file #9
Comments
Does it work from the command line? E.g. cat myfile.ogg | sox --type=ogg - --rate=44100 --type=wav newfile.wav
curl http://listen.oma-radio.fr/paj.ogg | sox --type=ogg - --rate=44100 --type=wav newfile.wav If something is working from the command line, and not in the sox-stream module, then it's probably an issue with the module. If it's broken in both, it's probably an issue with sox support of the attempted action. |
I've typed exactly your commands and it's working like a charm |
When I created this module, I was having issues with streaming certain inputs since sox was then unable to go back and read the headers. So I made the decision to pipe the input to a temporary file, and then run sox when that completes. I don't like the solution, but it's what made it work at the time. I wish it was, but this module is not currently a great all-around module. From what I can tell, the way you and I use it are pretty different. 😬 If you're wanting to use node.js for this operation, you can use child_process, and the command I wrote above. // untested
const fs = require('fs')
const http = require('http')
const cp = require('child_process')
const dest = fs.createWriteStream('transcoded.wav')
// If you have the argument '-' instead of a filename, sox will use stdin or stdout instead of a file
// http://sox.sourceforge.net/sox.html#FILENAMES
const transcode = cp.spawn('sox', [ '--type=ogg', '-', '--rate=44100', '--type=wav', '-' ])
http.get('http://listen.oma-radio.fr/paj.ogg', res => {
res.pipe(transcode).pipe(dest)
}) Sorry this module isn't working out for you. |
Thanks for your help, I'll try this |
I would like to pipe a arecord/pulse audio stream in node using the script you wrote above but I can't seem to get it to work... // a pulseaudio client opening a recording stream
const rate = 44100, channels = 2, format = PA_SAMPLE_FORMAT.S16LE;
const stream = await pa.createRecordStream({
sampleSpec: { rate, format, channels }
});
const writer = new wav.Writer({
sampleRate: rate,
channels,
bitDepth: sampleSize[format] * 8
});
stream.pipe(writer);
const dest = fs.createWriteStream('transcoded.wav')
const transcode = cp.spawn('sox', [ '--type=wav', '-', '--rate=44100', '--type=wav', '-' ])
writer.pipe(transcode.stdin).pipe(process.stdout, { end: false }); I'm getting an empty file... |
@tommyzat you're not piping anything into your write stream for transcoded.wav. I'm not sure exactly what will work, but maybe this will: - writer.pipe(transcode.stdin).pipe(process.stdout, { end: false });
+ writer.pipe(transcode.stdin);
+ transcode.stdout.pipe(dest); |
Thank you so much! I missed the stdout... Thank you once again!! |
I don't know.
What do you see in the console if you run that command directly?
|
It does work, indeed! However I wanted to do it with a stream because I need to get the amplitude of sound at 60fps without writing to disk at all |
I wonder if |
Hi!
I'm trying to transcode an audio http stream from ogg to wav.
Here is my code:
The output file remain empty with no error message in the console.
I've tried to pipe directly the http stream to the file, it's working.
I've tried to convert a real ogg file from file system with this code:
I encounter the following errors in my terminal:
And the file re'mains empty
The text was updated successfully, but these errors were encountered: