Red5视频流录制正在分手 [英] Red5 video stream recording is breaking up
问题描述
最后我创建了一个流视频录制器Flash应用程序及其简单的Red5后端,但当然Red5再次开玩笑。大多数情况下录制的视频都已损坏,无法随意停止播放,播放播放器以及我也无法播放。为什么要这样做?
Finally I created a stream video recorder flash application and its simple Red5 backend but of course Red5 jokes me again. Most of the times the recorded videos are corrupted, cannot play them back without randomly stopping-resuming, hanging out the player .. and me as well. Why is it doing this?
我研究了互联网,发现了这个问题,但没有解决方案!我尝试不录制视频而是将其切换为live并附加ffmpeg来执行脏作业,但自然ffmpeg无法连接red5输出上的以下错误消息:
I researched the internet and found this issue but no solution! I tried not to record the video instead switch it to live and attach an ffmpeg to do the dirty job but naturally the ffmpeg couldn't connect with the following error message on the red5's output:
执行调用时出错:服务:null方法:播放Num Params:1 0:my_little_stream ... blabla bla
Error executing call: Service: null Method: play Num Params: 1 0: my_little_stream ... blabla bla
在我尝试整合 Xuggler 之前我真正喜欢的东西我想问你,做什么,我可以以某种方式附加ffmpeg,或者我应该更改red5服务器中的配置..或者其他任何东西!谢谢!
Before I try out integrating the Xuggler stuff what I truly don't want to I ask you, what to do, can I attach the ffmpeg somehow or is there a configuration in the red5 server I should change.. or anything! Thanks!
编辑:我正在使用Red5 1.0 RC2
Edit: I'm using Red5 1.0 RC2
编辑#2 :我使用red5 1.0.0rc2服务器文件从主干源编译了oflaDemo应用程序,然后使用简单的flex应用程序创建了一个实时流,以便尝试ffmpeg刻录机工作。现在它可以连接到red5,但结果是一样的!视频似乎已损坏...
Edit#2: I compiled the oflaDemo app from trunk sources with red5 1.0.0rc2 server files then created a live stream with a simple flex app just to try out if ffmpeg recorder worked. Now it could connect to red5 but the result is the same! The videos seems to be corrupt...
推荐答案
*但我应该将什么放入packetReceived()函数? *
*But what should I put into the packetReceived() function? *
我将其添加到单独的答案中以正确突出显示:
I add this in a separated answer to highlight correctly:
要将数据包写入磁盘,需要:
1)数据包,
2)将数据包转换为ITag
3)获取ITagWriter实例
To write the packets to disk, you need: 1) the packet, 2) convert the packet to an ITag 3) Obtain an instance of a ITagWriter
1)分组数据
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/flvrecord/listener/StreamVideoListener.java? view = markup $ 50 $ b在第50行附近
1) the packet data http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/flvrecord/listener/StreamVideoListener.java?view=markup around Line 50
public void packetReceived(IBroadcastStream broadcastStream,
IStreamPacket streampacket) {
}
streampacket =>你要写的包到磁盘。
streampacket => the packet you want to write to disk.
2)通过将数据包转换为ITag来写入数据包
2) write the packet by converting it to a ITag
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/flvrecord/listener/async/StreamVideoWriter.java?view=markup around Line 90ff
IoBuffer data = streampacket.getData().asReadOnlyBuffer();
if (data.limit() == 0) {
return;
}
if (startTimeStamp == -1) {
// That will be not bigger then long value
startTimeStamp = streampacket.getTimestamp();
}
timeStamp -= startTimeStamp;
ITag tag = new Tag();
tag.setDataType(streampacket.getDataType());
// log.debug("data.limit() :: "+data.limit());
tag.setBodySize(data.limit());
tag.setTimestamp(timeStamp);
tag.setBody(data);
writer.writeTag(tag);
3)获取作家的实例
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/flvrecord/listener/async/BaseStreamWriter.java?view=markup around Line 90ff
protected ITagWriter writer = null;
private void init() throws IOException {
file = new File(OmFileHelper.getStreamsSubDir(this.scope.getName()), this.streamName + ".flv");
IStreamableFileFactory factory = (IStreamableFileFactory) ScopeUtils
.getScopeService(this.scope, IStreamableFileFactory.class,
StreamableFileFactory.class);
if (!this.file.isFile()) {
// Maybe the (previously existing) file has been deleted
this.file.createNewFile();
} else if (!file.canWrite()) {
throw new IOException("The file is read-only");
}
IStreamableFileService service = factory.getService(this.file);
IStreamableFile flv = service.getStreamableFile(this.file);
this.writer = flv.getWriter();
}
所以这是一个粗略的步骤。从那个意义上说,你可以继续。
So this is a rough walk through. In that sense you can then go ahead.
class还包含一个队列收集数据包。
class also contains a Queue to collect the packets.
IStreamPacket.getType == 9是视频,我认为8是音频(但你需要验证)。
IStreamPacket.getType == 9 is video and I think 8 is audio (but you need to verify that).
Sebastian
Sebastian
这篇关于Red5视频流录制正在分手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!