/* this parses a result if there it contains the video bitrate
544638
function (result) {
            if (result.stat('googFrameRateSent')) {
              currentStats.videoSentBytes = Number(result.stat('bytesSent'));
              currentStats.videoSentPackets = Number(result.stat('packetsSent'));
              currentStats.videoSentPacketsLost = Number(result.stat('packetsLost'));
              currentStats.videoRtt = Number(result.stat('googRtt'));
              currentStats.videoFrameRate = Number(result.stat('googFrameRateInput'));
              currentStats.videoWidth = Number(result.stat('googFrameWidthSent'));
              currentStats.videoHeight = Number(result.stat('googFrameHeightSent'));
              currentStats.videoCodec = result.stat('googCodecName');
            } else if (result.stat('googFrameRateReceived')) {
              currentStats.videoRecvBytes = Number(result.stat('bytesReceived'));
              currentStats.videoRecvPackets = Number(result.stat('packetsReceived'));
              currentStats.videoRecvPacketsLost = Number(result.stat('packetsLost'));
              currentStats.videoFrameRate = Number(result.stat('googFrameRateOutput'));
              currentStats.videoWidth = Number(result.stat('googFrameWidthReceived'));
              currentStats.videoHeight = Number(result.stat('googFrameHeightReceived'));
              currentStats.videoCodec = result.stat('googCodecName');
            }
            return null;
          }
910291
function getTypeFromFileExtension(url) {
	url = url.toLowerCase().split('?')[0];
	var _ext = url.substring(url.lastIndexOf('.') + 1);
	var _av = /mp4|m4v|ogg|ogv|m3u8|webm|webmv|wmv|mpeg|mov/gi.test(_ext) ? 'video/' : 'audio/';

	switch (_ext) {
		case 'mp4':
		case 'm4v':
		case 'm4a':
			return _av + 'mp4';
		case 'webm':
		case 'webma':
		case 'webmv':
			return _av + 'webm';
		case 'ogg':
		case 'oga':
		case 'ogv':
			return _av + 'ogg';
		case 'm3u8':
			return 'application/x-mpegurl';
		case 'ts':
			return _av + 'mp2t';
		default:
			return _av + _ext;
	}
}
1354906
function parse_Bes(blob) {
	var v = blob.read_shift(1), t = blob.read_shift(1);
	return t === 0x01 ? v : v === 0x01;
}
932880
function(media) {
    if (typeof media === "undefined") {
      // If left blank, all media on the page will be polyfilled.
      media = document.querySelectorAll("[data-object-fit]");
    } else if (media && media.nodeName) {
      // If it's a single node, wrap it in an array so it works.
      media = [media];
    } else if (typeof media === "object" && media.length && media[0].nodeName) {
      // If it's an array of DOM nodes (e.g. a jQuery selector), it's fine as-is.
      media = media;
    } else {
      // Otherwise, if it's invalid or an incorrect type, return false to let people know.
      return false;
    }

    for (var i = 0; i < media.length; i++) {
      if (!media[i].nodeName) { continue; }

      var mediaType = media[i].nodeName.toLowerCase();

      if (mediaType === "img" && !edgePartialSupport) {
        if (media[i].complete) {
          objectFit(media[i]);
        }
        else {
          media[i].addEventListener("load", function() {
            objectFit(this);
          });
        }
      }
      else if (mediaType === "video") {
        if (media[i].readyState > 0) {
          objectFit(media[i]);
        }
        else {
          media[i].addEventListener("loadedmetadata", function() {
            objectFit(this);
          });
        }
      }
    }

    return true;
  }
81903
function () {

			var images = {};
			var blobs = {};

			if ( 'Video' in fbxTree.Objects ) {

				var videoNodes = fbxTree.Objects.Video;

				for ( var nodeID in videoNodes ) {

					var videoNode = videoNodes[ nodeID ];

					var id = parseInt( nodeID );

					images[ id ] = videoNode.RelativeFilename || videoNode.Filename;

					// raw image data is in videoNode.Content
					if ( 'Content' in videoNode ) {

						var arrayBufferContent = ( videoNode.Content instanceof ArrayBuffer ) && ( videoNode.Content.byteLength > 0 );
						var base64Content = ( typeof videoNode.Content === 'string' ) && ( videoNode.Content !== '' );

						if ( arrayBufferContent || base64Content ) {

							var image = this.parseImage( videoNodes[ nodeID ] );

							blobs[ videoNode.RelativeFilename || videoNode.Filename ] = image;

						}

					}

				}

			}

			for ( var id in images ) {

				var filename = images[ id ];

				if ( blobs[ filename ] !== undefined ) images[ id ] = blobs[ filename ];
				else images[ id ] = images[ id ].split( '\\' ).pop();

			}

			return images;

		}
856001
def ParseVideoRow(self, parser_mediator, query, row, **unused_kwargs):
    
    query_hash = hash(query)

    event_data = KodiVideoEventData()
    event_data.filename = self._GetRowValue(query_hash, row, 'strFilename')
    event_data.play_count = self._GetRowValue(query_hash, row, 'playCount')
    event_data.query = query

    timestamp = self._GetRowValue(query_hash, row, 'lastPlayed')
    date_time = dfdatetime_time_elements.TimeElements()
    date_time.CopyFromDateTimeString(timestamp)
    event = time_events.DateTimeValuesEvent(
        date_time, definitions.TIME_DESCRIPTION_LAST_VISITED)
    parser_mediator.ProduceEventWithEventData(event, event_data)
848016
function VideoCaps(videoCapsDict){
  if(!(this instanceof VideoCaps))
    return new VideoCaps(videoCapsDict)

  videoCapsDict = videoCapsDict || {}

  // Check videoCapsDict has the required fields
  // 
  // checkType('VideoCodec', 'videoCapsDict.codec', videoCapsDict.codec, {required: true});
  //  
  // checkType('Fraction', 'videoCapsDict.framerate', videoCapsDict.framerate, {required: true});
  //  

  // Init parent class
  VideoCaps.super_.call(this, videoCapsDict)

  // Set object properties
  Object.defineProperties(this, {
    codec: {
      writable: true,
      enumerable: true,
      value: videoCapsDict.codec
    },
    framerate: {
      writable: true,
      enumerable: true,
      value: videoCapsDict.framerate
    }
  })
}
237270
function () {
                var el = document.createElement( 'video' ),
                    bool = false;
                // IE9 Running on Windows Server SKU can cause an exception to be thrown, bug #224
                try {
                    if ( bool = !!el.canPlayType ) {
                        bool      = new Boolean(bool);
                        bool.ogg  = el.canPlayType('video/ogg; codecs="theora"')      .replace(/^no$/,'');
                        bool.h264 = el.canPlayType('video/mp4; codecs="avc1.42E01E"') .replace(/^no$/,'');
                        bool.webm = el.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,'');
                    }
    
                } catch(e) {}
                _video = bool;
    
                this.supportVideo = function () { return _video; };
                return this.supportVideo();
            }
768009
function Analyze() {
		$info = &$this->getid3->info;

		$initialOffset = $info['avdataoffset'];

		if (!$this->getOnlyMPEGaudioInfo($info['avdataoffset'])) {
			if ($this->allow_bruteforce) {
				$info['error'][] = 'Rescanning file in BruteForce mode';
				$this->getOnlyMPEGaudioInfoBruteForce($this->getid3->fp, $info);
			}
		}


		if (isset($info['mpeg']['audio']['bitrate_mode'])) {
			$info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
		}

		if (((isset($info['id3v2']['headerlength']) && ($info['avdataoffset'] > $info['id3v2']['headerlength'])) || (!isset($info['id3v2']) && ($info['avdataoffset'] > 0) && ($info['avdataoffset'] != $initialOffset)))) {

			$synchoffsetwarning = 'Unknown data before synch ';
			if (isset($info['id3v2']['headerlength'])) {
				$synchoffsetwarning .= '(ID3v2 header ends at '.$info['id3v2']['headerlength'].', then '.($info['avdataoffset'] - $info['id3v2']['headerlength']).' bytes garbage, ';
			} elseif ($initialOffset > 0) {
				$synchoffsetwarning .= '(should be at '.$initialOffset.', ';
			} else {
				$synchoffsetwarning .= '(should be at beginning of file, ';
			}
			$synchoffsetwarning .= 'synch detected at '.$info['avdataoffset'].')';
			if (isset($info['audio']['bitrate_mode']) && ($info['audio']['bitrate_mode'] == 'cbr')) {

				if (!empty($info['id3v2']['headerlength']) && (($info['avdataoffset'] - $info['id3v2']['headerlength']) == $info['mpeg']['audio']['framelength'])) {

					$synchoffsetwarning .= '. This is a known problem with some versions of LAME (3.90-3.92) DLL in CBR mode.';
					$info['audio']['codec'] = 'LAME';
					$CurrentDataLAMEversionString = 'LAME3.';

				} elseif (empty($info['id3v2']['headerlength']) && ($info['avdataoffset'] == $info['mpeg']['audio']['framelength'])) {

					$synchoffsetwarning .= '. This is a known problem with some versions of LAME (3.90 - 3.92) DLL in CBR mode.';
					$info['audio']['codec'] = 'LAME';
					$CurrentDataLAMEversionString = 'LAME3.';

				}

			}
			$info['warning'][] = $synchoffsetwarning;

		}

		if (isset($info['mpeg']['audio']['LAME'])) {
			$info['audio']['codec'] = 'LAME';
			if (!empty($info['mpeg']['audio']['LAME']['long_version'])) {
				$info['audio']['encoder'] = rtrim($info['mpeg']['audio']['LAME']['long_version'], "\x00");
			} elseif (!empty($info['mpeg']['audio']['LAME']['short_version'])) {
				$info['audio']['encoder'] = rtrim($info['mpeg']['audio']['LAME']['short_version'], "\x00");
			}
		}

		$CurrentDataLAMEversionString = (!empty($CurrentDataLAMEversionString) ? $CurrentDataLAMEversionString : (isset($info['audio']['encoder']) ? $info['audio']['encoder'] : ''));
		if (!empty($CurrentDataLAMEversionString) && (substr($CurrentDataLAMEversionString, 0, 6) == 'LAME3.') && !preg_match('[0-9\)]', substr($CurrentDataLAMEversionString, -1))) {
			// a version number of LAME that does not end with a number like "LAME3.92"
			// or with a closing parenthesis like "LAME3.88 (alpha)"
			// or a version of LAME with the LAMEtag-not-filled-in-DLL-mode bug (3.90-3.92)

			// not sure what the actual last frame length will be, but will be less than or equal to 1441
			$PossiblyLongerLAMEversion_FrameLength = 1441;

			// Not sure what version of LAME this is - look in padding of last frame for longer version string
			$PossibleLAMEversionStringOffset = $info['avdataend'] - $PossiblyLongerLAMEversion_FrameLength;
			fseek($this->getid3->fp, $PossibleLAMEversionStringOffset);
			$PossiblyLongerLAMEversion_Data = fread($this->getid3->fp, $PossiblyLongerLAMEversion_FrameLength);
			switch (substr($CurrentDataLAMEversionString, -1)) {
				case 'a':
				case 'b':
					// "LAME3.94a" will have a longer version string of "LAME3.94 (alpha)" for example
					// need to trim off "a" to match longer string
					$CurrentDataLAMEversionString = substr($CurrentDataLAMEversionString, 0, -1);
					break;
			}
			if (($PossiblyLongerLAMEversion_String = strstr($PossiblyLongerLAMEversion_Data, $CurrentDataLAMEversionString)) !== false) {
				if (substr($PossiblyLongerLAMEversion_String, 0, strlen($CurrentDataLAMEversionString)) == $CurrentDataLAMEversionString) {
					$PossiblyLongerLAMEversion_NewString = substr($PossiblyLongerLAMEversion_String, 0, strspn($PossiblyLongerLAMEversion_String, 'LAME0123456789., (abcdefghijklmnopqrstuvwxyzJFSOND)')); //"LAME3.90.3"  "LAME3.87 (beta 1, Sep 27 2000)" "LAME3.88 (beta)"
					if (empty($info['audio']['encoder']) || (strlen($PossiblyLongerLAMEversion_NewString) > strlen($info['audio']['encoder']))) {
						$info['audio']['encoder'] = $PossiblyLongerLAMEversion_NewString;
					}
				}
			}
		}
		if (!empty($info['audio']['encoder'])) {
			$info['audio']['encoder'] = rtrim($info['audio']['encoder'], "\x00 ");
		}

		switch (isset($info['mpeg']['audio']['layer']) ? $info['mpeg']['audio']['layer'] : '') {
			case 1:
			case 2:
				$info['audio']['dataformat'] = 'mp'.$info['mpeg']['audio']['layer'];
				break;
		}
		if (isset($info['fileformat']) && ($info['fileformat'] == 'mp3')) {
			switch ($info['audio']['dataformat']) {
				case 'mp1':
				case 'mp2':
				case 'mp3':
					$info['fileformat'] = $info['audio']['dataformat'];
					break;

				default:
					$info['warning'][] = 'Expecting [audio][dataformat] to be mp1/mp2/mp3 when fileformat == mp3, [audio][dataformat] actually "'.$info['audio']['dataformat'].'"';
					break;
			}
		}

		if (empty($info['fileformat'])) {
			unset($info['fileformat']);
			unset($info['audio']['bitrate_mode']);
			unset($info['avdataoffset']);
			unset($info['avdataend']);
			return false;
		}

		$info['mime_type']         = 'audio/mpeg';
		$info['audio']['lossless'] = false;

		// Calculate playtime
		if (!isset($info['playtime_seconds']) && isset($info['audio']['bitrate']) && ($info['audio']['bitrate'] > 0)) {
			$info['playtime_seconds'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['audio']['bitrate'];
		}

		$info['audio']['encoder_options'] = $this->GuessEncoderOptions();

		return true;
	}
152301
static long compensateForDropFrame(final long framenumber, final double framerate)
	{
		//Code by David Heidelberger, adapted from Andrew Duncan

		//Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate
		final long dropFrames = Math.round(framerate * .066666);

		final long framesPer10Minutes = Math.round(framerate * 60 * 10);
		final long framesPerMinute = (Math.round(framerate) * 60) - dropFrames;

		final long d = framenumber / framesPer10Minutes;
		final long m = framenumber % framesPer10Minutes;

		//In the original post, the next line read m>1, which only worked for 29.97. Jean-Baptiste Mardelle correctly pointed out that m should be compared to dropFrames.
		if (m > dropFrames)
			return framenumber + (dropFrames * 9 * d) + dropFrames * ((m - dropFrames) / framesPerMinute);
		else
			return framenumber + dropFrames * 9 * d;
	}
433523
function gotMedia(mediaStream) {
  // Extract video track.
  videoDevice = mediaStream.getVideoTracks()[0];
  log('Using camera', videoDevice.label);

  const captureDevice = new ImageCapture(videoDevice, mediaStream);
  interval = setInterval(function () {
    captureDevice.grabFrame().then(processFrame).catch(error => {
      err((new Date()).toISOString(), 'Error while grabbing frame:', error);
    });

    captureDevice.takePhoto().then(processPhoto).catch(error => {
      err((new Date()).toISOString(), 'Error while taking photo:', error);
    });
  }, 300);
}
1332289
public void parseMetaData() {
    final ImageFormat imageFormat = ImageFormatChecker.getImageFormat_WrapIOException(
        getInputStream());
    mImageFormat = imageFormat;
    // BitmapUtil.decodeDimensions has a bug where it will return 100x100 for some WebPs even though
    // those are not its actual dimensions
    final Pair<Integer, Integer> dimensions;
    if (DefaultImageFormats.isWebpFormat(imageFormat)) {
      dimensions = readWebPImageSize();
    } else {
      dimensions = readImageMetaData().getDimensions();
    }
    if (imageFormat == DefaultImageFormats.JPEG && mRotationAngle == UNKNOWN_ROTATION_ANGLE) {
      // Load the JPEG rotation angle only if we have the dimensions
      if (dimensions != null) {
        mExifOrientation = JfifUtil.getOrientation(getInputStream());
        mRotationAngle = JfifUtil.getAutoRotateAngleFromOrientation(mExifOrientation);
      }
    } else if (imageFormat == DefaultImageFormats.HEIF
        && mRotationAngle == UNKNOWN_ROTATION_ANGLE) {
      mExifOrientation = HeifExifUtil.getOrientation(getInputStream());
      mRotationAngle = JfifUtil.getAutoRotateAngleFromOrientation(mExifOrientation);
    } else {
      mRotationAngle = 0;
    }
  }
1063783
private void processVideoStbl(SampleTableBox stbl, long scale) {
        // stsc - has Records
        SampleToChunkBox stsc = stbl.getSampleToChunkBox(); // stsc
        if (stsc != null) {
            log.debug("Sample to chunk atom found");
            videoSamplesToChunks = stsc.getEntries();
            log.debug("Video samples to chunks: {}", videoSamplesToChunks.size());
            for (SampleToChunkBox.Entry s2c : videoSamplesToChunks) {
                log.info("Entry: {}", s2c);
            }
        }
        // stsz - has Samples
        SampleSizeBox stsz = stbl.getSampleSizeBox(); // stsz
        if (stsz != null) {
            log.debug("Sample size atom found");
            videoSamples = stsz.getSampleSizes();
            // if sample size is 0 then the table must be checked due to variable sample sizes
            log.debug("Sample size: {}", stsz.getSampleSize());
            videoSampleCount = stsz.getSampleCount();
            log.debug("Sample count: {}", videoSampleCount);
        }
        // stco - has Chunks
        ChunkOffsetBox stco = stbl.getChunkOffsetBox(); // stco / co64
        if (stco != null) {
            log.debug("Chunk offset atom found");
            videoChunkOffsets = stco.getChunkOffsets();
            log.debug("Chunk count: {}", videoChunkOffsets.length);
        } else {
            // co64 - has Chunks
            List<ChunkOffset64BitBox> stblBoxes = stbl.getBoxes(ChunkOffset64BitBox.class);
            if (stblBoxes != null && !stblBoxes.isEmpty()) {
                ChunkOffset64BitBox co64 = stblBoxes.get(0);
                if (co64 != null) {
                    log.debug("Chunk offset (64) atom found");
                    videoChunkOffsets = co64.getChunkOffsets();
                    log.debug("Chunk count: {}", videoChunkOffsets.length);
                    // double the timescale for video, since it seems to run at
                    // half-speed when co64 is used (seems hacky)
                    //videoTimeScale = scale * 2.0;
                    //log.debug("Video time scale: {}", videoTimeScale);
                }
            }
        }
        // stss - has Sync - no sync means all samples are keyframes
        SyncSampleBox stss = stbl.getSyncSampleBox(); // stss
        if (stss != null) {
            log.debug("Sync sample atom found");
            syncSamples = stss.getSampleNumber();
            log.debug("Keyframes: {}", syncSamples.length);
        }
        // stts - has TimeSampleRecords
        TimeToSampleBox stts = stbl.getTimeToSampleBox(); // stts
        if (stts != null) {
            log.debug("Time to sample atom found");
            List<TimeToSampleBox.Entry> records = stts.getEntries();
            log.debug("Video time to samples: {}", records.size());
            // handle instance where there are no actual records (bad f4v?)
            if (records.size() > 0) {
                TimeToSampleBox.Entry rec = records.get(0);
                log.debug("Samples = {} delta = {}", rec.getCount(), rec.getDelta());
                //if we have 1 record it means all samples have the same duration
                videoSampleDuration = rec.getDelta();
            }
        }
        // ctts - (composition) time to sample
        CompositionTimeToSample ctts = stbl.getCompositionTimeToSample(); // ctts
        if (ctts != null) {
            log.debug("Composition time to sample atom found");
            compositionTimes = ctts.getEntries();
            log.debug("Record count: {}", compositionTimes.size());
            if (log.isTraceEnabled()) {
                for (CompositionTimeToSample.Entry rec : compositionTimes) {
                    double offset = rec.getOffset();
                    if (scale > 0d) {
                        offset = (offset / (double) scale) * 1000.0;
                        rec.setOffset((int) offset);
                    }
                    log.trace("Samples = {} offset = {}", rec.getCount(), rec.getOffset());
                }
            }
        }
        // sdtp - sample dependency type
        SampleDependencyTypeBox sdtp = stbl.getSampleDependencyTypeBox(); // sdtp
        if (sdtp != null) {
            log.debug("Independent and disposable samples atom found");
            List<SampleDependencyTypeBox.Entry> recs = sdtp.getEntries();
            for (SampleDependencyTypeBox.Entry rec : recs) {
                log.debug("{}", rec);
            }
        }
    }
73075
function parse_PtgAttrIf(blob, length, opts) {
	var bitIf = (blob[blob.l+1] & 0xFF) ? 1 : 0;
	blob.l += 2;
	return [bitIf, blob.read_shift(opts && opts.biff == 2 ? 1 : 2)];
}
269127
def bitrate(self):
        """"""

        assert self.parsed_frames, "no frame parsed yet"

        if self._samples == 0:
            return 0

        return (8 * self._payload * self.frequency) // self._samples
854466
private void processVideoBox(SampleTableBox stbl, VisualSampleEntry vse, long scale) {
        // get codec
        String codecName = vse.getType();
        //set the video codec here - may be avc1 or mp4v
        setVideoCodecId(codecName);
        if ("avc1".equals(codecName)) {
            AvcConfigurationBox avc1 = vse.getBoxes(AvcConfigurationBox.class).get(0);
            avcLevel = avc1.getAvcLevelIndication();
            log.debug("AVC level: {}", avcLevel);
            avcProfile = avc1.getAvcProfileIndication();
            log.debug("AVC Profile: {}", avcProfile);
            AvcDecoderConfigurationRecord avcC = avc1.getavcDecoderConfigurationRecord();
            if (avcC != null) {
                long videoConfigContentSize = avcC.getContentSize();
                log.debug("AVCC size: {}", videoConfigContentSize);
                ByteBuffer byteBuffer = ByteBuffer.allocate((int) videoConfigContentSize);
                avc1.avcDecoderConfigurationRecord.getContent(byteBuffer);
                byteBuffer.flip();
                videoDecoderBytes = new byte[byteBuffer.limit()];
                byteBuffer.get(videoDecoderBytes);
            } else {
                // quicktime and ipods use a pixel aspect atom (pasp)
                // since we have no avcC check for this and avcC may be a child
                log.warn("avcC atom not found; we may need to modify this to support pasp atom");
            }
        } else if ("mp4v".equals(codecName)) {
            if (vse.getBoxes(ESDescriptorBox.class).size() > 0) {
                // look for esds
                ESDescriptorBox esds = vse.getBoxes(ESDescriptorBox.class).get(0);
                if (esds != null) {
                    ESDescriptor descriptor = esds.getEsDescriptor();
                    //log.debug("ES descriptor: {}", descriptor);
                    if (descriptor != null) {
                        DecoderConfigDescriptor decConf = descriptor.getDecoderConfigDescriptor();
                        if (decConf != null) {
                            DecoderSpecificInfo decInfo = decConf.getDecoderSpecificInfo();
                            ByteBuffer byteBuffer = decInfo.serialize();
                            videoDecoderBytes = new byte[byteBuffer.limit()];
                            byteBuffer.get(videoDecoderBytes);
                        }
                    }
                }
            }
        } else {
            log.debug("Unrecognized video codec: {} compressor name: {}", codecName, vse.getCompressorname());
        }
        processVideoStbl(stbl, scale);
    }
313746
private void decodeVideoHeader() throws IOException {
        int length = file.readInt();
        file.skipBytes(4);//video frame count is always zero with ffmpeg encoded files...
        videoWidth = file.readUnsignedShort();
        videoHeight = file.readUnsignedShort();
        byte[] videoEncodingBytes = new byte[4];
        file.readFully(videoEncodingBytes);
        videoEncoding = SmjpegVideoEncoding.fromMagic(videoEncodingBytes);
        file.skipBytes(Math.max(0, length - 4 - 4 - 2 - 2));
    }