@@ -701,125 +701,69 @@ def main():
701701
702702 # Sidebar for file uploads and settings
703703 with st .sidebar :
704- st .header ("📁 File Upload" )
705-
706- # Drag and drop area
707- create_drag_drop_area ()
708-
709- # Video file upload with enhanced features
704+ st .header ("📁 Upload & Edit Files" )
705+ # Video upload
710706 video_file = st .file_uploader (
711707 "Upload Video File" ,
712- type = [' mp4' , ' avi' , ' mov' , ' mkv' , ' webm' ],
713- help = "Upload your raw video footage (max 2GB - increased limit! )" ,
708+ type = [" mp4" , " avi" , " mov" , " mkv" , " webm" ],
709+ help = "Upload your raw video footage (max 2GB)" ,
714710 key = "video_uploader"
715711 )
716-
717- # Display upload progress, file info, and thumbnail
718- if video_file is not None :
712+ if video_file :
719713 file_size_mb = video_file .size / (1024 * 1024 )
720- max_size_mb = config .get ('file_limits' , {}).get ('max_video_size_mb' , 4096 )
721-
722- # Comprehensive file validation
723- validation_errors = []
724-
725- # Check file size
726- if file_size_mb > max_size_mb :
727- validation_errors .append (f"File too large: { file_size_mb :.1f} MB. Maximum allowed: { max_size_mb } MB" )
728-
729- # Check file extension
730- allowed_extensions = config .get ('video' , {}).get ('supported_formats' , ['.mp4' , '.avi' , '.mov' , '.mkv' , '.webm' ])
731714 file_ext = '.' + video_file .name .split ('.' )[- 1 ].lower ()
732- if file_ext not in allowed_extensions :
733- validation_errors .append (f"Unsupported format: { file_ext } . Allowed: { ', ' .join (allowed_extensions )} " )
734-
735- # Check minimum file size (1MB minimum)
736- if file_size_mb < 1 :
737- validation_errors .append (f"File too small: { file_size_mb :.1f} MB. Minimum size: 1MB" )
738-
739- # Display validation results
740- if validation_errors :
741- for error in validation_errors :
742- st .error (f"⚠️ { error } " )
743- st .warning ("Please upload a valid video file that meets all requirements." )
744- else :
745- st .success (f"✅ Video loaded: { file_size_mb :.1f} MB" )
746-
747- # Display file metadata
748- with st .expander ("📋 File Information" , expanded = False ):
749- col1 , col2 = st .columns (2 )
750- with col1 :
751- st .write (f"**Filename:** { video_file .name } " )
752- st .write (f"**Size:** { file_size_mb :.1f} MB" )
753- st .write (f"**Format:** { file_ext .upper ()} " )
754- with col2 :
755- st .write (f"**Status:** ✅ Valid" )
756- st .write (f"**Validation:** Passed all checks" )
757-
758- # Generate and display thumbnail
759- with st .expander ("📺 Video Preview" , expanded = True ):
760- try :
761- # Save uploaded file temporarily for thumbnail generation
762- with tempfile .NamedTemporaryFile (delete = False , suffix = file_ext ) as tmp_file :
763- tmp_file .write (video_file .getvalue ())
764- temp_path = tmp_file .name
765-
766- thumbnail = generate_video_thumbnail (temp_path )
767- if thumbnail :
768- st .image (thumbnail , caption = "Video Thumbnail" , use_column_width = True )
769- else :
770- st .info ("Could not generate thumbnail - file may be corrupted or in an unsupported codec" )
771-
772- # Clean up temporary file
773- os .unlink (temp_path )
774- except Exception as e :
775- st .warning (f"Thumbnail generation failed: { e } " )
776- st .info ("This may indicate a corrupted file or unsupported codec" )
777-
778- # Script file upload
715+ st .markdown (f"**Video:** `{ video_file .name } ` ({ file_size_mb :.1f} MB, { file_ext .upper ()} )" )
716+ with st .expander ("Preview Video" , expanded = True ):
717+ try :
718+ with tempfile .NamedTemporaryFile (delete = False , suffix = file_ext ) as tmp_file :
719+ tmp_file .write (video_file .getvalue ())
720+ temp_path = tmp_file .name
721+ thumbnail = generate_video_thumbnail (temp_path )
722+ if thumbnail :
723+ st .image (thumbnail , caption = "Video Thumbnail" , use_column_width = True )
724+ else :
725+ st .info ("Could not generate thumbnail." )
726+ os .unlink (temp_path )
727+ except Exception as e :
728+ st .warning (f"Thumbnail error: { e } " )
729+ # Script upload
779730 script_file = st .file_uploader (
780731 "Upload Script File" ,
781- type = [' txt' , ' srt' , ' vtt' , ' ass' ],
782- help = "Upload the corresponding script or subtitles (max 500KB)" ,
732+ type = [" txt" , " srt" , " vtt" , " ass" ],
733+ help = "Upload script or subtitles (max 500KB)" ,
783734 key = "script_uploader"
784735 )
785-
786- # Audio file upload (new feature)
736+ if script_file :
737+ st .markdown (f"**Script:** `{ script_file .name } ` ({ script_file .size / 1024 :.1f} KB)" )
738+ with st .expander ("View/Edit Script" , expanded = False ):
739+ content = script_file .read ().decode (errors = "ignore" )
740+ edited = st .text_area ("Edit Script Content" , value = content , height = 200 )
741+ # Audio upload
787742 audio_file = st .file_uploader (
788743 "Upload Audio File (Optional)" ,
789- type = [' mp3' , ' wav' , ' aac' , ' flac' ],
790- help = "Upload separate audio file for analysis (max 500MB)" ,
744+ type = [" mp3" , " wav" , " aac" , " flac" ],
745+ help = "Upload audio for analysis (max 500MB)" ,
791746 key = "audio_uploader"
792747 )
793-
748+ if audio_file :
749+ st .markdown (f"**Audio:** `{ audio_file .name } ` ({ audio_file .size / 1024 / 1024 :.1f} MB)" )
794750 st .divider ()
795-
796- # Processing options
797751 st .header ("⚙️ Analysis Options" )
798-
799752 analyze_video = st .checkbox ("Analyze Video Content" , value = True )
800753 analyze_audio = st .checkbox ("Analyze Audio" , value = True )
801754 analyze_script = st .checkbox ("Analyze Script" , value = bool (script_file ))
802-
803755 st .divider ()
804-
805- # Sensitivity settings
806756 st .header ("🎛️ Sensitivity Settings" )
807-
808757 emotion_threshold = st .slider (
809- "Emotion Change Sensitivity" ,
810- 0.1 , 1.0 , 0.3 , 0.1 ,
758+ "Emotion Change Sensitivity" , 0.1 , 1.0 , 0.3 , 0.1 ,
811759 help = "How sensitive to emotional changes in content"
812760 )
813-
814761 scene_threshold = st .slider (
815- "Scene Change Sensitivity" ,
816- 0.1 , 1.0 , 0.4 , 0.1 ,
762+ "Scene Change Sensitivity" , 0.1 , 1.0 , 0.4 , 0.1 ,
817763 help = "How sensitive to visual scene changes"
818764 )
819-
820765 min_cut_interval = st .slider (
821- "Minimum Cut Interval (seconds)" ,
822- 0.5 , 10.0 , 2.0 , 0.5 ,
766+ "Minimum Cut Interval (seconds)" , 0.5 , 10.0 , 2.0 , 0.5 ,
823767 help = "Minimum time between suggested cuts"
824768 )
825769
0 commit comments