Results 1 to 4 of 4

Thread: How to record only one segment of certain duration?

  1. #1
    Join Date
    Mar 2013

    Default How to record only one segment of certain duration?

    Hi everybody. I am new to Wowza and I've been struggling with some issues. I need to tell Wowza the following:
    - start a stream
    - start recording the stream and only output one segment of X seconds (the resulting file path and name should be given as parameters and not hardcoded)
    - stop the stream

    What I managed to do so far:

    I've build the following HTTPProvider :

    package com.mycompany.wms.http;

    import com.wowza.wms.application.IApplication;
    import com.wowza.wms.application.IApplicationInstance;
    import com.wowza.wms.http.*;
    import com.wowza.wms.logging.*;
    import com.wowza.wms.vhost.*;

    public class MyHTTPProvider extends HTTProvider2Base {
    public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
    if (!doHTTPAuthentication(vhost, req, resp))

    String resultStr = "";

    String appInstance = req.getParameter("appInstance");
    String stream = req.getParameter("stream");

    IApplication app = vhost.getApplication("capture");
    IApplicationInstance appInst = app.getAppInstance(appInstance);

    if (appInst.startMediaCasterStream(stream, "rtp")) {
    resultStr = "<font color='green'>Stream started succesfully!</font>";
    } else {
    resultStr = "<font color='red'>Error starting stream!</font>";

    String retStr = "<html><head></head><body>" + resultStr + "</body></html>";

    try {
    OutputStream out = resp.getOutputStream();
    byte[] outBytes = retStr.getBytes();
    } catch (Exception e) {
    WMSLoggerFactory.getLogger(null).error("MyHTTPProvider: " + e.toString());
    I call this with a URL like this:
    And the stream starts properly.

    Then I have the following module:

    package com.mycompany.wms.module;

    import com.wowza.wms.application.*;
    import com.wowza.wms.livestreamrecord.model.LiveStreamRecorderMP4;
    import com.wowza.wms.module.*;
    import com.mycompany.wms.listener.MyListener;

    public class MyModule extends ModuleBase {
    private IApplicationInstance applicationInstance;

    public void onAppStart(IApplicationInstance appInstance) {
    this.applicationInstance = appInstance;

    public void onStreamCreate(IMediaStream stream) {
    MyListener myListener = new MyListener(this.applicationInstance, stream);

    LiveStreamRecorderMP4 recorder = new LiveStreamRecorderMP4();
    recorder.startRecordingSegmentByDuration(stream, "/opt/test/" + "fileName" + ".mp4", null, 60000);
    The purpose of the module is to start recording of the live stream, right after the stream is created. The recording starts properly.
    Then I have the following listener:

    package com.mycompany.wms.listener;

    import com.wowza.wms.application.IApplicationInstance;
    import com.wowza.wms.livestreamrecord.model.ILiveStreamRecord;
    import com.wowza.wms.livestreamrecord.model.ILiveStreamRecordNotify;

    public class MyListener implements ILiveStreamRecordNotify {
    private IApplicationInstance applicationInstance;
    private IMediaStream stream;

    public MyListener(IApplicationInstance applicationInstance, IMediaStream stream) { = stream;
    this.applicationInstance = applicationInstance;

    public void onSegmentEnd(ILiveStreamRecord recorder) {

    public void onSegmentStart(ILiveStreamRecord recorder) {

    The listener role si to "kill" the recording right after the first segment is done. Recording is stopped properly.

    No the questions:

    1. Look at the hardcoded values of the resulting file path, name and duration (red coloured). I need to pass those values from the HTTPProvider but I have no ideea how to accomplish this. I would get them in the HTTPProvider as parameters in the query string but I don't know how to pass them further to the module.

    2. Could it be a simpler approach to what I want to achieve? I feel like I overcomplicated things. Would you suggest a better approach?

    Thank you,

  2. #2
    Join Date
    Dec 2007



    You can do this easily with the HTTPLiveStreamRecord


  3. #3
    Join Date
    Mar 2013



    Thanks for your suggestion. That document was one of the firsts I've read regarding live recording. But it doesn't help me much because I don't need to manually start a stream, then start recording, then pay attention to the recorded segments in order to stop recording after the first segment has finished, then stop the stream. I need to perform all these actions in one shot. I need one URL with the following params:
    - stream name
    - application name (this could be hardcoded actually)
    - recording duration
    - output filename and path

    Calling this should have the following result:
    - create an instance of the application
    - start the above stream
    - record one segment only with the above duration
    - stop recording
    - stop the stream
    - close the application instance

    All in one shot (one call to Wowza, be it an URL or another way). I would call Wowza this way from an external Java application. No flash client in the browser and no user clicks in the browser.

    Any suggestions?

  4. #4
    Join Date
    Dec 2007



    Take a look at the "Recording live streams using URL queries" section of that article. That is how to do what you describe


Similar Threads

  1. Record and Segment Live Streams by Default
    By stratus in forum Live Streaming and Encoders
    Replies: 13
    Last Post: 10-08-2015, 06:39 AM
  2. Start Recording Segment By Duration has a problem?
    By tujixx in forum Live Streaming and Encoder Discussion
    Replies: 2
    Last Post: 02-01-2014, 01:09 AM
  3. How to get recording segment duration at onWriteComplete()
    By spiritsoul in forum Live Streaming and Encoder Discussion
    Replies: 7
    Last Post: 08-19-2013, 07:39 PM
  4. Live stream recording using recorder segment duration setter
    By sam.shm in forum Live Streaming and Encoder Discussion
    Replies: 0
    Last Post: 01-31-2013, 01:06 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