static getVideoSamples(videoData) {
    const H264 = shaka.transmuxer.H264;

    /** @type {!Array<shaka.extern.VideoSample>} */
    const videoSamples = [];
    /** @type {?shaka.extern.VideoSample} */
    let lastVideoSample = null;
    /** @type {boolean} */
    let audFound = false;

    const addLastVideoSample = () => {
      if (!lastVideoSample) {
        return;
      }
      if (!lastVideoSample.nalus.length || !lastVideoSample.frame) {
        return;
      }
      const nalusData = [];
      for (const nalu of lastVideoSample.nalus) {
        const size = nalu.fullData.byteLength;
        const naluLength = new Uint8Array(4);
        naluLength[0] = (size >> 24) & 0xff;
        naluLength[1] = (size >> 16) & 0xff;
        naluLength[2] = (size >> 8) & 0xff;
        naluLength[3] = size & 0xff;
        nalusData.push(naluLength);
        nalusData.push(nalu.fullData);
      }
      lastVideoSample.data = shaka.util.Uint8ArrayUtils.concat(...nalusData);
      videoSamples.push(lastVideoSample);
    };

    const createLastVideoSample = (pes) => {
      lastVideoSample = {
        data: new Uint8Array([]),
        frame: false,
        isKeyframe: false,
        pts: pes.pts,
        dts: pes.dts,
        nalus: [],
      };
    };

    for (let i = 0; i < videoData.length; i++) {
      const pes = videoData[i];
      const nalus = pes.nalus;
      let spsFound = false;

      // If new NAL units found and last sample still there, let's push ...
      // This helps parsing streams with missing AUD
      // (only do this if AUD never found)
      if (lastVideoSample && nalus.length && !audFound) {
        addLastVideoSample();
        createLastVideoSample(pes);
      }

      for (const nalu of pes.nalus) {
        let push = false;
        switch (nalu.type) {
          case H264.NALU_TYPE_NDR_: {
            let isKeyframe = false;
            push = true;
            const data = nalu.data;
            // Only check slice type to detect KF in case SPS found in same
            // packet (any keyframe is preceded by SPS ...)
            if (spsFound && data.length > 4) {
              // retrieve slice type by parsing beginning of NAL unit (follow
              // H264 spec,slice_header definition) to detect keyframe embedded
              // in NDR
              const sliceType = new shaka.util.ExpGolomb(data).readSliceType();
              // 2 : I slice, 4 : SI slice, 7 : I slice, 9: SI slice
              // SI slice : A slice that is coded using intra prediction only
              // and using quantisation of the prediction samples.
              // An SI slice can be coded such that its decoded samples can be
              // constructed identically to an SP slice.
              // I slice: A slice that is not an SI slice that is decoded using
              // intra prediction only.
              if (sliceType === 2 || sliceType === 4 ||
                  sliceType === 7 || sliceType === 9) {
                isKeyframe = true;
              }
            }
            if (isKeyframe) {
              // If we have non-keyframe data already, that cannot belong to
              // the same frame as a keyframe, so force a push
              if (lastVideoSample &&
                  lastVideoSample.frame && !lastVideoSample.isKeyframe) {
                addLastVideoSample();
                lastVideoSample = null;
              }
            }
            if (!lastVideoSample) {
              createLastVideoSample(pes);
            }
            lastVideoSample.frame = true;
            lastVideoSample.isKeyframe = isKeyframe;
            break;
          }
          case H264.NALU_TYPE_IDR_: {
            push = true;
            // Handle PES not starting with AUD
            // If we have frame data already, that cannot belong to the same
            // frame, so force a push
            if (lastVideoSample &&
                lastVideoSample.frame && !lastVideoSample.isKeyframe) {
              addLastVideoSample();
              lastVideoSample = null;
            }
            if (!lastVideoSample) {
              createLastVideoSample(pes);
            }
            lastVideoSample.frame = true;
            lastVideoSample.isKeyframe = true;
            break;
          }
          case H264.NALU_TYPE_SEI_:
            push = true;
            break;
          case H264.NALU_TYPE_SPS_:
            push = true;
            spsFound = true;
            break;
          case H264.NALU_TYPE_PPS_:
            push = true;
            break;
          case H264.NALU_TYPE_AUD_:
            push = true;
            audFound = true;
            if (lastVideoSample && lastVideoSample.frame) {
              addLastVideoSample();
              lastVideoSample = null;
            }
            if (!lastVideoSample) {
              createLastVideoSample(pes);
            }
            break;
          case H264.NALU_TYPE_FILLER_DATA_:
            push = true;
            break;
          default:
            push = false;
            break;
        }
        if (lastVideoSample && push) {
          lastVideoSample.nalus.push(nalu);
        }
      }
    }

    // If last PES packet, push samples
    addLastVideoSample();

    return videoSamples;
  }
@param {!Array<shaka.extern.MPEG_PES>} videoData
@return {!Array<shaka.extern.VideoSample>}