Comments (10)
@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);
from sox-stream.
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.
from sox-stream.
I've typed exactly your commands and it's working like a charm
from sox-stream.
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.
from sox-stream.
Thanks for your help, I'll try this
from sox-stream.
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...
from sox-stream.
Thank you so much! I missed the stdout...
On an unrelated note, do you know if it's possible to determine amplitude values from a stream? "sox stat" doesn't seem to be working with:
cp.spawn('sox', [ '--type=wav', '-', '-n', 'stat' ])
(i read both stderr and stdout and both aren't returning)
Thank you once again!!
from sox-stream.
On an unrelated note, do you know if it's possible to determine amplitude values from a stream?
I don't know.
"sox stat" doesn't seem to be working with:
cp.spawn('sox', [ '--type=wav', '-', '-n', 'stat' ])
What do you see in the console if you run that command directly?
cat myfile.wav | sox --type=wav - -n stat
from sox-stream.
On an unrelated note, do you know if it's possible to determine amplitude values from a stream?
I don't know.
"sox stat" doesn't seem to be working with:
cp.spawn('sox', [ '--type=wav', '-', '-n', 'stat' ])
What do you see in the console if you run that command directly?
cat myfile.wav | sox --type=wav - -n stat
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
from sox-stream.
I wonder if sox stat
is trying to read the entire "file", so it doesn't write to stdout until the stream is finished?
from sox-stream.
Related Issues (20)
- VBR on MP3 files HOT 2
- Breaks with newer versions of node HOT 1
- spawn sox ENOENT HOT 9
- Error: sox WARN mp3-util HOT 5
- Problem with MP3 files in OSX HOT 3
- Why write to temp file? HOT 3
- Pipe to on data HOT 3
- Segmentation fault in sox results in a zero-byte stream.
- Error: write EPIPE on use of trim effect HOT 2
- sox-stream does not work with file descriptor HOT 1
- replay-gain is required in typescript, but should not be HOT 1
- How create realtime reading stream ? HOT 1
- Streams & Pipe resulting in ENOENT HOT 5
- sox FAIL formats: no handler for detected file type `opus' HOT 1
- How to pass additional parameter (ex. the "-s" for "sox tempo -s 0.5") HOT 5
- A readme probable fix
- sox: invalid option -- - HOT 11
- How to connect additional output streams? HOT 2
- Get it works with bpm.js HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sox-stream.