Skip to content

Instantly share code, notes, and snippets.

View ahmed-abdelazim's full-sized avatar

Ahmed Abdeazim ahmed-abdelazim

View GitHub Profile
@ahmed-abdelazim
ahmed-abdelazim / stream_to_youtube.sh
Created April 4, 2019 21:15 — forked from olasd/stream_to_youtube.sh
Stream video to youtube via ffmpeg
#! /bin/bash
#
# Diffusion youtube avec ffmpeg
# Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée.
VBR="2500k" # Bitrate de la vidéo en sortie
FPS="30" # FPS de la vidéo en sortie
QUAL="medium" # Preset de qualité FFMPEG
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube
@ahmed-abdelazim
ahmed-abdelazim / node-expo.sh
Last active June 23, 2019 18:43
install nodejs + expo + npm on ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install nodejs
sudo npm install --unsafe-perm -g expo-cli
@ahmed-abdelazim
ahmed-abdelazim / jq.md
Last active July 5, 2019 16:16
jq commands

Return first element of any json

jq -r '[.[] ] | .[0]' input.json

Use enviroment variable as index (integer).

jq --arg len $len -r '[.[] ] | .[$len | tonumber]."aud-cmd"' input.json

/**
* marked - a markdown parser
* Copyright (c) 2011-2013, Christopher Jeffrey. (MIT Licensed)
* https://github.com/chjj/marked
*/
;(function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){3,} *\n*/,blockquote:/^( *>[^\n]+(\n[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,'gm')
(/bull/g,block.bullet)
();block.list=replace(block.list)
(/bull/g,block.bullet)
('hr',/\n+(?=(?: *[-*_]){3,} *(?:\n+|$))/)
@ahmed-abdelazim
ahmed-abdelazim / terraform.md
Last active July 22, 2019 13:11
Quick Terraform start

Install Terraform

wget https://releases.hashicorp.com/terraform/0.11.9/terraform_0.11.9_linux_amd64.zip
unzip terraform_0.11.9_linux_amd64.zip
export PATH="$PATH:$HOME/terraform"
cd /usr/bin
sudo ln -s $HOME/terraform
cd $HOME
source ~/.bashrc
terraform
@ahmed-abdelazim
ahmed-abdelazim / concat_ffmpeg.sh
Last active September 10, 2019 21:56
Concat folder Videos with ffmpeg
# Concat folder Videos with ffmpeg
ffmpeg -f concat -safe 0 -i <(for f in ./*.MP4; do echo "file '$PWD/$f'"; done) -c copy output.MP4
# Concat files in the list.txt
ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4
# Concat with re-encode (if faced some errors like "Non-monotonous DTS in output stream")
ffmpeg -f concat -safe 1 -i list.txt -c:v libx265 -preset ultrafast -crf 18 -c:a libmp3lame output3.mp4
# list.txt
# file 1.mp4
# file 2.mp4
@ahmed-abdelazim
ahmed-abdelazim / overlay_ffmpeg.sh
Last active September 10, 2019 21:56
add overlay to video
ffmpeg -i intro.mp4 -i overlay.png \
-filter_complex "[1:v]scale=520:-1,format=rgba,colorchannelmixer=aa=0.5[fg];[0][fg]overlay=1380:920:enable='between(t,0,20)'" \
-pix_fmt yuv420p -c:v libx264 -preset fast -crf 22 -c:a libmp3lame \
output.mp4
ffmpeg -i intro.mp4 -i overlay.png \
-filter_complex "[1:v]format=rgba,colorchannelmixer=aa=0.7[fg];[0][fg]overlay" \
-pix_fmt yuv420p -c:a copy \
output.mp4
@ahmed-abdelazim
ahmed-abdelazim / install.sh
Last active September 11, 2019 09:26
Install doctl (Digital Ocean official command line utility) on Debian
# install doctl
sudo apt update
sudo apt -y install snapd
sudo snap install doctl
ln -s /snap/bin/doctl /usr/local/bin
# initiate doctl
# Generate access token herer https://cloud.digitalocean.com/account/api/tokens
doctl auth init
# list current droplets in json format
doctl compute droplet list -o json
@ahmed-abdelazim
ahmed-abdelazim / default
Created September 11, 2019 21:15
Install Nginx - php on Ubuntu 18 and Digital Ocean php client
server {
listen 80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
@ahmed-abdelazim
ahmed-abdelazim / service.sh
Created September 15, 2019 21:27
Create a service from bash script on Ubuntu ( for startup )
bootscript=/root/run.sh
servicename=customboot
cat > $bootscript <<EOF
#!/usr/bin/env bash
echo "$bootscript ran at $(date)!" > /tmp/it-works
EOF
chmod +x $bootscript