Results 1 to 2 of 2

Thread: Record stream from command line

  1. #1
    Join Date
    Feb 2014
    Posts
    6

    Default Record stream from command line

    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.appI nstName+",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.appI nstName+",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.

  2. #2

    Default

    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.

Similar Threads

  1. Shut down Wowza in Linux command line
    By olarsson in forum Server Administration Discussion
    Replies: 1
    Last Post: 01-11-2014, 12:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •