Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7d6ecf1
feat: add ingest module (hls)
sebastianpiq Dec 8, 2025
8cc31ff
feat: implement hls importer
sebastianpiq Dec 9, 2025
ea83ea0
Merge branch 'main' into feat/hls-ingest-module
sebastianpiq Dec 9, 2025
c1d9c3f
chore: update dependencies
sebastianpiq Dec 9, 2025
4027289
refactor: rename `InputFormat` to `ImportType` and use `hang::import:…
sebastianpiq Dec 9, 2025
ab19cdf
refactor: Rename `Media` and `Manifest` structs to `ImportMedia` and …
sebastianpiq Dec 9, 2025
d03f54d
refactor: extract run_loop helper and improve code quality
sebastianpiq Dec 10, 2025
8891ee3
Merge branch 'main' into feat/hls-ingest-module
sebastianpiq Dec 10, 2025
d00ad22
Recover removed comments
sebastianpiq Dec 11, 2025
5606b97
Recover removed comments
sebastianpiq Dec 11, 2025
bec9bfe
rename HLS ingestion from `ingest-hls` to `pub-hls`
sebastianpiq Dec 11, 2025
a9b87d1
Improve code style
sebastianpiq Dec 11, 2025
af60a6e
Code optimization
sebastianpiq Dec 11, 2025
bcf48bd
Merge remote-tracking branch 'origin/main' into feat/hls-ingest-module
kixelated Dec 12, 2025
6206ba3
Reshuffle the import stuff a bit.
kixelated Dec 12, 2025
bf9e958
Resolve merge conflicts and revamp publish CLI
sebastianpiq Dec 15, 2025
37ae6d0
refactor: Simplify Fmp4 catalog management to always use the broadcas…
sebastianpiq Dec 15, 2025
bd98a40
refactor: remove redundant MediaType enum from HLS importer and use b…
sebastianpiq Dec 16, 2025
0bab310
refactor: Fmp4 importer now uses the broadcast's existing catalog ins…
sebastianpiq Dec 16, 2025
060af17
Merge branch 'main' into feat/hls-ingest-module
sebastianpiq Dec 17, 2025
8307f3c
feat: directly define `pub-hls` recipe and explicitly pass `fmp4` for…
sebastianpiq Dec 17, 2025
401e840
feat: Add a justfile command to serve HLS
sebastianpiq Dec 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ node_modules
*.jwk
*.jwt

# HLS stream output (just hls-stream)
dev/hls_*/

# We're using bun (and sometimes deno)
package-lock.json
yarn.lock
Expand Down
140 changes: 140 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 75 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ pub name url="http://localhost:4443/anon" *args:
-i "dev/{{name}}.fmp4" \
-c copy \
-f mp4 -movflags cmaf+separate_moof+delay_moov+skip_trailer+frag_every_frame \
- | cargo run --bin hang -- publish --url "{{url}}" --name "{{name}}" {{args}}
- | cargo run --bin hang -- publish --url "{{url}}" --name "{{name}}" fmp4 {{args}}

# Ingest a live HLS media playlist and publish it via hang (full ladder).
pub-hls url name="demo" relay="http://localhost:4443/anon":
cargo run --bin hang -- publish --url "{{relay}}" --name "{{name}}" hls --playlist "{{url}}"

# Publish a video using H.264 Annex B format to the localhost relay server
pub-h264 name url="http://localhost:4443/anon" *args:
Expand Down Expand Up @@ -287,3 +290,74 @@ update:
build:
bun run --filter='*' build
cargo build

# Generate and serve an HLS stream from a video for testing pub-hls
hls-stream name="bbb" port="8000":
#!/usr/bin/env bash
set -euo pipefail

just download "{{name}}"

INPUT="dev/{{name}}.mp4"
OUT_DIR="dev/hls_{{name}}"

rm -rf "$OUT_DIR"
mkdir -p "$OUT_DIR/video_1080p" "$OUT_DIR/video_144p" "$OUT_DIR/audio"

START_NUMBER=$(date +%s)

cat > "$OUT_DIR/master.m3u8" << 'EOF'
#EXTM3U

#EXT-X-MEDIA:TYPE=AUDIO,NAME="Stereo",GROUP-ID="audio",DEFAULT=YES,AUTOSELECT=YES,URI="audio/audio.m3u8"

#EXT-X-STREAM-INF:BANDWIDTH=4500000,CODECS="avc1.640029,mp4a.40.2",RESOLUTION=1920x1080,AUDIO="audio"
video_1080p/video.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=350000,CODECS="avc1.640029,mp4a.40.2",RESOLUTION=256x144,AUDIO="audio"
video_144p/video.m3u8
EOF

sed -i 's/^\t//' "$OUT_DIR/master.m3u8"

echo ">>> Starting HLS stream generation..."
echo ">>> Master playlist: http://localhost:{{port}}/master.m3u8"

cleanup() {
echo "Shutting down..."
kill $(jobs -p) 2>/dev/null || true
exit 0
}
trap cleanup SIGINT SIGTERM

ffmpeg -loglevel warning -re -stream_loop -1 -i "$INPUT" \
-map 0:v:0 -r 25 -preset veryfast -g 50 -keyint_min 50 -sc_threshold 0 \
-c:v libx264 -profile:v high -level 4.1 -pix_fmt yuv420p -tag:v avc1 \
-bsf:v dump_extra -b:v 4M -vf "scale=1920:-2" \
-f hls -hls_time 2 -hls_list_size 12 \
-hls_flags independent_segments+delete_segments \
-hls_segment_type fmp4 -hls_fmp4_init_filename init.mp4 \
-hls_segment_filename "$OUT_DIR/video_1080p/segment_%09d.m4s" \
-start_number "$START_NUMBER" "$OUT_DIR/video_1080p/video.m3u8" &

ffmpeg -loglevel warning -re -stream_loop -1 -i "$INPUT" \
-map 0:v:0 -r 25 -preset veryfast -g 50 -keyint_min 50 -sc_threshold 0 \
-c:v libx264 -profile:v high -level 4.1 -pix_fmt yuv420p -tag:v avc1 \
-bsf:v dump_extra -b:v 300k -vf "scale=256:-2" \
-f hls -hls_time 2 -hls_list_size 12 \
-hls_flags independent_segments+delete_segments \
-hls_segment_type fmp4 -hls_fmp4_init_filename init.mp4 \
-hls_segment_filename "$OUT_DIR/video_144p/segment_%09d.m4s" \
-start_number "$START_NUMBER" "$OUT_DIR/video_144p/video.m3u8" &

ffmpeg -loglevel warning -re -stream_loop -1 -i "$INPUT" \
-map 0:a:0 -c:a aac -b:a 128k \
-f hls -hls_time 2 -hls_list_size 12 \
-hls_flags independent_segments+delete_segments \
-hls_segment_type fmp4 -hls_fmp4_init_filename init.mp4 \
-hls_segment_filename "$OUT_DIR/audio/segment_%09d.m4s" \
-start_number "$START_NUMBER" "$OUT_DIR/audio/audio.m3u8" &

sleep 2
echo ">>> HTTP server: http://localhost:{{port}}/"
cd "$OUT_DIR" && python3 -m http.server {{port}}
1 change: 1 addition & 0 deletions rs/hang-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ path = "src/main.rs"
[dependencies]
anyhow = { version = "1", features = ["backtrace"] }
axum = { version = "0.8", features = ["tokio"] }
bytes = "1.10"
clap = { version = "4", features = ["derive"] }
hang = { workspace = true }
hyper-serve = { version = "0.6", features = ["tls-rustls"] }
Expand Down
Loading
Loading