import os


def generate_video(source_path, target_dir, video_dir, scene_name, quality):
    command_template = 'manim {0} {1} --media_dir {2} --video_output_dir {3} {4}'
    width = 2560
    height = 1440
    q_str = '-w'
    if quality == 'w':
        q_str = '-w'
    elif quality == 'h':
        q_str = '--high_quality'
        width = 1920
        height = 1080
    elif quality == 'm':
        q_str = '-m'
        width = 1280
        height = 720
    elif quality == 'l':
        q_str = '-l'
        width = 854
        height = 480
    command = command_template.format(source_path, scene_name, target_dir, video_dir, q_str)
    os.system(command)
    return width, height
