Skip to content

Instantly share code, notes, and snippets.

View mayeaux's full-sized avatar
💭
Coding

Anthony mayeaux

💭
Coding
View GitHub Profile
@mayeaux
mayeaux / encode.sh
Created November 9, 2017 21:09 — forked from mikoim/README.md
YouTube recommended encoding settings on ffmpeg (+ libx264)
#/bin/sh
ffmpeg -i input -c:v libx264 -preset slow -profile:v high -crf 18 -coder 1 -pix_fmt yuv420p -movflags +faststart -g 30 -bf 2 -c:a aac -b:a 384k -profile:a aac_low output
@mayeaux
mayeaux / ffmpeg-html5
Created November 9, 2017 21:11 — forked from yellowled/ffmpeg-html5
Convert videos to proper formats for HTML5 video on Linux shell using ffmpeg. Will probably convert this to a bash script later, but for the time being, here's some examples. Not sure there have actually sensible dimensions and bitrates for web video.
# webm
ffmpeg -i IN -f webm -vcodec libvpx -acodec libvorbis -ab 128000 -crf 22 -s 640x360 OUT.webm
# mp4
ffmpeg -i IN -acodec aac -strict experimental -ac 2 -ab 128k -vcodec libx264 -vpre slow -f mp4 -crf 22 -s 640x360 OUT.mp4
# ogg (if you want to support older Firefox)
ffmpeg2theora IN -o OUT.ogv -x 640 -y 360 --videoquality 5 --audioquality 0 --frontend
@mayeaux
mayeaux / nginx_assets.md
Created November 20, 2017 18:36 — forked from vishaltelangre/nginx_assets.md
Serving Static Assets via Nginx

Concept

  • People talk about two servers: a web server (e.g. Nginx, Apache, etc.) and a app server (e.g. Language specific servers like Unicorn, Node.js, Tomcat, Http-Kit, etc.). There are exceptions where app servers not required at all (as web server itself provides preprocessors for handling), but let's not talk about now.
  • Web servers are really fast and supports lot of standard and commonly used MIME-type requests. Concept of serving a file is -- forming and sending a response of bytes of data and labeling it with requested MIME-type by a client (e.g. web browser).
  • Every response format (in layman's language, a file) is recognized by it's MIME-type, for e.g. a PNG image file has "image/png" MIME-type. JavaScript file has "text/javascript". HTML responses (or files) has "text/html". Plain text files have "text/plain".
  • Modern Browsers supports a lot of standard MIME-types. Images, videos, text files (XML, HTML, SVG, JS), and they better know how to visualize it. Browser also knows unrec
@mayeaux
mayeaux / gist:7c3562e1616dfdd76aea51975463d22d
Created December 5, 2017 03:04
Enable youtube-dl by forcing ipv4
easy fix for linux users.
nano /etc/youtube-dl.conf
--force-ipv4
ctrl + x
Y
done.
ffmpeg -i data/video.mp4 -vcodec h264 -b:v 1000k -acodec mp2 data/output.mp4
<div class="switch-toggle switch-3 switch-candy">
<input id="on" name="state-d" type="radio" checked="">
<label for="on" onclick="">ON</label>
<input id="na" name="state-d" type="radio" checked="checked">
<label for="na" onclick="">N/A</label>
<input id="off" name="state-d" type="radio">
<label for="off" onclick="">OFF</label>
@mayeaux
mayeaux / webrtc-options.md
Created December 12, 2017 01:02 — forked from jpopesculian/webrtc-options.md
Large Scale WebRTC Broadcast

Large Scale WebRTC Broadcast

The Problem

WebRTC is a protocol that has been standardized in recent years among major browsers like Chrome, Firefox, Opera and the Android Browsers. Plugins/Native Implementations are available on IE/Edge/Safari and iOS/Android basically providing a relatively global protocol for real time media streams. However WebRTC is a P2P protocol which means that if a user wishes to broadcast his/her video to multiple users he/she needs to individually send that broadcast to each participant. This works on a small scale, but degrades quickly on a large scale due to bandwidth deterioration.

The Solution

One possible solution is to let the user stream his/her media to a server and the server in turn splits the media streams to the subscribers. There are two technical ways to do this. A Selective Forwarding Unit (SFU) which simply forwards streams, and a Multipoint Control Unit (MCU) which essentially does the same thing but lowers bandwidth usage by packaging streams together.

/*
* (C) Copyright 2013 Kurento (http://kurento.org/)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-2.1.html
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@mayeaux
mayeaux / nginx-websocket-proxy.conf
Created December 17, 2017 04:46 — forked from uorat/nginx-websocket-proxy.conf
Nginx Reverse Proxy for WebSocket
upstream websocket {
server localhost:3000;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/websocket.access.log main;
@mayeaux
mayeaux / bookmarkleting.md
Created December 24, 2017 01:54 — forked from caseywatts/bookmarkleting.md
Making Bookmarklets

Making Bookmarklets

I'm feeling very clever. I've got this sweet line of javascript that replaces "cloud" with "butt". My mom would LOVE this, but she doesn't computer very well. I'm afraid to show her the Developer Console and have her type/paste this in. But she IS pretty good at bookmarks, she knows just how to click those!

A bookmark normally takes you to a new web page. A bookmarklet is a bookmark that runs javascript on the current page instead of taking you to a new page. To declare that it is a bookmarklet, the "location" it points to starts with javascript:.

This guide will walk you through creating your first bookmarklet. For a more thorough guide check out the great website Bookmarklets - Browser Power.

Some bookmarklets are pretty cool. Become a spaceship that shoots and destroys elements on the webpage you're on with Kick Ass. Or make pages rainbow and sparkly with Cornify.