vidverse / app /functions /helper.py
badal
feat: initial commit
2f2406a
from subprocess import run, DEVNULL
from app.captioning import generate_sub
def download_video(link, output):
command = ["yt-dlp", "-f", "bv*[ext=mp4]", "-o", output, link]
run(command, stdout=DEVNULL, stderr=DEVNULL)
def download_audio(link, output):
command = ["yt-dlp", "-f", "ba*[ext=m4a]", "-o", output, link]
run(command, stdout=DEVNULL, stderr=DEVNULL)
def m4a_to_wav(input_video, output):
command = ["ffmpeg", "-i", input_video, output]
run(command, stdout=DEVNULL, stderr=DEVNULL)
print(f"m4a to wav converted, Input: {input_video}, Output: {output}")
def audio_to_srt(language, audio_file, output):
generate_sub(language, audio_file, output)
print("audio to srt converted")
def merge_video_audio(video_file, audio_file, output):
command = ["ffmpeg", "-i", video_file, "-i", audio_file, "-c:v", "copy", "-c:a", "copy", output]
run(command, stdout=DEVNULL, stderr=DEVNULL)
print(f"video and audio merged, Input: {video_file}, {audio_file}, Output: {output}")