Skip to content

Instantly share code, notes, and snippets.

@albert-zhang
albert-zhang / ffmpeg.md
Last active June 20, 2019 11:15
ffmpeg

Convert to specific resolution:

ffmpeg -i input.mov -vcodec h264 -acodec aac -s 1280x720 output.mp4

ffmpeg -i {input}.mov -vcodec h264 -acodec aac -strict -2 output.mp4

Stream camera to rtmp on Mac:

ffmpeg -f avfoundation -framerate 30 -i "0" -c:v libx264 -an -f flv rtmp://localhost:1935/live/mystream

Stream file to rtmp:

ffmpeg -re -i ~/Desktop/input.mp4 -c copy -f flv rtmp://localhost:1935/live/mystream

@albert-zhang
albert-zhang / adjust-font-size-based-on-screen-size.js
Created December 6, 2016 03:57
adjust font size based on screen size
// http://mp.weixin.qq.com/s?__biz=MzAxODE2MjM1MA==&mid=2651551510&idx=1&sn=ad6f87385c39c90c2501ca94b5f5c8dc
var designWidth = 640, rem2px = 100;
var d = window.document.createElement('div');
d.style.width = '1rem';
d.style.display = "none";
var head = window.document.getElementsByTagName('head')[0];
head.appendChild(d);
var defaultFontSize = parseFloat(window.getComputedStyle(d, null).getPropertyValue('width'));
d.remove();
document.documentElement.style.fontSize = window.innerWidth / designWidth * rem2px / defaultFontSize * 100 + '%';
@albert-zhang
albert-zhang / curl.md
Last active February 8, 2017 03:43
curl
@albert-zhang
albert-zhang / angularjs.js
Last active August 10, 2018 03:15
angularjs
// Get provider outside of angular:
angular.element(document.querySelector('.app')).injector().get('SomeService')
@albert-zhang
albert-zhang / check-repo-version.js
Created August 14, 2018 23:49
check-repo-version.js
const semver = require('semver')
const exec = require('child_process').exec
const packageJson = require('./package.json')
const prjName = packageJson.name
function getRemoteVer() {
return new Promise((resolve, reject) => {
const theCmd = 'npm show ' + prjName + ' version --registry=http://example.com'
exec(theCmd, function(err, stdout, stderr) {
@albert-zhang
albert-zhang / gem_install_to_usr.sh
Created August 16, 2018 02:53
gem_install_to_usr.sh
# ref: https://stackoverflow.com/questions/31972968/cant-install-gems-on-os-x-el-capitan
sudo gem install THE_GEM -n/usr/local/bin
@albert-zhang
albert-zhang / another.sh
Last active December 3, 2018 01:59 — forked from jobsamuel/readme.md
Run NodeJS as a Service on Ubuntu 14.04 LTS
start on filesystem and started networking
respawn
chdir /home/work/node-app
env NODE_ENV=production
exec /usr/bin/node /home/work/node-app/index.js
@albert-zhang
albert-zhang / upstart.md
Created February 13, 2019 10:09
upstart

create file the-name.service at /etc/systemd/system:

[Unit]
Description=the-desc
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple