Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Tahani miketahani

View GitHub Profile
@miketahani
miketahani / convert-mp4-to-gif.mkd
Created Mar 30, 2021 — forked from tomnomnom/convert-mp4-to-gif.mkd
Crop an mp4 and convert it to a gif
View convert-mp4-to-gif.mkd

Because I'll forget how to do this...

Crop

crop=w:h:x:y

ffmpeg -i in.mp4 -filter:v "crop=900:700:0:50" out.mp4
View gifs.md

convert mp4 to gif

$ ffmpeg -ss 61.0 -t 2.5 -i input.mp4 -filter_complex "[0:v] split [a][b];[a] palettegen [p];[b][p] paletteuse" output.gif

  • -ss 61.0: start gif at 61.0 seconds into video
  • -t 2.5: gif duration of 2.5 seconds (starting at 61.0 seconds into video)

crop existing gif

convert input.gif -coalesce -repage 0x0 -crop 343x310+0+65 +repage output.gif

@miketahani
miketahani / DrawInstances.frag
Last active Dec 17, 2020 — forked from mantissa/DrawInstances.frag
Drawing instanced meshes using matrices contained in textures (OpenFrameworks)
View DrawInstances.frag
#version 120
#extension GL_EXT_gpu_shader4 : require
void main(){
gl_FragColor = gl_Color;
}
@miketahani
miketahani / MakingGeometries.md
Created Dec 12, 2020 — forked from patriciogonzalezvivo/MakingGeometries.md
Creating Geometries in openFrameworks
View MakingGeometries.md

Face by Face

void addFace(ofMesh& mesh, ofVec3f a, ofVec3f b, ofVec3f c) {
	ofVec3f normal = ((b - a).cross(c - a)).normalize();
	mesh.addNormal(normal);
	mesh.addVertex(a);
	mesh.addNormal(normal);
	mesh.addVertex(b);
	mesh.addNormal(normal);
@miketahani
miketahani / motion_vector.c
Created Sep 20, 2020 — forked from w495/motion_vector.c
Пример построения векторов движения с помощью libav. Выводит координаты точек и векторов на stdout. Проверялось на коротких mp4 (h264 / aac). Начальный вариант был взят тут: http://www.princeton.edu/~jiasic/cos435/motion_vector.c и переписан под современный ffmpeg.
View motion_vector.c
/**
* MOTION_VECTOR
*
* Calculates motion vector using ffmpeg and libavcodec.
*
* @authors First modifications by Victor Hsieh.
* Second modifications by Jiasi Chen.
* Third modifications by Ilya Nikitin <w@w-495.ru>.
*
* @date: 2014.05.10 23:30:13
@miketahani
miketahani / rpi4-setup.md
Created Aug 11, 2020
Raspberry Pi 4 with external boot SSD
View rpi4-setup.md

Raspberry Pi 4 setup

For barebones initial setup of a Pi to boot from an external, USB-connected SSD.

Follow instructions in this tutorial, reproduced below:

  1. Flash SD card using Raspberry Pi Imager

  2. touch /Volumes/<volume>/ssh to enable SSH on boot

@miketahani
miketahani / web-servers.md
Created May 26, 2020 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
View singlePageReact.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>single page react boilerplate</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="kokaneka">
</head>
View convertLatLngToSphere.js
const radians = deg => deg * Math.PI / 180
// @param {Number} z Offset from radius
export default function convertLatLngToSphere (lat, lng, baseRadius, z) {
// radians
const phi = radians(lat)
const theta = radians(lng - 180)
const radius = baseRadius + z