public ImageToMJPEGMOVMuxer(SeekableByteChannel ch, AudioFormat af, int framesPerSecond)
      throws IOException {

    this.ch = ch;
    this.af = af;
    this.framesPerSecond = framesPerSecond;

    // Muxer that will store the encoded frames
    muxer = new WebOptimizedMP4Muxer(ch, Brand.MP4, 4096 * 4);

    // Add video track to muxer
    videoTrack = muxer.addTrack(TrackType.VIDEO, framesPerSecond);
    muxer.addTimecodeTrack(framesPerSecond);
    videoTrack.setTgtChunkDuration(new Rational(3, 1), Unit.SEC);

    if (af != null) audioTrack = muxer.addPCMAudioTrack(af);
  }