我正在使用Action Script作为具有Red5 Media Server的客户端。我的视频有2个问题:
我写了以下代码:
private function onStart():void
{
mic = Microphone.getMicrophone();
cam = Camera.getCamera();
if(cam!=null)
{
cam.addEventListener(StatusEvent.STATUS, onDivStatus);
ns.attachCamera(cam)
cam.setQuality( 0, 100 );;
}
else
{
trace("you need to check webcam setting:");
}
if(mic != null)
{
mic.setUseEchoSuppression(true);
mic.setSilenceLevel(5, 1000);
mic.addEventListener(StatusEvent.STATUS, onDivStatus);
ns.attachAudio(mic);
}
else
{
trace("you need to check Microphone setting:");
}
webCamRecording.video1.attachCamera(cam);
webCamRecording.video1.smoothing = true;
}
var timer:Timer;
public function startRecording():void
{
ns.publish(webCamRecording.userName,"record");
webCamRecording.stopBtn.visible = true;
webCamRecording.stopBtn.addEventListener(MouseEvent.CLICK,stopRecording)
timer = new Timer(1000,10*60);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onComplete);
timer.start();
}
private function stopRecording(evt:MouseEvent):void
{
trace("call external function::::::::::::::D>>>>>> ");
timer.stop();
webCamRecording.video1.clear();
ns = null
webCamRecording.video1.visible = false;
}
我检查了日志并找到了以下错误:
java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:236)
at sun.nio.ch.IOUtil.write(IOUtil.java:68)
at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:205)
at org.red5.io.flv.impl.FLVWriter.writeTag(FLVWriter.java:254)
at org.red5.io.flv.impl.FLVWriter.writeMetadataTag(FLVWriter.java:371)
at org.red5.io.flv.impl.FLVWriter.writeTag(FLVWriter.java:226)
at org.red5.server.stream.consumer.FileConsumer.write(FileConsumer.java:333)
at org.red5.server.stream.consumer.FileConsumer.doWrites(FileConsumer.java:292)
at org.red5.server.stream.consumer.FileConsumer$1.run(FileConsumer.java:180)
Exception in thread "Thread-12" java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:236)
at sun.nio.ch.IOUtil.write(IOUtil.java:68)
at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:205)
at org.red5.io.flv.impl.FLVWriter.writeTag(FLVWriter.java:254)
at org.red5.server.stream.consumer.FileConsumer.write(FileConsumer.java:333)
at org.red5.server.stream.consumer.FileConsumer.doWrites(FileConsumer.java:292)
at org.red5.server.stream.consumer.FileConsumer$1.run(FileConsumer.java:180)
Exception in thread "Thread-15" java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:519)
at java.nio.HeapByteBuffer.putInt(HeapByteBuffer.java:366)
at org.apache.mina.core.buffer.AbstractIoBuffer.putInt(AbstractIoBuffer.java:743)
at org.red5.io.flv.impl.FLVWriter.writeTag(FLVWriter.java:251)
at org.red5.server.stream.consumer.FileConsumer.write(FileConsumer.java:333)
at org.red5.server.stream.consumer.FileConsumer.doWrites(FileConsumer.java:292)
at org.red5.server.stream.consumer.FileConsumer$1.run(FileConsumer.java:180)
Exception in thread "Thread-18" java.nio.BufferOverflowException
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:357)
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:336)
at sun.nio.ch.IOUtil.write(IOUtil.java:60)
at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:205)
at org.red5.io.flv.impl.FLVWriter.writeTag(FLVWriter.java:254)
at org.red5.server.stream.consumer.FileConsumer.write(FileConsumer.java:333)
at org.red5.server.stream.consumer.FileConsumer.doWrites(FileConsumer.java:292)
at org.red5.server.stream.consumer.FileConsumer$1.run(FileConsumer.java:180)
Exception in thread "Thread-20" java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:236)
at sun.nio.ch.IOUtil.write(IOUtil.java:68)
at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:205)
at org.red5.io.flv.impl.FLVWriter.writeTag(FLVWriter.java:254)
at org.red5.server.stream.consumer.FileConsumer.write(FileConsumer.java:333)
at org.red5.server.stream.consumer.FileConsumer.doWrites(FileConsumer.java:292)
at org.red5.server.stream.consumer.FileConsumer$1.run(FileConsumer.java:180)
Exception in thread "Thread-34" java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:236)
at sun.nio.ch.IOUtil.write(IOUtil.java:68)
at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:205)
at org.red5.io.flv.impl.FLVWriter.writeTag(FLVWriter.java:278)
at org.red5.server.stream.consumer.FileConsumer.write(FileConsumer.java:333)
at org.red5.server.stream.consumer.FileConsumer.doWrites(FileConsumer.java:292)
at org.red5.server.stream.consumer.FileConsumer$1.run(FileConsumer.java:180)
Exception in thread "Thread-43" java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:236)
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:337)
at sun.nio.ch.IOUtil.write(IOUtil.java:60)
at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:205)
at org.red5.io.flv.impl.FLVWriter.writeTag(FLVWriter.java:278)
at org.red5.server.stream.consumer.FileConsumer.write(FileConsumer.java:333)
at org.red5.server.stream.consumer.FileConsumer.doWrites(FileConsumer.java:292)
at org.red5.server.stream.consumer.FileConsumer$1.run(FileConsumer.java:180)
Exception in thread "Thread-44" java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:236)
at sun.nio.ch.IOUtil.write(IOUtil.java:68)
at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:205)
at org.red5.io.flv.impl.FLVWriter.writeTag(FLVWriter.java:278)
at org.red5.server.stream.consumer.FileConsumer.write(FileConsumer.java:333)
at org.red5.server.stream.consumer.FileConsumer.doWrites(FileConsumer.java:292)
at org.red5.server.stream.consumer.FileConsumer$1.run(FileConsumer.java:180)
Exception in thread "Thread-48" java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:236)
at sun.nio.ch.IOUtil.write(IOUtil.java:68)
at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:205)
at org.red5.io.flv.impl.FLVWriter.writeTag(FLVWriter.java:278)
at org.red5.server.stream.consumer.FileConsumer.write(FileConsumer.java:333)
at org.red5.server.stream.consumer.FileConsumer.doWrites(FileConsumer.java:292)
at org.red5.server.stream.consumer.FileConsumer$1.run(FileConsumer.java:180)
Exception in thread "Thread-65" java.nio.BufferOverflowException
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:357)
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:336)
at sun.nio.ch.IOUtil.write(IOUtil.java:60)
at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:205)
at org.red5.io.flv.impl.FLVWriter.writeTag(FLVWriter.java:254)
at org.red5.server.stream.consumer.FileConsumer.write(FileConsumer.java:333)
at org.red5.server.stream.consumer.FileConsumer.doWrites(FileConsumer.java:292)
at org.red5.server.stream.consumer.FileConsumer$1.run(FileConsumer.java:180)
Exception in thread "Thread-68" java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:236)
at sun.nio.ch.IOUtil.write(IOUtil.java:68)
at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:205)
at org.red5.io.flv.impl.FLVWriter.writeTag(FLVWriter.java:278)
at org.red5.server.stream.consumer.FileConsumer.write(FileConsumer.java:333)
at org.red5.server.stream.consumer.FileConsumer.doWrites(FileConsumer.java:292)
at org.red5.server.stream.consumer.FileConsumer$1.run(FileConsumer.java:180)
Exception in thread "Thread-71" java.nio.BufferOverflowException
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:357)
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:336)
at sun.nio.ch.IOUtil.write(IOUtil.java:60)
at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:205)
at org.red5.io.flv.impl.FLVWriter.writeTag(FLVWriter.java:254)
at org.red5.server.stream.consumer.FileConsumer.write(FileConsumer.java:333)
at org.red5.server.stream.consumer.FileConsumer.doWrites(FileConsumer.java:292)
at org.red5.server.stream.consumer.FileConsumer$1.run(FileConsumer.java:180)
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Close
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Provider disconnect
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Provider disconnect
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Provider disconnect
如果有人有解决方案可以帮助我。感谢。
答案 0 :(得分:1)
根据个人经验,Red5不会录制好录音。
尝试其他服务器,例如具有相同Flash客户端的Wowza Developer Server,看看你是否获得了更好的结果。如果你这样做,那就是Red5问题,并且更容易切换服务器。
您可以通过增加缓冲区并等待缓冲区上传来尝试一些优化。
答案 1 :(得分:0)
Red5 0.9 完全没有录制过程。
Red5 0.8 做得相当不错,但在通过慢速连接进行流式传输/录制时无法解释Flash Player对视频数据的音频优先级。因此,当通过慢速连接录制高质量视频时,最终文件中的音频和视频将不会同步。
Red5 1.0 RC1 引入了一种几乎有效的延迟写入机制。
Red5 1.0 final,1.0.1和1.0.2 延迟写入机制完全有缺陷导致flv文件有1个视频关键帧,其余只有音频通过慢速连接录制。
用于录制的最佳Red5版本是经过修补的Red5 1.0.2 ,可在此博文中找到:Recording high quality (HD) video over slow connections with Red5 is now possible
The patch has also been applied to Red5's source code on GitHub它也将在下一个官方版本中提供(1.0.3)。
我是该补丁的作者,我一劳永逸地修复了Red5录音。它很棒。