Red 5 从直播和 Xuggle 生成 FLV
我使用 Red5 录制用户的直播。我能够将流保存到磁盘并生成一个 FLV 文件。
当我尝试使用某些 FLV 播放器读取 FLV 文件时 - 似乎文件的元数据已损坏 - 这也使进度条表现得很奇怪。
此外,我尝试使用 Xuggle 来播放该文件。这似乎是不可能的,因为生成的 FLV 中没有编解码器 ID。
任何见解将不胜感激。
这是我的相关 Red5 (JAVA) 代码:
public void record(IConnection conn, String streamName)
{
ClientBroadcastStream stream = (ClientBroadcastStream) getBroadcastStream(
conn.getScope(), streamName);
try {
stream.saveAs(streamName, false);
} catch (Exception e) {
System.out.print(e.getMessage());
}
}
public void encodeWithXuggler(IConnection conn, String streamName)
{
String nm = "C:\\Program Files\\Red5\\webapps\\Red5Recorder\\streams\\"+
streamName+".flv";
File f = new File(nm);
if (f.exists()) {
IMediaReader reader = ToolFactory.makeReader(nm);
reader.addListener(ToolFactory.makeWriter("output.mov", reader));
while (reader.readPacket() == null);
} else {
System.out.print("NOT EXiST");
}
}
我得到的 Xuggle 错误消息:
Caused by: java.lang.IllegalArgumentException: null inputCodecId 在 com.xuggle.xuggler.IContainerFormat.builtOutputCodecId(IContainerFormat.java:295) [xuggle-xuggler.jar:3.4.1012] 在 com.xuggle.mediatool.MediaWriter.addStreamFromContainer(MediaWriter.java:1141) [xuggle-xuggler.jar:3.4.1012] 在 com.xuggle.mediatool.MediaWriter.getStream(MediaWriter.java:1046) [xuggle-xuggler.jar:3.4.1012] 在 com.xuggle.mediatool.MediaWriter.encodeAudio(MediaWriter.java:837) [xuggle-xuggler.jar:3.4.1012] 在 com.xuggle.mediatool.MediaWriter.onAudioSamples(MediaWriter.java:1448) [xuggle-xuggler.jar:3.4.1012] 在 com.xuggle.mediatool.AMediaToolMixin.onAudioSamples(AMediaToolMixin.java:89) [xuggle-xuggler.jar:3.4.1012] 在 com.xuggle.mediatool.MediaReader.dispatchAudioSamples(MediaReader.java:628) [xuggle-xuggler.jar:3.4.1012] 在 com.xuggle.mediatool.MediaReader.decodeAudio(MediaReader.java:555) [xuggle-xuggler.jar:3.4.1012] 在 com.xuggle.mediatool.MediaReader.readPacket(MediaReader.java:469) [xuggle-xuggler.jar:3.4.1012]
Im Using Red5 to record live stream from the user. I am able to save the stream to disk and it generates an FLV file.
When I'm trying to read the FLV file with some FLV player - it seems like the file's meta-data is corrupted - which also makes the progress bar to act oddly.
Also, I tried to play with the file using Xuggle. It seems impossible since the generated FLV do not have the codec-id in it.
Any insight will be much appreciated.
Here is my relevant Red5 (JAVA) code:
public void record(IConnection conn, String streamName)
{
ClientBroadcastStream stream = (ClientBroadcastStream) getBroadcastStream(
conn.getScope(), streamName);
try {
stream.saveAs(streamName, false);
} catch (Exception e) {
System.out.print(e.getMessage());
}
}
public void encodeWithXuggler(IConnection conn, String streamName)
{
String nm = "C:\\Program Files\\Red5\\webapps\\Red5Recorder\\streams\\"+
streamName+".flv";
File f = new File(nm);
if (f.exists()) {
IMediaReader reader = ToolFactory.makeReader(nm);
reader.addListener(ToolFactory.makeWriter("output.mov", reader));
while (reader.readPacket() == null);
} else {
System.out.print("NOT EXiST");
}
}
And the Xuggle error message I get:
Caused by: java.lang.IllegalArgumentException: null inputCodecId
at com.xuggle.xuggler.IContainerFormat.establishOutputCodecId(IContainerFormat.java:295) [xuggle-xuggler.jar:3.4.1012]
at com.xuggle.mediatool.MediaWriter.addStreamFromContainer(MediaWriter.java:1141) [xuggle-xuggler.jar:3.4.1012]
at com.xuggle.mediatool.MediaWriter.getStream(MediaWriter.java:1046) [xuggle-xuggler.jar:3.4.1012]
at com.xuggle.mediatool.MediaWriter.encodeAudio(MediaWriter.java:837) [xuggle-xuggler.jar:3.4.1012]
at com.xuggle.mediatool.MediaWriter.onAudioSamples(MediaWriter.java:1448) [xuggle-xuggler.jar:3.4.1012]
at com.xuggle.mediatool.AMediaToolMixin.onAudioSamples(AMediaToolMixin.java:89) [xuggle-xuggler.jar:3.4.1012]
at com.xuggle.mediatool.MediaReader.dispatchAudioSamples(MediaReader.java:628) [xuggle-xuggler.jar:3.4.1012]
at com.xuggle.mediatool.MediaReader.decodeAudio(MediaReader.java:555) [xuggle-xuggler.jar:3.4.1012]
at com.xuggle.mediatool.MediaReader.readPacket(MediaReader.java:469) [xuggle-xuggler.jar:3.4.1012]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最近修复了建立OutputCodecID 的错误,因此您可能想尝试当前的 Xuggler 树提示。
I recently fixed a bug with establishOutputCodecID, so you may want to try the current Xuggler tip of tree.