this method splits a video into n chunks defined by the frames array.
$frames = array(array(0, 12), array(13, 110), array(111, 200));
ffmpeg -i quickns.mov -an -vf "select=between(n\,110\,200),setpts=PTS-STARTPTS" grg.mov
11437
public function splitVideo($source, $frames, $target)
    {
        if (empty($frames)) {
            $frames = array();
        }
        $this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false);
        
        $i=1;
        foreach ($frames as $frame) {
            $this->serviceLocator->get('playgroundcore_phpvideotoolkit')
                ->addPreInputCommand('-y')
                ->addCommand('-i', $source)
                ->addCommand('-an')
                ->addCommand('-vf', 'select=between(n\,' . $frame[0] . '\,' . $frame[1] . '),setpts=PTS-STARTPTS')
                ->setOutputPath($target . sprintf('s%02d', $i) . '.mov')
                ->execute();
            $i++;
        }

        return $target;
    }
486983
Object[] mosim(double S[][], double SF[][], int SR[], int n, double minn[], double maxn[]) {
        int lenS = S[0].length;
        int lenSF = SF[0].length;

//        int e = S.length;
        int r = lenS + lenSF + 1;
        // Define Simplex .. Simplex = [S SF SR];
        double Simplex[][] = new double[S.length][lenS + lenSF + 1];

        for (int i = 0; i < S.length; i++) {
            for (int j = 0; j < lenS; j++) {
                Simplex[i][j] = S[i][j];
            }
            for (int j = 0; j < lenSF; j++) {
                Simplex[i][lenS + j] = SF[i][j];
            }
            Simplex[i][lenS + lenSF] = (double) SR[i];
        }
        // Sort Simplex
        sort(Simplex, r - 1);
        //Assing function values for worst point in Simplex
        double Fw[] = new double[lenSF];
        for (int i = 0; i < lenSF; i++) {
            Fw[i] = Simplex[Simplex.length - 1][n + i];
        }
        // Assing parameter values worst ranked point in Simplex
        double Sw[] = new double[n];
        for (int i = 0; i < n; i++) {
            Sw[i] = Simplex[Simplex.length - 1][i];
        }
        double Sg[] = new double[n];
        // Compute centroid of Simplex after excluding the worst ranked point
        for (int i = 0; i < n; i++) {
            Sg[i] = 0;
            for (int j = 0; j < Simplex.length - 1; j++) {
                Sg[i] += Simplex[j][i];
            }
            Sg[i] /= (double) (Simplex.length - 1);
        }
        // Compute Reflection step
        double Sref[] = new double[n];
        for (int i = 0; i < n; i++) {
            Sref[i] = 2 * Sg[i] - Sw[i];
        }
        boolean accept = isSampleValid(Sref);
        double Snew[], Fnew[];
        if (!accept) {
            // Compute contraction step
            double Scon[] = new double[n];
            for (int i = 0; i < n; i++) {
                Scon[i] = 0.5 * Sg[i] + 0.5 * Sw[i];
            }
            accept = isSampleValid(Scon);
            //if it fails again, try a mutation
            while (!accept) {
                double newpar[][] = lhsu(this.lowBound, this.upBound, 1);
                Scon = newpar[0];
                accept = isSampleValid(Scon);
            }
            double Fcon[] = compob(Scon);
            Snew = Scon;
            Fnew = Fcon;
        // Update number of function evaluations
        } else {
            // Compute corresponding objective function values
            double Fref[] = compob(Sref);
            double SimplexTmp[][] = new double[Simplex.length][lenSF];
            for (int j = 0; j < lenSF; j++) {
                for (int i = 0; i < Simplex.length - 1; i++) {
                    SimplexTmp[i][j] = Simplex[i][n + j];
                }
                SimplexTmp[Simplex.length - 1][j] = Fref[j];
            }
            // Test for non dominance
            Object ret[] = parrank(SimplexTmp, 2); // 2 ist possible wrong
            int Rref[] = (int[]) ret[0];

            int Rrefmax = Integer.MIN_VALUE;
            for (int i = 0; i < Rref.length - 1; i++) {
                if (Rref[i] > Rrefmax) {
                    Rrefmax = Rref[i];
                }
            }
            if (Rref[Rref.length - 1] <= Rrefmax) {
                Snew = Sref;
                Fnew = Fref;
            } else {
                // Compute contraction step
                double Scon[] = new double[n];
                for (int i = 0; i < n; i++) {
                    Scon[i] = 0.5 * Sg[i] + 0.5 * Sw[i];
                }
                accept = isSampleValid(Scon);
                //if it fails again, try a mutation
                while (!accept) {
                    double newpar[][] = lhsu(this.lowBound, this.upBound, 1);
                    Scon = newpar[0];
                    accept = isSampleValid(Scon);
                }
                // Compute corresponding objective function values
                double Fcon[] = compob(Scon);
                Snew = Scon;
                Fnew = Fcon;
            }
        }
        for (int i = 0; i < n; i++) {
            S[S.length - 1][i] = Snew[i];
        }
        for (int i = 0; i < SF[0].length; i++) {
            SF[SF.length - 1][i] = Fnew[i];
        }
        return new Object[]{S, SF};
    }
230536
static Frame toFrame(Matrix m, Key key) {
    final int log_rows_per_chunk = Math.max(1, FileVec.DFLT_LOG2_CHUNK_SIZE - (int) Math.floor(Math.log(m.cols()) / Math.log(2.)));
    Vec v[] = new Vec[m.cols()];
    for (int i = 0; i < m.cols(); ++i) {
      v[i] = makeCon(0, m.rows(), log_rows_per_chunk);
    }
    Frame f = new FrameFiller(m).doAll(new Frame(key, v, true))._fr;
    DKV.put(key, f);
    return f;
  }
562912
function split (data, w, h) {
  var colors = {};

  var pos = 0;

  for (var y = 0; y < h; ++y) {
    for (var x = 0; x < w; ++x) {
      pos = (y * w + x) * 4;
      if (data[pos + 3] > 0) {
        set(x, y, data[pos], data[pos + 1], data[pos + 2]);
      }
    }
  }

  return {
    w: w,
    h: h,
    colors: colors
  };

  function set (x, y, r, g, b) {
    var hex = "#" + [r, g, b].map(hexaze).join("");

    if (!colors[hex]) {
      colors[hex] = new Array(h);

      for (var i = 0; i < h; ++i) {
        colors[hex][i] = new Uint8Array(w);
      }
    }

    colors[hex][y][x] = 1;
  }
}
1365984
public function parseFromArray()
    {
        $this->chunk = '';
        // read the length byte
        $length = $this->reader->next();
        // just take the splice from this array
        $this->childParseFromArray($length);
    }
551381
public function createVideoFromImages($path = 'data/etape*.jpg', $target = false, $framerate = '25', $fps = 25)
    {
        try {
            // don't want this service to be a singleton. I have to reset the ffmpeg parameters for each call.
            $this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false);

            $this->serviceLocator->get('playgroundcore_phpvideotoolkit')
            ->addPreInputCommand('-y')
            ->addPreInputCommand('-framerate', $framerate)
            ->addPreInputCommand('-pattern_type', 'glob')
            ->addCommand('-i', $path)
            ->addCommand('-c:v', 'libx264')
            ->addCommand('-vf', 'fps='. $fps)
            ->addCommand('-pix_fmt', 'yuv420p')
            ->setOutputPath($target)
            ->execute();
        } catch (FfmpegProcessOutputException $e) {
            throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos');
        } catch (\PHPVideoToolkit\Exception $e) {
            throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos');
        }

        return $target;
    }
747181
public function shiftFrame()
    {
        $this->loadFrames();

        if (empty($this->frames)) {
            throw new \RuntimeException('No more IdFrames?');
        }
        return array_shift($this->frames);
    }
440915
def __init_ffmpeg(self, image_shape):
    """"""
    import itertools  # pylint: disable=g-import-not-at-top
    from subprocess import Popen, PIPE  # pylint: disable=g-import-not-at-top,g-multiple-import,g-importing-member
    ffmpeg = "ffmpeg"
    height, width, channels = image_shape
    self.cmd = [
        ffmpeg, "-y",
        "-f", "rawvideo",
        "-vcodec", "rawvideo",
        "-r", "%.02f" % self.fps,
        "-s", "%dx%d" % (width, height),
        "-pix_fmt", {1: "gray", 3: "rgb24"}[channels],
        "-i", "-",
        "-filter_complex", "[0:v]split[x][z];[x]fifo[w];[z]palettegen,fifo[y];"
                           "[w][y]paletteuse,fifo",
        "-r", "%.02f" % self.fps,
        "-f", self.file_format,
        "-qscale", "0",
        "-"
    ]
    self.proc = Popen(
        self.cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, bufsize=-1
    )
    (self._out_thread, self._err_thread) = itertools.starmap(
        self._start_reader_thread, [
            (self.proc.stdout, self._out_chunks),
            (self.proc.stderr, self._err_chunks)
        ]
    )
276150
def framesToFrameRanges(frames, zfill=0):
        
        _build = FrameSet._build_frange_part
        curr_start = None
        curr_stride = None
        curr_frame = None
        last_frame = None
        curr_count = 0
        for curr_frame in frames:
            if curr_start is None:
                curr_start = curr_frame
                last_frame = curr_frame
                curr_count += 1
                continue
            if curr_stride is None:
                curr_stride = abs(curr_frame-curr_start)
            new_stride = abs(curr_frame-last_frame)
            if curr_stride == new_stride:
                last_frame = curr_frame
                curr_count += 1
            elif curr_count == 2 and curr_stride != 1:
                yield _build(curr_start, curr_start, None, zfill)
                curr_start = last_frame
                curr_stride = new_stride
                last_frame = curr_frame
            else:
                yield _build(curr_start, last_frame, curr_stride, zfill)
                curr_stride = None
                curr_start = curr_frame
                last_frame = curr_frame
                curr_count = 1
        if curr_count == 2 and curr_stride != 1:
            yield _build(curr_start, curr_start, None, zfill)
            yield _build(curr_frame, curr_frame, None, zfill)
        else:
            yield _build(curr_start, curr_frame, curr_stride, zfill)
1065018
function PC2Parser () {
  Dissolve.call(this)

  // Read header(32 bytes)
  this.string('cacheSignatureString', 11).tap(checkEqual('cacheSignatureString', 'POINTCACHE2'))
  this.uint8('zero').tap(checkEqual('zero', 0))
  this.uint32le('fileVersion').tap(checkEqual('fileVersion', 1))
  this.uint32le('numPoints') // Number of points per sample
  this.floatle('startFrame') // First sampled frame
  this.floatle('sampleRate') // How frequently to sample (or skip) the frames
  this.uint32le('numSamples') // How many samples are stored in this file

  // Read raw data for positions
  this.tap(function () {
    this.vars.numFrames = this.vars.numSamples / this.vars.sampleRate
    this.buffer('raw', this.vars.numFrames * this.vars.numPoints * 12)
  })

  // Organize positions as nested, anonymous arrays
  // (could not do it with "loop")
  this.tap(function () {
    var raw = this.vars.raw
    delete this.vars.raw

    // "for frame in range(startFrame, startFrame+numSamples, sampleRate)"
    this.vars.frames = []
    for (var idx = 0; idx < this.vars.numFrames; idx++) {
      this.vars.frames.push(pointsArray(raw, idx * this.vars.numPoints * 12, this.vars.numPoints))
    }
  })

  // Read from buffer "buf", starting at position "offset", an array of "numPoints" positions (arrays of 3 floats)
  function pointsArray (buf, offset, numPoints) {
    var pointsData = []
    for (var i = offset; i < offset + numPoints * 12; i += 12) {
      pointsData.push([buf.readFloatLE(i + 0), buf.readFloatLE(i + 4), buf.readFloatLE(i + 8)])
    }
    return pointsData
  }

  // Emit result ("this" is a Transform stream)
  this.tap(function () {
    this.push(this.vars)
  })
}
1149747
static Frame toFrame(Vector v, Key key) {
    final int log_rows_per_chunk = Math.max(1, FileVec.DFLT_LOG2_CHUNK_SIZE - (int) Math.floor(Math.log(1) / Math.log(2.)));
    Vec vv = makeCon(0, v.size(), log_rows_per_chunk, false /* no rebalancing! */);
    Frame f = new Frame(key, new Vec[]{vv}, true);
    try( Vec.Writer vw = f.vecs()[0].open() ) {
      for (int r = 0; r < v.size(); ++r)
        vw.set(r, v.get(r));
    }
    DKV.put(key, f);
    return f;
  }
512551
function( num ) {
		var n = new Buffer(4);
		if (SAFE) { if (num == 0.0) { }
		else if ((Math.abs(num) < FLOAT32_SMALL) || (num < FLOAT32_NEG) || (num > FLOAT32_POS)) 
			throw new Errors.PackError('Packing float bigger than 32-bits ('+num+')!');
		}
		packViewF32[0] = num;
		for (var i=0; i<4; ++i) n[i]=packViewU8[i];
		return n;
	}
727818
def from_array(cls, array, filename=None, channels=3, scale_to_range=False,
                   grayscale=False, channel_bitdepth=8,
                   has_alpha=False, palette=None):
        
        if scale_to_range:
            amax = array.max()
            amin = array.min()
            _array = (2**channel_bitdepth - 1) * (array - amin) / (amax - amin)
        else:
            _array = array
        _array = numpy.rint(_array).astype(dtype=PNGWriter.get_dtype(channel_bitdepth))  # proper rounding
        return cls(_array, filename, channels=channels,
                   grayscale=grayscale, channel_bitdepth=channel_bitdepth,
                   has_alpha=has_alpha, palette=palette)
229723
def _frame_generator(self, frame_duration_ms, audio, sample_rate):
        
        n = int(sample_rate * (frame_duration_ms / 1000.0) * 2)
        offset = 0
        timestamp = 0.0
        duration = (float(n) / sample_rate) / 2.0
        while offset + n < len(audio):
            yield self.Frame(audio[offset:offset + n], timestamp, duration)
            timestamp += duration
            offset += n
256311
function WhammyVideo(duration, quality) {
        this.frames = [];
        if (!duration) {
            duration = 1;
        }
        this.duration = 1000 / duration;
        this.quality = quality || 0.8;
    }
1003221
private function createFormat($videoFormat)
    {
        switch ($videoFormat) {
            case 'flv':
                $format = new Flv();
                break;

            case 'ogg':
                $format = new Ogg();
                break;

            case 'webm':
                $format = new WebM();
                break;

            case 'wmv':
                $format = new WMV();
                break;

            case 'wmv3':
                $format = new WMV3();
                break;

            case '3gp':
                $format = new ThreeGP();
                break;

            case 'mp4':
            case 'x264':
            default:
                $format = new X264();
                break;
        }

        return $format;
    }
43993
def get_video_frames(self, path):
        
        videogen = skvideo.io.vreader(path)
        frames = np.array([frame for frame in videogen])
        return frames