# Record stream from command line

**URL:** <https://community.wowza.com/t/record-stream-from-command-line/42090>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [February 27, 2014, 2:02pm UTC](https://community.wowza.com/t/record-stream-from-command-line/42090 "2014-02-27T14:02:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_O\_Rourke](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Mike\_O\_Rourke](https://community.wowza.com/u/Mike_O_Rourke)\
**Post date:** [February 27, 2014, 2:02pm UTC](https://community.wowza.com/t/record-stream-from-command-line/42090/1 "2014-02-27T14:02:31Z")

</div>

Hi.

I am running WowzaStreamingEngine 4.0.0 on a Solaris box. I want to set cron jobs to start and stop streams and recordings.

The part about starting and stopping streams works fine with the JMXCommandLine tool.

The recording part is proving to be a little bit harder. Is the LiveStreamRecordManager module usable from the JMX interface?

I do not want to use the AutoRecord since I want to bring the stream up about 10 to 15 minutes before I start the recording and stop it before I stop the stream.

I have attempted to modify JMXCommandLine.java and here is a diff output of my modifications to JMXCommandLine.java (I called the new file WowzaCTRL.java to keep things separate):

5c5

\< public class JMXCommandLine

* * *

> public class WowzaCTRL

47a48,50

> public static final String CMD\_STARTRECORDING = “startRecording”;

> public static final String CMD\_STOPRECORDING = “stopRecording”;

> 

158a162,164

> System.out.println(" “+CMD\_STARTRECORDING+” [vhost:application/appInstance] [stream-name] [filename]");

> System.out.println(" “+CMD\_STOPRECORDING+” [vhost:application/appInstance] [stream-name]");

> 

518a523,553

> else if (args[argOffset].equalsIgnoreCase(CMD\_STARTRECORDING))

> {

> System.out.println(args[argOffset]+" “+args[argOffset+1]+” “+args[argOffset+2]+” "+args[argOffset+3]);

> 

> AppConextName context = new AppConextName(args[argOffset+1], true);

> 

> String connectsName = MBEANNAME+“:vHosts=VHosts,vHostName=”+context.vhostName+“,applications=Applications,applicationName=”+context.appName+“,applicationInstances=ApplicationInstances,applicationInstanceName=”+context.appInstName+“,name=ApplicationInstance”;

> ObjectName connectsObjName = new ObjectName(connectsName);

> StreamRecorderParameters recordParams = new StreamRecorderParameters(connectsName);

> recordParams.segmentationType = IStreamRecorderConstants.SEGMENT\_NONE;

> recordParams.versioningOption = IStreamRecorderConstants.OVERWRITE\_FILE;

> recordParams.fileFormat = IStreamRecorderConstants.FORMAT\_MP4;

> recordParams.outputFile = args[argOffset+3];

> 

> Object arguments = {args[argOffset+1], args[argOffset+2], recordParams};

> String signature = {“java.lang.String”, “java.lang.String”, “java.lang.Object”};

> doInvoke(connection, connectsObjName, “ILiveStreamRecordManager.startRecording”, arguments, signature);

> }

> else if (args[argOffset].equalsIgnoreCase(CMD\_STOPRECORDING))

> {

> System.out.println(args[argOffset]+" “+args[argOffset+1]+” "+args[argOffset+2]);

> 

> AppConextName context = new AppConextName(args[argOffset+1], true);

> 

> String connectsName = MBEANNAME+“:vHosts=VHosts,vHostName=”+context.vhostName+“,applications=Applications,applicationName=”+context.appName+“,applicationInstances=ApplicationInstances,applicationInstanceName=”+context.appInstName+“,name=ApplicationInstance”;

> ObjectName connectsObjName = new ObjectName(connectsName);

> 

> Object arguments = {args[argOffset+1], args[argOffset+2]};

> String signature = {“java.lang.String”};

> doInvoke(connection, connectsObjName, “ILiveStreamRecordManager.stopRecording”, arguments, signature);

> }

When I try to compile this, the first problem is the argument I use in the “new StreamRecorderParameters()” function (connectsName).

The compiler complains with an “error: cannot find symbol” with a carat under the “e” in “connectsName”.

Another cannot find symbol error puts the carat under the “S” in the second “StreamRecorderParamaters” of that same command.

Finally, there are 3 cannot find symbol errors concerning the “IStreamRecorderConstants” lines.

My first problem (and perhaps solution to the others) is: what argument do I supply for the “new StreamRecorderParameters()” function; since I am not actually **in** any appInstance yet, I cannot use “this.appInstance”; I need to supply a name.

If the LiveStreamRecordManager module is ultimately not accessible from the JMX utility, I guess I will have to use telnet to send http commands, which is not nearly as elegant as using the JMXCommandLine, but would work.

Thanks.

Mike.

---

<div class="post-metadata">

**Author:** ![Roger\_Littin1](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@Roger\_Littin1](https://community.wowza.com/u/Roger_Littin1)\
**Post date:** [February 28, 2014, 10:58am UTC](https://community.wowza.com/t/record-stream-from-command-line/42090/2 "2014-02-28T10:58:37Z")

</div>

Hi Mike,

The way JMX works, you can only send and receive simple values or Objects that are marked as Serializable. ApplicationInstance is not Serializable so you cannot send and receive it using JMX.

For what you are wanting to do, I would suggest creating a simple module that wraps the methods you want to use and make those wrappers available to the JMX interface. Any public methods that only receive or return simple values or do not need or return a value are automatically added to the mbeans for the module instance and will be available via JMX. AppInstances do need to be running for the module instance mbeans to be visible. You can call one of the VHost. touchApplicationInstance methods via JMX to load the appInstance prior to calling your methods

You will then be able to add methods to your JMX class that will work with your wrapper methods.

The reason you are probably getting the compile errors is because you don’t have the Wowza classes available in your class path when compiling. Because you are building something to communicate remotely with wowza then you shouldn’t be compiling against the Wowza classes anyway as these will most likely not be available at runtime anyway.

Roger.
