Upload 5 files
Browse files- README.md +14 -0
- app.py +8 -7
- backend/video_processor.py +1 -1
README.md
CHANGED
|
@@ -8,3 +8,17 @@ sdk_version: "4.24.0"
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
---
|
| 11 |
+
|
| 12 |
+
# NHAI DAMS Phase 1: Video to Frame Extraction
|
| 13 |
+
|
| 14 |
+
This Gradio app allows you to upload a drone video and extract frames every 1 second.
|
| 15 |
+
|
| 16 |
+
### Features:
|
| 17 |
+
- Supports `.mp4` files
|
| 18 |
+
- Saves extracted frames to `frames/<video_name>/`
|
| 19 |
+
- Works on Gradio 4.24+ with `type="filepath"` support
|
| 20 |
+
|
| 21 |
+
### How to Use:
|
| 22 |
+
1. Upload your video
|
| 23 |
+
2. Click "Start Frame Extraction"
|
| 24 |
+
3. View output path and frame count
|
app.py
CHANGED
|
@@ -1,16 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from backend.video_processor import extract_frames
|
| 3 |
|
| 4 |
-
def process_video(
|
| 5 |
-
saved, folder = extract_frames(
|
| 6 |
return f"✅ Extracted {saved} frames to {folder}"
|
| 7 |
|
| 8 |
with gr.Blocks() as demo:
|
| 9 |
-
gr.Markdown("# 🎥
|
| 10 |
-
video_input = gr.File(label="Upload Sample Drone Video (.mp4)", type="file")
|
| 11 |
-
output = gr.Textbox(label="Extraction Status")
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from backend.video_processor import extract_frames
|
| 3 |
|
| 4 |
+
def process_video(video_path):
|
| 5 |
+
saved, folder = extract_frames(video_path)
|
| 6 |
return f"✅ Extracted {saved} frames to {folder}"
|
| 7 |
|
| 8 |
with gr.Blocks() as demo:
|
| 9 |
+
gr.Markdown("# 🎥 NHAI DAMS Phase 1: Video to Frame Extractor")
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
video_input = gr.File(label="Upload Drone Video (.mp4)", type="filepath")
|
| 12 |
+
result_output = gr.Textbox(label="Status")
|
| 13 |
+
|
| 14 |
+
process_button = gr.Button("Start Frame Extraction")
|
| 15 |
+
process_button.click(fn=process_video, inputs=[video_input], outputs=[result_output])
|
| 16 |
|
| 17 |
demo.launch()
|
backend/video_processor.py
CHANGED
|
@@ -9,7 +9,7 @@ def extract_frames(video_path, output_dir='frames', every_n_sec=1):
|
|
| 9 |
|
| 10 |
cap = cv2.VideoCapture(video_path)
|
| 11 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
| 12 |
-
interval = int(fps * every_n_sec)
|
| 13 |
frame_idx = 0
|
| 14 |
saved = 0
|
| 15 |
|
|
|
|
| 9 |
|
| 10 |
cap = cv2.VideoCapture(video_path)
|
| 11 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
| 12 |
+
interval = max(1, int(fps * every_n_sec))
|
| 13 |
frame_idx = 0
|
| 14 |
saved = 0
|
| 15 |
|