Search code examples
javavideo-streamingwowzavideo-recording

Wowza ModuleLiveStreamRecord null pointer exception


I have downloaded the LiveStreamRecord library and I have tried to use the example given with the library and it works fine. Now what I want to do is, I want to start the recording of a specific stream using the webservice.

I have written the wowza webservice and it works fine except the recording. When I put the following code to start the recording of a specific stream, It throws NULL POINTER EXCEPTION. The code snippet is given below. Please let me know how to overcome this issue.

Code :

String streamname="12";
ModuleLiveStreamRecord lsr=new ModuleLiveStreamRecord();
lsr.recordStream(streamname, 1, true, "", true, true, true);

The error obtained.

ERROR server comment - invoke(onStreamCreate): java.lang.NullPointerException: com.wowza.wms.plugin.livestreamrecord.ModuleLiveStreamRecord.recordStream(ModuleLiveStreamRecord.java:28)
java.lang.NullPointerException
    at com.wowza.wms.plugin.livestreamrecord.ModuleLiveStreamRecord.recordStream(ModuleLiveStreamRecord.java:28)
    at com.media.modules.OnlineVideoStream.onStreamCreate(OnlineVideoStream.java:128)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.wowza.wms.module.ModuleFunction.invoke(Unknown Source)
    at com.wowza.wms.module.ModuleFunctions.a(Unknown Source)
    at com.wowza.wms.module.ModuleFunctions.onStreamCreate(Unknown Source)
    at com.wowza.wms.stream.MediaStreamMap.getStream(Unknown Source)
    at com.wowza.wms.module.ModuleCore.createStream(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.wowza.wms.module.ModuleFunction.invoke(Unknown Source)
    at com.wowza.wms.module.ModuleFunctions.invoke(Unknown Source)
    at com.wowza.wms.request.RequestProcessFunctions.processFunctions(Unknown Source)
    at com.wowza.wms.client.ClientWorker.processNextReq(Unknown Source)
    at com.wowza.wms.request.RTMPRequestAdapter.service(Unknown Source)
    at com.wowza.wms.server.ServerHandler.a(Unknown Source)
    at com.wowza.wms.server.ServerHandler.a(Unknown Source)
    at com.wowza.wms.server.ServerHandler.messageReceived(Unknown Source)
    at com.wowza.wms.server.ServerHandlerThreadedSession.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

I tried to figureout the issue for two days and could not find where it went wrong. But the flash example is working perfectly without any errors.

If I'm using the wrong library please do suggest me the correct code sample to use for this kind of operation.

Thanks.


Solution

  • I am not sure what you mean by "start the recording of a specific stream using the webservice". Using the built-in http provider here http://www.wowza.com/forums/content.php?123 will allow you to make post requests to the Wowza server to start and stop recording. If you want to create your own Wowza module that records a particular stream, you'll need to reference wms-plugin-integrationrecord.jar. Below is an example:

    LiveStreamRecorderMP4 recorder = new LiveStreamRecorderMP4();
     recorder.setRecordData(true);
     // Set to true if you want to version the previous file rather than overwrite it
     recorder.setVersionFile(true);
     // If recording only audio set this to false so the recording starts immediately
     recorder.setStartOnKeyFrame(true);
     boolean append = false;    
     //stream is a valid IMediaStream retrieved from Wowza API, outputPath a string 
     recorder.startRecording(stream, outputPath, append);