将以下代码添加到 red5 应用程序中的 Application 类。它具有开始录制,将录制保存到磁盘和停止的代码。
/*
*Start the recording
*/
public void recordVideo() {
IConnection conn = Red5.getConnectionLocal();
//get the stream published by the id "publishId"
ClientBroadcastStream stream = (ClientBroadcastStream) getBroadcastStream(conn.getScope(), "publishId");
try {
// Save the stream to disk.
stream.saveAs("streamName", false);
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
/*
*Stop the recording
*/
public void stopRecording(){
IConnection conn = Red5.getConnectionLocal();
ClientBroadcastStream stream = (ClientBroadcastStream) getBroadcastStream(conn.getScope(), "publishId");
// Stop recording.
stream.stopRecording();
stream.stop();
}
JUV RTMP是一个用于 RTMP 协议的 java 客户端。但它不提供任何用于音频/视频流的编解码器:
播放和发布音频/视频流(由服务器支持)(不包括!音频/视频编解码器实现!)