Skip to content

Instantly share code, notes, and snippets.

View zinzinday's full-sized avatar
🏠
Working from home

Nghia Nguyen zinzinday

🏠
Working from home
View GitHub Profile
@zinzinday
zinzinday / ffmpeg.sh
Created September 30, 2016 19:23 — forked from charlee/ffmpeg.sh
ffmpeg tips
# losslessly concat mp4 files
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
# concat files with the same format
# 1. create a file list
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
@zinzinday
zinzinday / videoinfo.js
Created September 2, 2017 23:49
Get video information using ffprobe and url
var exec = require('child_process').exec;
var url = 'https://URL';
var command = 'curl --silent ' + url + '| ffprobe pipe:0 -print_format json -show_format';
exec(command, function callback(error, stdout, stderr){
if(stderr.indexOf("Invalid data") > -1) {
console.log("Error!");
}
<?xml version="1.0" encoding="utf-8"?>
<!-- https://gist.github.com/kalehv/bae765c756e94455ed88 -->
<resources>
<color name="red_50">#ffebee</color>
<color name="red_100">#ffcdd2</color>
<color name="red_200">#ef9a9a</color>
<color name="red_300">#e57373</color>
<color name="red_400">#ef5350</color>
<color name="red_500">#f44336</color>
@zinzinday
zinzinday / nginx.conf
Created November 24, 2017 22:08 — forked from turtlesoupy/nginx.conf
node.js upstream nginx config
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
@zinzinday
zinzinday / signed_request.js
Created March 30, 2018 21:33 — forked from sorenlouv/signed_request.js
Parse signed request from Facebook cookie, and exchange code to access token
var request = require('request-promise');
var crypto = require('crypto');
var config = {...};
function getAccessToken(cookies) {
var cookieName = 'fbsr_' + config.client_id;
var signedRequest = cookies[cookieName];
var code = getCode(signedRequest);
return exchangeCodeForAccessToken(code);
};
@zinzinday
zinzinday / xcarchive2ipa
Created September 5, 2018 14:25 — forked from samma835/xcarchive2ipa
How to convert .xcarchive to .ipa
xcodebuild -exportArchive -exportFormat ipa -archivePath {PATH}/MyApp.xcarchive -exportPath ~/Desktop/MyApp.ipa
@zinzinday
zinzinday / file-upload.ts
Created February 2, 2019 12:01 — forked from victor-carv/file-upload.ts
File upload - Ionic 3
import {Component} from '@angular/core';
import {
ActionSheetController,
AlertController,
IonicPage,
LoadingController,
ModalController,
NavParams,
ToastController
} from 'ionic-angular';
@zinzinday
zinzinday / get-facebook-token-console-android.js
Created February 10, 2019 22:42 — forked from dieudv/get-facebook-token-console-android.js
Press F12 -> Console and patse this code for android or for ios. (Cre: dieudv)
var email = "youremail";
var password = "yourpassword";
var BASE_URL = "https://api.facebook.com/restserver.php";
var API_SECRET = "62f8ce9f74b12f84c123cc23437a4a32";
var md5 = function(d){result = M(V(Y(X(d),8*d.length)));return result.toLowerCase()};function M(d){for(var _,m="0123456789ABCDEF",f="",r=0;r<d.length;r++)_=d.charCodeAt(r),f+=m.charAt(_>>>4&15)+m.charAt(15&_);return f}function X(d){for(var _=Array(d.length>>2),m=0;m<_.length;m++)_[m]=0;for(m=0;m<8*d.length;m+=8)_[m>>5]|=(255&d.charCodeAt(m/8))<<m%32;return _}function V(d){for(var _="",m=0;m<32*d.length;m+=8)_+=String.fromCharCode(d[m>>5]>>>m%32&255);return _}function Y(d,_){d[_>>5]|=128<<_%32,d[14+(_+64>>>9<<4)]=_;for(var m=1732584193,f=-271733879,r=-1732584194,i=271733878,n=0;n<d.length;n+=16){var h=m,t=f,g=r,e=i;f=md5_ii(f=md5_ii(f=md5_ii(f=md5_ii(f=md5_hh(f=md5_hh(f=md5_hh(f=md5_hh(f=md5_gg(f=md5_gg(f=md5_gg(f=md5_gg(f=md5_ff(f=md5_ff(f=md5_ff(f=md5_ff(f,r=md5_ff(r,i=md5_ff(i,m=md5_ff(m,f,r,i,d[n+0],7,-680876936),f,r,d[n+1],12,-389564586),m,
@zinzinday
zinzinday / ffmpeg.md
Created May 13, 2021 17:10 — forked from tigefa4u/ffmpeg.md
personal quick ffmpeg cheat sheet

These are a few quick easy ffmpeg command lines that can be used to make oft-used video formats. I use them a lot so I wrote them down in a txt file but I converted it to markdown to upload here and access on all my pcs.

Feel free to use 'em. I've gathered them through superuser posts, wiki trawls, and personal experience.

General notes

  • Add -movflags faststart to make mp4 files have their headers at the beginning of the file, allowing them to be streamed (i.e. played even if only part of the file is downloaded).
  • mp4 container supports mp3 files, so if libfdk_aac isnt available (it's the only good aac enc) use libmp3lame.
  • For mp4 files, use -preset X to use mp4 enc presets, like slow or superfast. (veryfast or fast is ok)
  • c:v refers to the video codec used (codec: video). Likewise, c:a is audio. If you're using -map or something, this can be extended (-c:a:0: codec: audio: stream 0)