Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | 
         @@ -1,5 +1,26 @@ 
     | 
|
| 1 | 
         
             
            import gradio as gr
         
     | 
| 2 | 
         
             
            import subprocess
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 3 | 
         | 
| 4 | 
         
             
            def execute_command(command: str) -> None:
         
     | 
| 5 | 
         
             
                subprocess.run(command, check=True)
         
     | 
| 
         @@ -22,7 +43,12 @@ def infer(): 
     | 
|
| 22 | 
         | 
| 23 | 
         
             
                execute_command(command)
         
     | 
| 24 | 
         | 
| 25 | 
         
            -
                 
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 26 | 
         | 
| 27 | 
         
             
            with gr.Blocks() as demo:
         
     | 
| 28 | 
         
             
                with gr.Column():
         
     | 
| 
         | 
|
| 1 | 
         
             
            import gradio as gr
         
     | 
| 2 | 
         
             
            import subprocess
         
     | 
| 3 | 
         
            +
            import ffmpeg
         
     | 
| 4 | 
         
            +
             
     | 
| 5 | 
         
            +
            def convert_video(input_file, output_file, format='mp4'):
         
     | 
| 6 | 
         
            +
                try:
         
     | 
| 7 | 
         
            +
                    # Define input and output files
         
     | 
| 8 | 
         
            +
                    input_path = input_file
         
     | 
| 9 | 
         
            +
                    output_path = output_file + '.' + format
         
     | 
| 10 | 
         
            +
             
     | 
| 11 | 
         
            +
                    # Define ffmpeg command
         
     | 
| 12 | 
         
            +
                    ffmpeg_cmd = (
         
     | 
| 13 | 
         
            +
                        ffmpeg
         
     | 
| 14 | 
         
            +
                        .input(input_path)
         
     | 
| 15 | 
         
            +
                        .output(output_path, vcodec='libx264', acodec='aac')
         
     | 
| 16 | 
         
            +
                        .run()
         
     | 
| 17 | 
         
            +
                    )
         
     | 
| 18 | 
         
            +
             
     | 
| 19 | 
         
            +
                    print(f"Video converted successfully: {output_path}")
         
     | 
| 20 | 
         
            +
             
     | 
| 21 | 
         
            +
                except Exception as e:
         
     | 
| 22 | 
         
            +
                    print(f"Error converting video: {e}")
         
     | 
| 23 | 
         
            +
             
     | 
| 24 | 
         | 
| 25 | 
         
             
            def execute_command(command: str) -> None:
         
     | 
| 26 | 
         
             
                subprocess.run(command, check=True)
         
     | 
| 
         | 
|
| 43 | 
         | 
| 44 | 
         
             
                execute_command(command)
         
     | 
| 45 | 
         | 
| 46 | 
         
            +
                # Convert video to compatible codecs
         
     | 
| 47 | 
         
            +
                input_file_path = f"output_video/{output_name}.mp4"
         
     | 
| 48 | 
         
            +
                output_file_path = f"{output_name}"
         
     | 
| 49 | 
         
            +
                convert_video(input_file_path, output_file_path)
         
     | 
| 50 | 
         
            +
             
     | 
| 51 | 
         
            +
                return output_file_path
         
     | 
| 52 | 
         | 
| 53 | 
         
             
            with gr.Blocks() as demo:
         
     | 
| 54 | 
         
             
                with gr.Column():
         
     |