Question

I'm absolute beginner in RTMP. My task is to create a Java application which would record video from a certain RTMP URL.

I have an RTMP Server installed (Red5 server). I've verified that it works and streams fine. I have red5.jar providing me with all those Java classes which should be used to communicate with Red5 (as I understand).

I'm fairly proficient with Java but have no idea how to approach that recording application. Because no sample and no docs apart from Red5 Javadoc.

So, please, help me by giving any sample or any links or guidance. I can not use Flash or anything but Java.

Was it helpful?

Solution

Add the code below to your Application class in your red5 app. It has the codes to start recording, save the recording to the disk and stop.

/*
*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 is a java client for RTMP protocol. But it doesn't offer any codec for audio/video streaming:

Play and publish audio/video streams (supported by the server) (!audio/video codec implementations are not included!)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top