Skip to content

Instantly share code, notes, and snippets.

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

M Ahsan Izhar ahsanghalib

🏠
Working from home
View GitHub Profile
@ahsanghalib
ahsanghalib / Makefile
Created January 6, 2025 19:10 — forked from alexedwards/Makefile
Boilerplate Makefile for Go projects
# Change these variables as necessary.
main_package_path = ./cmd/example
binary_name = example
# ==================================================================================== #
# HELPERS
# ==================================================================================== #
## help: print this help message
.PHONY: help
@ahsanghalib
ahsanghalib / encoding.txt
Created June 13, 2024 07:55 — forked from Andrey2G/encoding.txt
Video Encoding with multiple resolutions
ffmpeg -i "c:/videos/sample.mp4
-map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0
-c:v libx264 -crf 22 -c:a aac -ar 48000
-filter:v:0 scale=w=480:h=360 -maxrate:v:0 600k -b:a:0 64k
-filter:v:1 scale=w=640:h=480 -maxrate:v:1 900k -b:a:1 128k
-filter:v:2 scale=w=1280:h=720 -maxrate:v:2 900k -b:a:2 128k
-var_stream_map "v:0,a:0,name:360p v:1,a:1,name:480p v:2,a:2,name:720p"
-preset slow -hls_list_size 0 -threads 0 -f hls -hls_playlist_type event -hls_time 3
-hls_flags independent_segments -master_pl_name "name-pl.m3u8"
"c:/videos/encoded/name-%v.m3u8"
@ahsanghalib
ahsanghalib / nerd_fonts.md
Created February 1, 2024 19:42 — forked from davidteren/nerd_fonts.md
Install Nerd Fonts via Homebrew [updated & fixed]
@ahsanghalib
ahsanghalib / m3u8-to-mp4.md
Created June 30, 2023 20:37 — forked from tzmartin/m3u8-to-mp4.md
m3u8 stream to mp4 using ffmpeg

1. Copy m3u8 link

Alt text

2. Run command

echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4
@ahsanghalib
ahsanghalib / download_m3u8.sh
Created March 14, 2023 21:52
Download an M3U8 video stream and output it as an MKV using ffmpeg
#!/usr/bin/env bash
if [ "$#" -ne 2 ] ; then
echo "USAGE: $0 <m3u8_url> <out_file>"; exit
fi
base=$(echo "$1" | rev | cut -d'/' -f2- | rev)
curl -s $1 | grep -v "^#" | sed -e "s>^>$base/>" | xargs curl -s | ffmpeg -i pipe:0 -c:v copy -c:a copy $2
@ahsanghalib
ahsanghalib / ffmpeg_mkv_mp4_conversion.md
Created March 14, 2023 21:11 — forked from jamesmacwhite/ffmpeg_mkv_mp4_conversion.md
Easy way to convert MKV to MP4 with ffmpeg

Converting mkv to mp4 with ffmpeg

Essentially just copy the existing video and audio stream as is into a new container, no funny business!

The easiest way to "convert" MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost, it is also a fairly quick process and requires very little CPU power. The main factor is disk read/write speed.

With ffmpeg this can be achieved with -c copy. Older examples may use -vcodec copy -acodec copy which does the same thing.

These examples assume ffmpeg is in your PATH. If not just substitute with the full path to your ffmpeg binary.

Single file conversion example

@ahsanghalib
ahsanghalib / locationHref.test.js
Created January 6, 2023 19:19 — forked from mateuspaulino/locationHref.test.js
Test window.location.href
import { getPageUrl } from './url';
const urls = [
{
url: 'website.com',
expected: 'website.com',
},
{
url: 'website.com?newparam=12',
expected: 'website.com',
@ahsanghalib
ahsanghalib / getPageUrl.js
Created January 6, 2023 19:19 — forked from mateuspaulino/getPageUrl.js
Regex to get clean page url
// This function returns the url page without params.
//google.com?id=1, returns google.com
//google.com/home/id=1, returns google.com/home/
//google.com/home/#init, returns google.com/home/
export const getPageUrl = () => window.location.href.split(/[?#]/)[0];
@ahsanghalib
ahsanghalib / Element Resize
Created December 2, 2022 22:17 — forked from csuwildcat/Element Resize
Legit detection of element resize - all modern browsers + IE down to version 6
(function(){
var attachEvent = document.attachEvent;
if (!attachEvent) {
var requestFrame = (function(){
var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame ||
function(fn){ return window.setTimeout(fn, 20); };
return function(fn){ return raf(fn); };
})();
@ahsanghalib
ahsanghalib / README
Created November 18, 2022 19:06 — forked from joelambert/README
Drop in replacements for setTimeout()/setInterval() that makes use of requestAnimationFrame() where possible for better performance
Drop in replace functions for setTimeout() & setInterval() that
make use of requestAnimationFrame() for performance where available
http://www.joelambert.co.uk
Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php