Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,11 +3,11 @@ import os
|
|
| 3 |
import zipfile
|
| 4 |
import rarfile
|
| 5 |
from PyPDF2 import PdfReader, PdfWriter
|
| 6 |
-
from moviepy.editor import VideoFileClip
|
| 7 |
from pydub import AudioSegment
|
| 8 |
from PIL import Image
|
| 9 |
import pdf2image
|
| 10 |
import streamlit as st
|
|
|
|
| 11 |
|
| 12 |
def convert_file(input_path, output_path):
|
| 13 |
if input_path.endswith('.pdf'):
|
|
@@ -21,9 +21,8 @@ def convert_file(input_path, output_path):
|
|
| 21 |
webp_images[0].save(output_path, 'PDF', resolution=100.0, save_all=True, append_images=webp_images[1:])
|
| 22 |
|
| 23 |
elif input_path.endswith('.mp4'):
|
| 24 |
-
# Convert MP4 to MKV
|
| 25 |
-
|
| 26 |
-
video.write_videofile(output_path, codec='libx264')
|
| 27 |
|
| 28 |
elif input_path.endswith('.wav'):
|
| 29 |
# Convert WAV to MP3
|
|
|
|
| 3 |
import zipfile
|
| 4 |
import rarfile
|
| 5 |
from PyPDF2 import PdfReader, PdfWriter
|
|
|
|
| 6 |
from pydub import AudioSegment
|
| 7 |
from PIL import Image
|
| 8 |
import pdf2image
|
| 9 |
import streamlit as st
|
| 10 |
+
import ffmpeg
|
| 11 |
|
| 12 |
def convert_file(input_path, output_path):
|
| 13 |
if input_path.endswith('.pdf'):
|
|
|
|
| 21 |
webp_images[0].save(output_path, 'PDF', resolution=100.0, save_all=True, append_images=webp_images[1:])
|
| 22 |
|
| 23 |
elif input_path.endswith('.mp4'):
|
| 24 |
+
# Convert MP4 to MKV using ffmpeg
|
| 25 |
+
ffmpeg.input(input_path).output(output_path, codec='libx264').run()
|
|
|
|
| 26 |
|
| 27 |
elif input_path.endswith('.wav'):
|
| 28 |
# Convert WAV to MP3
|