Streaming SBC or APTX over http to ffmpeg? #825
-
I'm trying to stream audio data captured via I2S over http. I'd like to do 44100hz sampling, so applying some compression seems like a good idea. I was able to make streams-i2s-webserver_aac work, but couldn't get the sampling rate over 22050hz. It was suggested that I try one of the codecs that Bluetooth uses. That's where I am now. Starting with streams-i2s-webserver_aac as a model, I've tried both SBC and APTX encoding. I can connect to the server, the server seems to be serving up data, but I can't get ffmpeg to decode it. Ffmpeg runs a while then returns an error of "Invalid data found when processing input". I have been able to get ffmpeg to translate a wav file to an SBC file and from SBC to a wav file. My ffmpeg command looks something like this: ffmpeg -i http://192.168.1.150 -dcodec sbc -t 15 output.wav Any suggestions? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Not sure what the issue is. ffmpeg does not give any meaningful hint... |
Beta Was this translation helpful? Give feedback.
-
There's something odd going on... Before trying this I updated the arduino-audio-tools library and cloned the libopus library for the first time. With the example you suggested, when I try to open the stream with VLC, it take a long time to buffer up and the play back is very choppy. When I try to save the stream to ogg, I get a bunch of errors, but it does produce a file. The output file was 35KB and could be opened with VLC. It contained the test tone but also some noise. I recorded for about 10 seconds, and the output file was about 6 seconds long. Note that ffmpeg thinks the input stream has a sample rate of 48000Hz even though it has been configured to be 16000Hz. This is the same in every test.
When I try to save to wav, it seems to work but the clock timing the save is running really slowly. Note the "time" on the last line is listed as 0.60 seconds, even though it had been running for maybe 20 seconds. The output file sounded the same as the ogg file, but was of course much larger (1.2MB). It was also much longer in duration - VLC says 12 seconds.
I also tried copying to an opus file without reencoding. The resulting file was very 36KB. It also contained the test tone but was only about 3 seconds long.
Also, between tests I had to restart the ESP32. If I didn't, I'd get an error like... The AAC example streams-generator-server_aac.ino works perfectly.
|
Beta Was this translation helpful? Give feedback.
Not sure what the issue is. ffmpeg does not give any meaningful hint...
Today I fixed the broken opus-ogg codec: maybe you can try this example