2014-11-16 9 views
0

아래와 같이 웹캠 스트림을 mp4 또는 webm 파일에 기록하는 kerento의 one2many 자습서 (https://github.com/Kurento/kurento-tutorial-java/blob/master/kurento-one2many-call/src/main/java/org/kurento/tutorial/one2manycall/CallHandler.java) 예제를 수정했습니다.kurento : webm 및 mp4 recordendpoint에 웹캠을 기록하는 방법은 무엇입니까?

나는 mp4를 쓰는 RecorderEndpoint를 주석 처리했다.

내 질문은 어떻게 하나의 WebRtcEndpoint에서 두 파일 (webm 및 mp4)을 쓸 수 있습니까? DispatcherOneToMany (http://www.kurento.org/docs/4.2.0/kmf-media-api/com/kurento/kmf/media/DispatcherOneToMany.html)를 사용하는 것에 대해 생각했지만 setSource에 내 WebRtcEndpoint masterWebRtc와 함께 작동하지 않는 HubPort가 필요합니다. 그래서 masterWebRtc를 두 개의 RecorderEndpoint에 디스패치 할 수 있습니까?

도움 주셔서 감사합니다.

private synchronized void master(WebSocketSession session, 
     JsonObject jsonMessage) throws IOException { 
    if (masterUserSession == null) { 
     masterUserSession = new UserSession(session); 

     pipeline = kurento.createMediaPipeline(); 
     masterUserSession.setWebRtcEndpoint(new WebRtcEndpoint.Builder(
       pipeline).build()); 

     WebRtcEndpoint masterWebRtc = masterUserSession.getWebRtcEndpoint(); 
     String sdpOffer = jsonMessage.getAsJsonPrimitive("sdpOffer") 
       .getAsString(); 
     String sdpAnswer = masterWebRtc.processOffer(sdpOffer); 

     JsonObject response = new JsonObject(); 
     response.addProperty("id", "masterResponse"); 
     response.addProperty("response", "accepted"); 
     response.addProperty("sdpAnswer", sdpAnswer); 
     masterUserSession.sendMessage(response); 

     //RecorderEndpoint recorderEndpoint = new RecorderEndpoint.Builder(pipeline,"file:///tmp/recording.mp4").withMediaProfile(MediaProfileSpecType.MP4).build(); 
     RecorderEndpoint recorderEndpoint = new RecorderEndpoint.Builder(pipeline,"file:///tmp/recording.webm").withMediaProfile(MediaProfileSpecType.WEBM).build(); 
     masterWebRtc.connect(recorderEndpoint); 
     recorderEndpoint.record(); 

    } else { 
     JsonObject response = new JsonObject(); 
     response.addProperty("id", "masterResponse"); 
     response.addProperty("response", "rejected"); 
     response.addProperty("message", 
       "Another user is currently acting as sender. Try again later ..."); 
     session.sendMessage(new TextMessage(response.toString())); 
    } 
} 

답변

1

모든 미디어 요소는 원본 미디어 요소를 원하는만큼의 싱크 미디어 요소에 연결할 수 있음을 의미하는 "일대 다"형식입니다. 다음 코드를 작성하십시오 :

RecorderEndpoint recorderEndpointA = new RecorderEndpoint.Builder(pipeline,"file:///tmp/recording.mp4").withMediaProfile(MediaProfileSpecType.MP4).build(); 
RecorderEndpoint recorderEndpointB = new RecorderEndpoint.Builder(pipeline,"file:///tmp/recording.webm").withMediaProfile(MediaProfileSpecType.WEBM).build(); 

masterWebRtc.connect(recorderEndpointA); //masterWebRtc is source, recorderEndpointA is sink 
masterWebRtc.connect(recorderEndpointB); //masterWebRtc is source, recorderEndpointB is sink 

//you could connect masterWebRtc to other additional elements here if you want. 

recorderEndpointA.record(); 
recorderEndpointB.record(); 
+0

감사합니다. 내 문제 중 하나는 나중에 내 테스트에서 .withMediaProfile (MediaProfileSpecType.MP4)을 추가했다는 것입니다. 즉, 기본적으로 MediaProfileSpecType을 사용하지 않으면 kurento가 파일 확장명이 mp4인데도 webm 내용을 저장합니다. 이유는 모르겠지만 인코딩이 파일 확장명에 달려 있다고 생각합니다. 내 잘못이야. –

관련 문제