The central asset repository for high-performance HLS (HTTP Live Streaming) and MP4 video delivery across the Franc Vila and Badreya web platforms.
- π Overview
- β‘ Why HLS (HTTP Live Streaming)?
- π Repository Structure
- βοΈ Prerequisites
- π How to Convert Videos
- π οΈ How the Conversion Script Works
- π URL Structure & Hosting
- π» React & Next.js Integration
- π Developer Workflow
This repository acts as the media hosting and processing backend for Badreya and Franc Vila web platforms. Instead of serving massive static .mp4 files directlyβwhich delays page rendering, causes buffering, and consumes excessive mobile dataβvideos are processed into HLS (HTTP Live Streaming) directories. This allows the websites to serve fast, modern, and adaptive video streams tailored directly to each user's network connection.
- Adaptive Bitrate Streaming: The player automatically shifts between 1080p (high fidelity) and 750p (lighter weight) depending on the user's internet speed, ensuring zero buffer lags.
- Instant Playback (Fast Start): The video is split into small chunks (8 seconds each). The browser only needs to download the first segment to start playing, resulting in an instant-on user experience.
- Broad Native Compatibility: Works natively on Safari and iOS devices, and seamlessly on Chrome, Firefox, and Edge via standard integration libraries (such as
hls.js).
video-v2/
βββ Reloj-azul-y-negro-FVGB.mp4 # Original high-res MP4 source files
βββ fin3.mp4
βββ frnkvll.mp4
βββ hls/ # HLS-converted streaming bundles
βββ convert_hls.sh # π οΈ Smart HLS Bash conversion script
β
βββ Reloj-azul-y-negro-FVGB/ # Converted HLS output directory
β βββ master.m3u8 # π Master Playlist file (Adaptive index)
β βββ v0/ # Stream 0: 1080p (High Quality)
β β βββ index.m3u8 # Playlist for the 1080p stream
β β βββ seg000.ts... # Segmented 1080p video files (TS chunks)
β βββ v1/ # Stream 1: 750p (Medium Quality)
β βββ index.m3u8 # Playlist for the 750p stream
β βββ seg000.ts... # Segmented 750p video files (TS chunks)
β
βββ fin3/ # HLS files for fin3
βββ frnkvll/ # HLS files for frnkvll
βββ ...
To run the local conversion script on your machine, you need FFmpeg and FFprobe installed:
# Install FFmpeg using Homebrew on macOS
brew install ffmpegVerify that the utilities are installed correctly by running:
ffmpeg -version
ffprobe -versionFollow these steps to convert any standard .mp4 video file into an HLS adaptive streaming bundle:
Open your terminal and change directory to the hls folder:
cd hlsRun the script by providing the path to your source .mp4 file and the desired output folder name:
./convert_hls.sh <input_file_path> <output_directory_name>- To convert the
fin3.mp4video located in the root folder:./convert_hls.sh ../fin3.mp4 fin3
- To convert the
frnkvll.mp4video:./convert_hls.sh ../frnkvll.mp4 frnkvll
- To convert an external video on your desktop:
./convert_hls.sh ~/Desktop/my-new-watch.mp4 my-new-watch
The convert_hls.sh script automates a premium transcoding pipeline:
- Resolution & Compression Tiers:
v0(1080p - High Quality): Uses a high-fidelity Constant Rate FactorCRF 18(visually near-lossless), high-efficiencyslowpreset compression, and crystal-clear256k AACstereo audio.v1(750p - Medium Quality): Uses a balancedCRF 21for optimized mobile viewing and 4G streaming, and compact128k AACstereo audio.
- Chunk Segmentation:
- Cuts the video streams into small, independent 8-second segments (
.tsfiles).
- Cuts the video streams into small, independent 8-second segments (
- Dynamic Master Playlist Generation (
master.m3u8):- Uses
ffprobeto query the precise output resolutions dynamically, and writes a standard-compliant multi-variant playlist.
- Uses
This repository is hosted on GitHub Pages, serving files directly as a static content delivery network (CDN):
- GitHub Repository:
https://github.com/simaa99/video-v2 - Static Content Base URL:
https://simaa99.github.io/video-v2/
To play or stream any converted video in your code, target the folder's master.m3u8 playlist using this structure:
https://simaa99.github.io/video-v2/hls/<folder_name>/master.m3u8
- Blue/Black Watch Video (watch-v1):
https://simaa99.github.io/video-v2/hls/watch-v1/master.m3u8 - Jewelry Show Video (jewely-v1):
https://simaa99.github.io/video-v2/hls/jewely-v1/master.m3u8 - Jihad Show Video (jihad-v1):
https://simaa99.github.io/video-v2/hls/jihad-v1/master.m3u8
To play adaptive HLS streams smoothly in your web apps, we recommend implementing a custom video component utilizing hls.js for non-native browsers, and native fallback for Apple devices.
Here is a ready-to-use, optimized React component:
"use client";
import { useEffect, useRef } from "react";
import Hls from "hls.js";
interface HlsVideoPlayerProps {
src: string; // Path to the master.m3u8 file
poster?: string; // Image shown before the video starts
className?: string;
autoPlay?: boolean;
muted?: boolean;
loop?: boolean;
}
export default function HlsVideoPlayer({
src,
poster,
className = "",
autoPlay = true,
muted = true,
loop = true,
}: HlsVideoPlayerProps) {
const videoRef = useRef<HTMLVideoElement>(null);
useEffect(() => {
const video = videoRef.current;
if (!video) return;
let hls: Hls | null = null;
if (Hls.isSupported()) {
// For browsers without native HLS support (Chrome, Firefox, Edge, etc.)
hls = new Hls({
maxMaxBufferLength: 30, // Buffers up to 30 seconds ahead for fluid playback
});
hls.loadSource(src);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, () => {
if (autoPlay) {
video.play().catch((err) => console.log("Autoplay was blocked:", err));
}
});
} else if (video.canPlayType("application/vnd.apple.mpegurl")) {
// For browsers with native HLS support (Safari on macOS, iOS devices)
video.src = src;
video.addEventListener("loadedmetadata", () => {
if (autoPlay) {
video.play().catch((err) => console.log("Autoplay was blocked:", err));
}
});
}
return () => {
// Prevent memory leaks by destroying the HLS instance on component unmount
if (hls) {
hls.destroy();
}
};
}, [src, autoPlay]);
return (
<video
ref={videoRef}
poster={poster}
className={`w-full h-full object-cover ${className}`}
muted={muted}
loop={loop}
playsInline
controls
/>
);
}Use this checklist when introducing a new video asset to the system:
- 1. Transfer Video: Place the original
.mp4file in the rootvideo-v2/directory. - 2. Convert Video: Change directory to
hls/in your terminal and run the converter script:./convert_hls.sh ../my-video.mp4 my-video-folder
- 3. Inspect Outputs: Open the new directory and verify that
master.m3u8,v0/, andv1/were created successfully. - 4. Push to Git: Add, commit, and push the newly generated folders:
git add . git commit -m "feat: add HLS stream for my-video" git push origin main
- 5. Wait & Verify: Give GitHub Pages about a minute to complete deployment, then check the livestream URL directly in a player or browser:
https://simaa99.github.io/video-v2/hls/my-video-folder/master.m3u8 - 6. Integrate: Embed the new HLS URL into your target codebase using the
VideoPlayercomponent.
Designed with precision to provide the ultimate media streaming experience.