Skip to content

Instantly share code, notes, and snippets.

Avatar

Josiah Bryan josiahbryan

View GitHub Profile
@josiahbryan
josiahbryan / transcode-test.js
Last active Feb 26, 2020
Test of transcoding with beamcoder
View transcode-test.js
// Revised 2/26/20 with a video filter to try using setpts - didn't help...
// Ticket ongoing at https://github.com/Streampunk/beamcoder/issues/36
const beamcoder = require('beamcoder');
async function main() {
// Get this file from http://dl5.webmfiles.org/big-buck-bunny_trailer.webm
let demuxer = await beamcoder.demuxer('file:./big-buck-bunny_trailer.webm');
let decoder = beamcoder.decoder({ demuxer, stream_index: 0 });
const inVideoStream = demuxer.streams[0];
// console.log(JSON.parse(JSON.stringify(inVideoStream)));
@josiahbryan
josiahbryan / faceEnvWorkerPatch.js
Last active Dec 1, 2020
Use this to make face-api.js work in a WebWorker
View faceEnvWorkerPatch.js
// From: https://github.com/justadudewhohacks/face-api.js/issues/47
// This is needed because face-api.js does not support working in a WebWorker natively
// Updated Dec 1 2020 to work on latest Chrome (tested in WebWorkers on Chrome Mobile on Android / Google Pixel 3 as well)
self.Canvas = self.HTMLCanvasElement = OffscreenCanvas;
// self.HTMLCanvasElement.name = 'HTMLCanvasElement';
// self.Canvas.name = 'Canvas';
self.CanvasRenderingContext2D = OffscreenCanvasRenderingContext2D;
View video-data-encode-test.js
/*
Aerostat Beam Coder - Node.js native bindings for FFmpeg.
Copyright (C) 2019 Streampunk Media Ltd.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@josiahbryan
josiahbryan / video-audio-encode-test.js
Last active Jan 27, 2020
Fixed based on feedback
View video-audio-encode-test.js
/*
Aerostat Beam Coder - Node.js native bindings for FFmpeg.
Copyright (C) 2019 Streampunk Media Ltd.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@josiahbryan
josiahbryan / FpsAutoTuner.js
Created Mar 19, 2019
FpsAutoTuner.js - Auto-optimize the FPS of your application
View FpsAutoTuner.js
/**
* FpsAutoTuner works by measuring the FPS (which you tell it by calling
* `countFrame()`) and then every so often (at `tuningInteval`ms), it compares
* that measured FPS to the `fpsTarget`. When the measured FPS goes below `fpsTarget` less
* `tuningMargin`, the `fpsTarget` will be decreased by
* `tuningRate` and the `callback` will be execute with the new `fpsTarget`. Likewise,
* when the measured FPS exceeds `fpsTarget` less `tuningMargin`, then `fpsTarget`
* will be increased by `tuningRate` and `callback` will be called with the new target.
*
* Example usage:
@josiahbryan
josiahbryan / debundle-sfc.js
Last active Sep 10, 2018
Really Simple Single-File-Component Support for Ember 3.x+
View debundle-sfc.js
"use strict";
const fs = require('fs');
/**
Really Simple Single-File-Component Support for Ember 3.x+
By Josiah Bryan <josiahbryan@gmail.com> 2018-09-07
(Posted for discussion at https://discuss.emberjs.com/t/really-simple-single-file-component-support-for-ember-3-x/15438)
Hey everyone! I'm designing a new hobby project, and I really wanted to work with single file
View live-dependant-list.js
import Ember from 'ember';
/**
@function LiveDependantListMixinFactory
@param listPropertyName {String} or {Object} - if a string, will be the name
of the destination property that you can use in your template as the list.
If this param is an object with at least `{selectAs,from}` defined,
it will be used as the values for the following args (they will be overwritten
with values from the object)
@param fromStoreModel - ember-data model name to select from
@josiahbryan
josiahbryan / ember-sample-index.html
Last active Feb 22, 2019
This is a sample "index.html" to for use with Ember. It moves the loading of the compiled "vendor.js" into an animation frame and instead renders a simple splash screen first with a simple CSS loading indicator. Then, once the splash screen is on screen, it starts loading the <scripts> generated by Ember to boot the app. This should be generic e…
View ember-sample-index.html
<!DOCTYPE html>
<html style='height:100%;overflow:none'>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My App</title>
<meta name="description" content="My App by My Company, Inc.">
<!-- http://www.favicon-generator.org/ generates a good starting manifest that I tweak by hand -->
<link rel="manifest" href="/manifest.json">
@josiahbryan
josiahbryan / es-search-example.json
Last active Dec 5, 2016
Problem with OR Search in ElasticSearch 5
View es-search-example.json
PUT /my_index/
{
"mappings": {
"data": {
"properties": {
"_stringified": {
"type": "text",
"fields": {
"autocomplete": {