Thanks in advance ,I am converting rtsp live stream to .wav file using ffmpeg.Its converting good but i want to convert .wav file to byte stream parallely at the time of converting rtsp to .wav file
1 Answers
1)Launch ffmpeg as a Proceas with the option to decode to standard output in the Arguments (usually a '-' at the end of the arguments)
2) Read the standard output from that Process in accordance with the output format being written.
This keeps the output in memory and allows you to consume it just after its been provided to stdout.
See this question for an example commanf of how to get raw audio from ffmpeg.
Can ffmpeg convert audio to raw PCM? If so, how?
You can't expect a player to understand the datastrucutes without the wav headers because the sample size and rate are not defined in a raw pcm stream.
Finally I think you'll see that it's better to output wav format and read the wav format which will contain everything a player needs to playback the audio.
You would them provide wav audio instead of pcm which will work in naudio as well as many other players quite easily.
-
sorry for the late reply,and thanks for the reply.I am new to ffmpeg,Is there any way to convert the stream into byte format directly.If it is please send the format to convert stream into bytes[] array – suresh Feb 15 '16 at 12:34
-
You can read the BaseStream of StandardOuput to obtain the raw bytes. The raw bytes will be in the format specified by the Arguments passed to the ffmpeg process. – Jay Feb 15 '16 at 13:25
-
thank u ,yes by using BaseStream of StandardOuput we are able to get raw bytes.but when we play the raw bytes using NAudio we are not getting the correct audio,we are getting only noise.Is there any way to get the correct audio as output – suresh Feb 16 '16 at 08:55
-
It's hard to say without an example of the command your using. The data format being written to stdout is defined by the Arguments passed to ffmpeg. You can specify any format you want but you have to read the output intelligently, if you specify raw pcm then you should be able to calculate how many bytes are in every sample and read that many bytes, it seems your reading is not aligned by the noise problem you cite. – Jay Feb 16 '16 at 12:21