gpt4 book ai didi

Kurento 录音不记录任何数据

转载 作者:行者123 更新时间:2023-12-04 02:17:09 26 4
gpt4 key购买 nike

我正在学习 one2many 调用教程、one2many 调用高级教程和 hello-world 录音,但我的录音似乎无法正常工作。它创建了文件,但它始终是 382 字节,没有可播放的内容。没有抛出任何错误,浏览器和应用服务器之间的通信也没有失败。

这是处理初始录制请求的代码:

       //1. Media logic
BroadcastPipeline broadcastPipeline = new BroadcastPipeline(kurento, "test-broadcast");

//2. User session
broadcasterUserSession = new UserSession(session);
broadcasterUserSession.setWebRtcEndpoint(broadcastPipeline.getWebRtcEndpoint());

//3. SDP negotiation
String broadcastSdpOffer = jsonMessage.get("sdpOffer").getAsString();
String broadcastSdpAnswer = broadcastPipeline.generateSdpAnswerForBroadcaster(broadcastSdpOffer);

//4. Gather ICE candidates
broadcastPipeline.getWebRtcEndpoint().addOnIceCandidateListener(
new EventListener<OnIceCandidateEvent>() {

@Override
public void onEvent(OnIceCandidateEvent event) {
JsonObject response = new JsonObject();
response.addProperty("id", "iceCandidate");
response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
try {
synchronized (session) {
session.sendMessage(new TextMessage(response.toString()));
}
} catch (IOException e) {
log.debug(e.getMessage());
}
}
});

JsonObject startBroadcast = new JsonObject();

startBroadcast.addProperty("id", "broadcasterResponse");
startBroadcast.addProperty("response", "accepted");
startBroadcast.addProperty("sdpAnswer", broadcastSdpAnswer);

synchronized (broadcasterUserSession){
session.sendMessage(new TextMessage(startBroadcast.toString()));
}

broadcastPipeline.getWebRtcEndpoint().gatherCandidates();

broadcastPipeline.startRecording();

UserSession 几乎与 hello-world-recording 相同。 BroadcastMediaPipeline 然而看起来像这样:

public static final String RECORDING_PATH = "file:///tmp/";
public static final String RECORDING_EXT = ".webm";

private final MediaPipeline mediaPipeline;
private final WebRtcEndpoint webRtcEndpoint;
private final RecorderEndpoint recorderEndpoint;

public BroadcastPipeline(KurentoClient kurento, String broadcastTitle){
log.info("Creating Broadcast pipeline");

//Create the media pipeline
mediaPipeline = kurento.createMediaPipeline();

//Create the broadcaster pipeline
webRtcEndpoint = new WebRtcEndpoint.Builder(mediaPipeline).build();

//Create the recording endpoint for the broadcast
recorderEndpoint = new RecorderEndpoint.Builder(mediaPipeline, RECORDING_PATH + broadcastTitle + RECORDING_EXT).build();

webRtcEndpoint.connect(recorderEndpoint);
}

public void startRecording(){
try{
recorderEndpoint.record();
log.info("Started recording broadcast");
}
catch(Exception e){
log.error("Something bad happended: + " + e.getMessage());
}
}
public MediaPipeline getMediaPipeline(){
return mediaPipeline;
}

public String generateSdpAnswerForBroadcaster(String sdpOffer){
return webRtcEndpoint.processOffer(sdpOffer);
}

public WebRtcEndpoint getWebRtcEndpoint(){
return webRtcEndpoint;
}

public WebRtcEndpoint buildViewerEndpoint(){
return (new WebRtcEndpoint.Builder(mediaPipeline).build());
}

如果需要更多信息来帮助解决此问题,我会提供。

最佳答案

为了正确生成记录器文件,您需要停止记录或释放记录器端点。我没有在您的代码中看到这种情况。

要修复它,当您完成录制(例如使用完成按钮或类似的东西)时,您需要执行以下操作之一

recorderEndpoint.stop(); //this stops the recording
recorderEndpoint.release(); //this stops recording when releasing the recorder
mediaPipeline.release(); //this relases all the pipeline, including recorder

关于Kurento 录音不记录任何数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33160648/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com