Coder Social home page Coder Social logo

Empty file about sox-stream HOT 10 CLOSED

artskydj avatar artskydj commented on May 27, 2024
Empty file

from sox-stream.

Comments (10)

ArtskydJ avatar ArtskydJ commented on May 27, 2024 1

@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.

ArtskydJ avatar ArtskydJ commented on May 27, 2024

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.

tuarrep avatar tuarrep commented on May 27, 2024

I've typed exactly your commands and it's working like a charm

from sox-stream.

ArtskydJ avatar ArtskydJ commented on May 27, 2024

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.

tuarrep avatar tuarrep commented on May 27, 2024

Thanks for your help, I'll try this

from sox-stream.

vladraduvidican avatar vladraduvidican commented on May 27, 2024

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.

vladraduvidican avatar vladraduvidican commented on May 27, 2024

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.

ArtskydJ avatar ArtskydJ commented on May 27, 2024

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.

vladraduvidican avatar vladraduvidican commented on May 27, 2024

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.

ArtskydJ avatar ArtskydJ commented on May 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.