I am facing some problems in my project.
In my project, I need to implement microphone integration with RED5 server using Actionscript which is used to store the audio stream on server and after that I used ffmpeg in java code to convert the flv file to mp3.
I am facing 2 problems here:
The recorded audio creates .flv file which is currepted.
When I try to convert the .flv to .mp3 using ffmpeg, it gets stuck until I stop the Red5 server.
Here is my code of both places. Please let me know where I am doing wrong.
Actionscipt to record microphone audio and stream on red5:
private function initConnection():Void {
trace("Connecting...");
nc = new NetConnection();
nc.client = this;
nc.addEventListener(NetStatusEvent.NET_STATUS, onNetConnectionStatus);
nc.connect("rtmp://127.0.0.1/test");
this.mic = Microphone.getMicrophone();
if (this.mic != null) {
this.mic.rate = 44;
mic.setSilenceLevel(0);
mic.gain = 100;
mic.setUseEchoSuppression(true);
mic.setLoopBack(true);
}
}
To Send on Red5:
public function startSending( nc: NetConnection, filename:String ) {
ns = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStreamStatus);
ns.publish(filename, 'record');
ns.attachAudio(mic);
}
To Stop recording/sending:
public function stopSending() {
mic.setLoopBack(false);
ns.attachAudio(null);
ns.close();
}
The resulting .flv stored on server which is currepted.
Not to convert .flv into .mp3, I have used ffmpeg in my Java code as per following:
String ffmpegArgs[] = {executableDir,"-i",flvFile.getAbsolutePath(), "-vn", mp3File.getAbsolutePath()};
Process process = new ProcessBuilder(Arrays.asList(ffmpegArgs)).start();
This starts the file conversion, but it gets stucked. After some time when I stop the server, it immediately shows the converted file. Please let me know, where I am doing wrong.