Results 1 to 6 of 6

Thread: High frequency of writePackets(…) on 3.6.x compared to 3.1.x

  1. #1

    Question High frequency of writePackets(…) on 3.6.x compared to 3.1.x

    Hi!

    I recently upgraded some old Wowza installations from 3.1.1 to 3.6.4 and noticed that the frequency of writePackets() calls to MediaWriterFLV is 10 times higher than before (approx. every 500 ms instead of every 5 sec). Is there an option to lower the frequency/increase the interval of writes to reduce disk IO load?

  2. #2

    Default

    Oh well, I threw together the following hack to somewhat mitigate the problem:

    package foo.bar.baz;
    
    import java.io.*;
    import java.nio.ByteBuffer;
    import java.util.*;
    
    import com.wowza.util.*;
    import com.wowza.wms.stream.*;
    import com.wowza.wms.application.WMSProperties;
    import com.wowza.wms.logging.*;
    import com.wowza.wms.mediawriter.flv.*;
    
    public class BufferedMediaWriterFLV extends MediaWriterFLV {
    	private ArrayList audioPacketsBuffer;
    	private ArrayList videoPacketsBuffer;
    	private ArrayList dataPacketsBuffer;
    
    	private ArrayList audioTCsBuffer;
    	private ArrayList videoTCsBuffer;
    	private ArrayList dataTCsBuffer;
    
    	private ArrayList dataTypesBuffer;
    
    	private long lastWriteTime;
    	private long writeBufferTime;
    
    	public BufferedMediaWriterFLV() {
    		this.audioPacketsBuffer = new ArrayList();
    		this.videoPacketsBuffer = new ArrayList();
    		this.dataPacketsBuffer = new ArrayList();
    
    		this.audioTCsBuffer = new ArrayList();
    		this.videoTCsBuffer = new ArrayList();
    		this.dataTCsBuffer = new ArrayList();
    
    		this.dataTypesBuffer = new ArrayList();
    
    		this.lastWriteTime = 0;
    	}
    
    	public void setParent(IMediaStream parent) {
    		super.setParent(parent);
    
    		WMSProperties properties = parent.getStreams().getAppInstance().getProperties();
    		this.writeBufferTime = properties.getPropertyLong("writeBufferTime", 5000);
    	}
    
    	public void writePackets(List audioPackets, List videoPackets, List dataPackets, List audioTCs, List videoTCs, List dataTCs, List dataTypes, boolean isFirst, boolean isLast) {
    		long currentTime = System.currentTimeMillis();
    		long diffTime = currentTime - lastWriteTime;
    
    		this.audioPacketsBuffer.addAll(audioPackets);
    		this.videoPacketsBuffer.addAll(videoPackets);
    		this.dataPacketsBuffer.addAll(dataPackets);
    
    		this.audioTCsBuffer.addAll(audioTCs);
    		this.videoTCsBuffer.addAll(videoTCs);
    		this.dataTCsBuffer.addAll(dataTCs);
    
    		this.dataTypesBuffer.addAll(dataTypes);
    
    		if (isFirst || isLast || diffTime >= writeBufferTime) {
    			super.writePackets(this.audioPacketsBuffer, this.videoPacketsBuffer, this.dataPacketsBuffer, this.audioTCsBuffer, this.videoTCsBuffer, this.dataTCsBuffer, this.dataTypesBuffer, isFirst, isLast);
    			this.lastWriteTime = currentTime;
    		}
    	}
    
    	private WMSLogger getLogger() {
    		return WMSLoggerFactory.getLogger(BufferedMediaWriterFLV.class);
    	}
    }
    Could use some additional checks but everything related to IMediaWriter is more or less a black box. For instance, the default FLV writer empties the packet Lists. Don't know if it is supposed to do that or not. However, the above code relies on that behavior.

  3. #3
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    I will see what else I can find out about this. I don't think this has changed, it should not be different.

    Richard

  4. #4
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    Hi,

    You're right, this did change. To modify this you can set the recordMinBufferTime Property in the Application.xml /Streams Properties container. The default is 500ms

    <Property>
           <Name>recordMinBufferTime</Name>
           <Value>500</Value>
           <Type>Integer</Type>
    </Property>
    Richard

  5. #5

    Default

    Great! Thank you very much.

  6. #6

    Default

    Hi again!

    I noticed that this property has gone missing in Wowza 3.6.4. It works in Wowza 3.6.3.

    Any chance of a patch for 3.6.4?

Posting Permissions

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