ArtskydJ / node-sox-stream

:mega: A stream-friendly wrapper around SoX
53 stars 14 forks source link

Pipe to on data #17

Open crls-scbr opened 5 years ago

crls-scbr commented 5 years ago

Hi there, I'd really appreciate some pointers on the following setup: I'm grabbing radio feeds with icy, checking the stream for codec details which I'm using to put together the sox input. The objective is to transcode to 8k mono wav to then feed to another setup via websocket.

Being a radio feed there is no EOF, the setup grabs portions of the audio to process on the fly for the next step to take action, but my on 'data' is only getting the buffers if I interrupt the process, meaning sox seems to be waiting for an EOF to pipe the whole temp file rather than letting it flow. Any ideas on how to accomplish this?

BTW I also tried just the same as the example, piping to a fs write stream, and got the same error: ENOENT: no such file or directory, unlink '...' :(

ArtskydJ commented 5 years ago

The issue is that I am writing it to a file in this repo, because sox was more reliable that way. However, that does not work with your use-case.

You could try using child_process directly: https://github.com/ArtskydJ/sox-stream/issues/9#issuecomment-338430206

crls-scbr commented 5 years ago

Thanks for getting back to me. I currently have a working setup with lame, but is not running as expected, reason why I want to replace it with cox. In the current setup I’m doing the concat though on data with specific intervals from the output of a lame.decoder, I was hoping to match this with the output of cox-streamer but i really don’t know how to handle your file setup. The suggestion you sent seems to only replace the temp file with a fully accumulated buffer, but again it will require a EOF event that doesn’t exist from the ongoing radio feed.

Any other ideas on how I can get those buffer bits as they are processed by cox?

On Jul 4, 2019, at 9:12 AM, Joseph Dykstra notifications@github.com wrote:

The issue is that I am writing it to a file in this repo, because sox was more reliable that way. However, that does not work with your use-case.

You could try using one of the solutions outlined here: ArtskydJ/sox.js#9 https://github.com/ArtskydJ/sox.js/issues/9 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ArtskydJ/sox-stream/issues/17?email_source=notifications&email_token=AGAH5Z7COK6JFYSMVDGQD6TP5XSK7A5CNFSM4H5I4EI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZHH25Q#issuecomment-508460406, or mute the thread https://github.com/notifications/unsubscribe-auth/AGAH5ZYQSST3BN3UOPA3RLDP5XSK7ANCNFSM4H5I4EIQ.

ArtskydJ commented 5 years ago

I don't know. I haven't tried that use-case.

You could try running it from the command-line and see if sox even works with files like you're wanting. I don't know if it works with non-ending streams.