I'm using the ffmpeg library to decode / encode audio in JAVA, using the Process objets. The aim is to got the raw datas decoded by ffmpeg in my JAVA code and then, to send them back to ffmpeg to generate a stream or create a file.
As JAVA sounds only allow wav audio datas, I made a first try with this command line :
ffmpeg -i http://199.180.75.118:80 -acodec pcm_s16le -ar 44100 -ac 2 "/home/dr_click/montest.wav"
It works. But, my goal is to get the frames on the fly and not a file. I thought about using a pipe but it seems it will work only with Linux and not with Windows (and no idea for MacOS) So, I'd prefer to stream locally a wav file and to catch it with JAVA into a AudioInputStream.
I wrote this command :
ffmpeg -re -i http://199.180.75.118:80 -acodec pcm_s16le -ar 44100 -ac 2 -f rtp rtp://127.0.0.1:1234
It semms to work on the server side. But, when I enter the below command line on the server side :
ffplay rtp://127.0.0.1:1234
It doesn't work at all. I got this error :
If I try the couple :
ffmpeg -i http://199.180.75.118:80 -acodec pcm_s16le -ar 44100 -ac 2 -f rtp -sdp_file /home/dr_click/audio.sdp rtp://127.0.1.1:1234
and
ffplay /home/dr_click/audio.sdp
I got the following error :
And if I finally try :
fmpeg -protocol_whitelist file,http,rtp,tcp -i http://199.180.75.118:80 -acodec pcm_s16le -ar 44100 -ac 2 -f rtp -sdp_file /home/dr_click/audio.sdp rtp://127.0.1.1:1234
I still get the same error.
Which point do I miss to stream locally some raw datas and catch them back in the AudioInputStream ?
Thank you for all your replies.
Finally, I found the explanation. The RTP streaming with the payload 10 or 11 are big endian. So, it's impossible to stream with a little endian codec. The right way to stream is to change the codec and the command line is becoming :
ffmpeg -re -i /home/dr_click/live.wav -acodec pcm_s16be -ar 44100 -ac 2 -payload_type 10 -f rtp rtp://127.0.0.1:1234
Thank you to those who read my question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With