- 2-3 videos in
Videosfolder:OOPs.mp4, etc. - Backend running at
http://localhost:3000 - MongoDB available
# 1. Make sure MongoDB is running:
# - Option 1: MongoDB locally (mongod running)
# - Option 2: MongoDB Atlas (set MONGO_URI environment variable)
# 2. Open PowerShell/Terminal
# 3. Navigate to Backend folder
cd "d:\HACKATHON PROJECTS\Acadly02-main\Backend"
# 4. Run upload script
node upload-videos.jsExpected Output:
🎬 ACADLY VIDEO UPLOADER
======================================================================
🔗 Connecting to MongoDB: mongodb://localhost:27017/acadly_videos
✅ Connected to MongoDB
📋 Ready to upload: 1 video(s)
[1/1] Object-Oriented Programming (OOPs)
📤 Uploading: OOPs.mp4
Size: 145.50 MB
✅ Uploaded successfully
Video ID: 507f1f77bcf86cd799439011
Stream URL: http://localhost:3000/api/videos/507f1f77bcf86cd799439011/stream
======================================================================
✅ Upload Complete! 1/1 video(s) uploaded
======================================================================
🎯 Next Steps:
1. Copy the Video IDs below
2. Update Frontend/js/video-metadata.js with these IDs
📺 Uploaded Videos:
1. Object-Oriented Programming (OOPs)
Video ID: 507f1f77bcf86cd799439011
Stream URL: http://localhost:3000/api/videos/507f1f77bcf86cd799439011/stream
Copy the Video ID: 507f1f77bcf86cd799439011
Replace the entire content with:
/**
* Acadly Video Metadata
* Defines all videos available in the platform
*/
// ====== VIDEO DATA ======
window.acadlyVideos = [
{
id: "507f1f77bcf86cd799439011", // <- Your Video ID from MongoDB
title: "Object-Oriented Programming (OOPs)",
description: "Complete guide to OOP concepts, classes, inheritance, and polymorphism",
category: "Programming",
subcategory: "Advanced",
duration: "60:00",
thumbnail: null,
src: "/api/videos/507f1f77bcf86cd799439011/stream", // <- Same Video ID
tags: ["OOP", "Programming", "Java"],
xpReward: 50,
rating: 4.5,
views: 125,
quiz: [], // Optional: Add quiz questions later
},
// Add more videos here if you have multiple:
// {
// id: "507f1f77bcf86cd799439022",
// title: "Data Structures",
// src: "/api/videos/507f1f77bcf86cd799439022/stream",
// },
];
// Default video (first in list)
window.currentVideoId = window.acadlyVideos[0]?.id || null;
// Optional: XP reward per video
window.videoXPMultiplier = {
default: 1,
difficult: 1.5,
easy: 0.8,
};-
Start Backend Server (if not running):
cd "d:\HACKATHON PROJECTS\Acadly02-main\Backend" npm start
-
Open Video Player:
- Visit: http://localhost:3000/Frontend/videoplayer.html
- OR: http://localhost:3000/index.html → Click "Video Hub"
-
Select & Play Your Video:
- Click on your video from the playlist
- Click the Play button
▶️ - Video streams from MongoDB! 🎉
If you have OOPs.mp4, DataStructures.mp4, Algorithms.mp4:
Edit: Backend/upload-videos.js (lines 83-117)
const videosToUpload = [
{
filePath: "OOPs.mp4",
metadata: {
title: "Object-Oriented Programming",
description: "OOP concepts",
category: "Programming",
duration: 3600,
xpReward: 50,
},
},
{
filePath: "DataStructures.mp4",
metadata: {
title: "Data Structures",
description: "Arrays, linked lists, trees",
category: "Programming",
duration: 2400,
xpReward: 35,
},
},
{
filePath: "Algorithms.mp4",
metadata: {
title: "Algorithm Design",
description: "Sorting and searching",
category: "Programming",
duration: 2000,
xpReward: 30,
},
},
];node upload-videos.jsExample output:
1. Object-Oriented Programming (OOPs)
Video ID: 507f1f77bcf86cd799439011
2. Data Structures
Video ID: 507f1f77bcf86cd799439022
3. Algorithm Design
Video ID: 507f1f77bcf86cd799439033
window.acadlyVideos = [
{
id: "507f1f77bcf86cd799439011",
title: "Object-Oriented Programming",
src: "/api/videos/507f1f77bcf86cd799439011/stream",
duration: "60:00",
category: "Programming",
xpReward: 50,
},
{
id: "507f1f77bcf86cd799439022",
title: "Data Structures",
src: "/api/videos/507f1f77bcf86cd799439022/stream",
duration: "40:00",
category: "Programming",
xpReward: 35,
},
{
id: "507f1f77bcf86cd799439033",
title: "Algorithm Design",
src: "/api/videos/507f1f77bcf86cd799439033/stream",
duration: "33:00",
category: "Programming",
xpReward: 30,
},
];Your Video File (OOPs.mp4)
↓
Upload Script
↓
MongoDB GridFS (stores binary data)
MongoDB VideoMetadata (stores title, duration, etc.)
↓
Frontend gets Video ID: 507f1f77bcf86cd799439011
↓
Requests: GET /api/videos/507f1f77bcf86cd799439011/stream
↓
Backend streams video from GridFS
↓
HTML5 Video Player receives stream
↓
User sees video playing! ▶️
- MongoDB running (mongod or Docker)
- Backend server running (npm start)
- Videos in
Videosfolder - Ran
node upload-videos.js - Copied Video IDs from console output
- Updated
Frontend/js/video-metadata.js - Visited videoplayer.html
- Playing video successfully! 🎉
Solution: Start MongoDB
# Windows: Start MongoDB Compass app or:
docker run -d -p 27017:27017 mongoCheck:
- Is backend running? (
npm startin Backend folder) - Is Video ID correct in
video-metadata.js? - Is MongoDB running?
Test:
# Visit this URL to test streaming:
http://localhost:3000/api/videos/507f1f77bcf86cd799439011/stream
# Should show video download dialog or start playingSolution: Install missing module
cd Backend
npm install mongooseUsing MongoDB Compass:
- Connect to
mongodb://localhost:27017 - Database:
acadly_videos - Collections:
videos.files→ Shows your video filesvideometadatas→ Shows video metadata
Each entry should have:
_id: The Video IDtitle: Your video titlefile_id: Reference to GridFS fileduration: Video length in secondscategory: "Programming" or whatever you set
After videos are playing:
- Add Quiz: Questions that appear while watching
- Track Progress: Save user's watch position
- Achievements: Award badges for completing videos
- Analytics: View video statistics (views, avg rating)
- Search: Find videos by title or category
-
Test Video Individually:
curl http://localhost:3000/api/videos/507f1f77bcf86cd799439011/stream -o test.mp4 # Should download video file to test.mp4 -
Update Metadata After Upload:
- Edit videos in MongoDB Compass
- Add thumbnails, change duration, update ratings
-
Bulk Upload:
- Add all videos to
videosToUploadarray - Run script once to upload all
- Add all videos to
Ready? Let's go! 🚀
Start with Step 1 above!