| # Hugging Face Deployment - Step by Step |
|
|
| ## Step 1: Hugging Face Account එකක් හදාගන්න |
|
|
| 1. https://huggingface.co/join වෙබ් අඩවියට යන්න |
| 2. Email එකක් දාලා Sign Up කරන්න |
| 3. Email එකේ verification link එක click කරන්න |
| 4. Login වෙන්න |
|
|
| ## Step 2: නව Space එකක් Create කරන්න |
|
|
| 1. Profile picture එක click කරන්න (top right corner) |
| 2. **"New Space"** button එක click කරන්න |
| 3. විස්තර fill කරන්න: |
| - **Space name**: `dulaksha-stream` (හෝ ඕන නමක්) |
| - **License**: MIT |
| - **Select SDK**: **Docker** (මේක select කරන්න ඕනේ) |
| - **Space hardware**: CPU basic - Free |
| 4. **"Create Space"** click කරන්න |
|
|
| ## Step 3: Files Upload කරන්න |
|
|
| ### Method 1: Web Interface එකෙන් (Easy) |
|
|
| 1. **"Files"** tab එක click කරන්න |
| 2. **"Add file"** > **"Upload files"** click කරන්න |
| 3. මේ files upload කරන්න එකින් එක: |
| - `server.js` |
| - `package.json` |
| - `Dockerfile` |
| - `.dockerignore` |
| 4. Upload වෙලා නැති files තියෙනවනම් repeat කරන්න |
|
|
| ### Method 2: Git එකෙන් (Advanced) |
|
|
| ```bash |
| git clone https://huggingface.co/spaces/YOUR-USERNAME/dulaksha-stream |
| cd dulaksha-stream |
| # Copy all files to this folder |
| git add . |
| git commit -m "Initial commit" |
| git push |
| ``` |
|
|
| ## Step 4: Build එක Wait කරන්න |
|
|
| 1. **"App"** tab එකට යන්න |
| 2. **"Building"** status එක පෙන්නන එක බලන්න |
| 3. **5-10 minutes** විතර wait කරන්න |
| 4. **"Running"** කියලා status එක change වෙනකල් wait කරන්න |
|
|
| Build එක fail වෙනවනම්: |
| - **"Logs"** tab එක check කරන්න |
| - Error message එක copy කරන්න |
|
|
| ## Step 5: URL එක ගන්න |
|
|
| Build එක success වුණාම ඔයාගේ app එක මේ URL එකේ available වෙයි: |
|
|
| ``` |
| https://YOUR-USERNAME-dulaksha-stream.hf.space |
| ``` |
|
|
| උදාහරණ: |
| ``` |
| https://dulaksha-dulaksha-stream.hf.space |
| ``` |
|
|
| ## Step 6: Test කරන්න |
|
|
| ### Browser එකෙන් Test: |
| 1. URL එක browser එකේ open කරන්න |
| 2. Server running කියලා පෙන්වන්න ඕන |
|
|
| ### Video Upload Test (Postman): |
|
|
| 1. Postman open කරන්න |
| 2. **New Request** create කරන්න |
| 3. Settings: |
| - **Method**: POST |
| - **URL**: `https://YOUR-USERNAME-dulaksha-stream.hf.space/upload` |
| - **Body**: form-data |
| - **Key**: `file` (type: File) |
| - **Value**: video file එකක් select කරන්න |
| 4. **Send** click කරන්න |
|
|
| ### cURL එකෙන් Test: |
|
|
| ```bash |
| curl -X POST -F "file=@video.mp4" https://YOUR-USERNAME-dulaksha-stream.hf.space/upload |
| ``` |
|
|
| ## Step 7: Response එක Check කරන්න |
|
|
| Upload success වුණාම මේ විදිහේ response එකක් එනවා: |
|
|
| ```json |
| { |
| "status": "success", |
| "stream_link": "https://YOUR-SPACE.hf.space/stream/123456/video.mp4", |
| "qualities": ["1080p", "720p", "480p"] |
| } |
| ``` |
|
|
| ## Video Quality Conversion |
|
|
| - **2160p (4K) video**: Convert to 1080p, 720p, 480p |
| - **1080p video**: Convert to 1080p, 720p, 480p |
| - **720p video**: Convert to 720p, 480p |
| - **480p video**: Keep as 480p |
|
|
| ## API Endpoints |
|
|
| ### Upload Video |
| ``` |
| POST /upload |
| Content-Type: multipart/form-data |
| Body: file (video file) |
| ``` |
|
|
| ### Stream File |
| ``` |
| GET /stream/:id/:filename |
| ``` |
|
|
| ### Download File |
| ``` |
| GET /download/:id/:filename |
| ``` |
|
|
| ## Important Notes |
|
|
| - **Bot connect වෙන්න විනාඩි 2-3ක් යනවා** - First upload එකට wait කරන්න |
| - **Large files වලට processing time වැඩියි** - 4K videos වලට 10-20 minutes යනවා |
| - **Stream links permanent** - කවදාවත් expire වෙන්නේ නැහැ |
| - **All files Telegram එකේ store වෙනවා** - Backup එකක් විදිහට |
|
|
| ## Common Issues |
|
|
| ### 1. Build Failed |
| **Solution**: Dockerfile එක හරියටම copy වෙලා තියෙනවද check කරන්න |
|
|
| ### 2. Service Unavailable |
| **Solution**: විනාඩි 2-3ක් wait කරලා retry කරන්න (bot connecting) |
|
|
| ### 3. Upload Timeout |
| **Solution**: |
| - File size අඩු කරන්න |
| - Better hardware tier එකක් select කරන්න (Settings > Hardware) |
|
|
| ### 4. FFmpeg Error |
| **Solution**: Video file එක corrupt වෙලා නැද්ද check කරන්න |
|
|
| ## Hardware Upgrade (Optional) |
|
|
| Free tier slow නම්: |
| 1. Space Settings > Hardware |
| 2. Upgrade කරන්න: |
| - CPU basic (Free) → CPU upgrade ($0.60/hour) |
| - GPU එකක් select කරන්න (faster conversion) |
|
|
| ## Files නෙරපන්න ඕනේ නම් |
|
|
| ```bash |
| # Hugging Face Space එකේ |
| Files > Delete කරන්න files |
| ``` |
|
|
| --- |
|
|
| **සියලු files මේ folder එකේ තියෙනවා. Upload කරන්න විතරයි ඕන!** |
|
|