File size: 1,021 Bytes
2f2406a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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}")