File size: 1,958 Bytes
0ad7e2a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
Split tab for Video Model Studio UI
"""

import gradio as gr
import logging
from typing import Dict, Any, List, Optional

from .base_tab import BaseTab

logger = logging.getLogger(__name__)

class SplitTab(BaseTab):
    """Split tab for scene detection and video splitting"""
    
    def __init__(self, app_state):
        super().__init__(app_state)
        self.id = "split_tab"
        self.title = "2️⃣  Split"
    
    def create(self, parent=None) -> gr.TabItem:
        """Create the Split tab UI components"""
        with gr.TabItem(self.title, id=self.id) as tab:
            with gr.Row():
                self.components["split_title"] = gr.Markdown("## Splitting of 0 videos (0 bytes)")
            
            with gr.Row():
                with gr.Column():
                    self.components["detect_btn"] = gr.Button("Split videos into single-camera shots", variant="primary")
                    self.components["detect_status"] = gr.Textbox(label="Status", interactive=False)

                with gr.Column():
                    self.components["video_list"] = gr.Dataframe(
                        headers=["name", "status"],
                        label="Videos to split",
                        interactive=False,
                        wrap=True
                    )
                    
        return tab
    
    def connect_events(self) -> None:
        """Connect event handlers to UI components"""
        # Scene detection button event
        self.components["detect_btn"].click(
            fn=self.app.start_scene_detection,
            inputs=[self.app.tabs["import_tab"].components["enable_automatic_video_split"]],
            outputs=[self.components["detect_status"]]
        )
        
    def refresh(self) -> Dict[str, Any]:
        """Refresh the video list with current data"""
        videos = self.app.splitter.list_unprocessed_videos()
        return {
            "video_list": videos
        }