Skip to content

Instantly share code, notes, and snippets.

@dlobjoie
dlobjoie / hls.sh
Created May 13, 2022 21:19 — forked from hsiaosiyuan0/hls.sh
hls demo
#!/usr/bin/env bash
# downloading mv.mp4
download_mv_if_needed() {
if [ ! -f "./videos/mv.mp4" ]; then
mkdir -p ./videos
curl -L https://www.dropbox.com/s/fl02xpyhz8693b0/mv.mp\?dl\=1 -o ./videos/mv.mp4
fi
}
@dlobjoie
dlobjoie / ffmpeg-hls.sh
Last active May 13, 2022 21:09 — forked from rlaphoenix/ffmpeg-hls.sh
FFMPEG HLS script.
ffmpeg -i sample.mp4 \
-filter_complex \
"[0:v]split=4[v1][v2][v3][v4]; \
[v1]scale=w=1980:h=1080[v1out]; \
[v2]scale=w=1280:h=720[v2out]; \
[v3]scale=w=854:h=480[v3out]; \
[v4]scale=w=640:h=360[v4out]" \
-map [v1out] -c:v:0 libx264 -profile main -b:v:0 5000k -minrate 4500k -maxrate 5300k -bufsize 5000k -preset slow -g 120 -keyint_min 120 -sc_threshold 0 \
-map [v2out] -c:v:1 libx264 -profile main -b:v:1 3000k -minrate 2500k -maxrate 3200k -bufsize 3000k -preset slow -g 120 -keyint_min 120 -sc_threshold 0 \
-map [v3out] -c:v:2 libx264 -profile main -b:v:2 1500k -minrate 1250k -maxrate 1600k -bufsize 1500k -preset slow -g 120 -keyint_min 120 -sc_threshold 0 \
@dlobjoie
dlobjoie / make-encrypted-hls-vod.sh
Last active May 13, 2022 21:01 — forked from arafathusayn/make-encrypted-hls-vod.sh
Bash script to create AES-encrypted HLS VOD using ffmpeg. Usage: ./make-encrypted-hls-vod.sh <path to video file>
#!/bin/bash
openssl rand 16 > enc.key
printf "enc.key\nenc.key\n$(openssl rand -hex 16)" > keyinfo.drm
mkdir -p ./hls
ffmpeg -y \
-i "$1" \
@dlobjoie
dlobjoie / create-vod-hls.sh
Last active May 13, 2022 22:52 — forked from maitrungduc1410/create-vod-hls.sh
Bash scripts to create VOD HLS stream with ffmpeg (Extended version)
#!/usr/bin/env bash
START_TIME=$SECONDS
set -e
echo "-----START GENERATING HLS STREAM-----"
# Usage create-vod-hls.sh SOURCE_FILE [OUTPUT_NAME]
[[ ! "${1}" ]] && echo "Usage: create-vod-hls.sh SOURCE_FILE [OUTPUT_NAME]" && exit 1
# commenter/ajouter des lignes ici pour contrôler les rendus qui seront créés
renditions=(