Simple functions to speed up audio and video to a specific multiply rate using Python

def speed_up_audio(input_file, output_file, speed_factor=1.2):
    # Run ffmpeg command to speed up audio
    command = ['ffmpeg', '-i', input_file, '-filter:a', f'atempo={speed_factor}', output_file, '-y']
    subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    return output_file

def speed_up_video(video_path, output_path):
    from moviepy.editor import VideoFileClip
   
    if video_path == output_path:
        raise ValueError("Output path cannot be the same as input path")

    clip = VideoFileClip(video_path)
    sped_up_clip = clip.speedx(1.2)
    sped_up_clip.write_videofile(output_path)
    return output_path

Comments

Popular posts from this blog

Apple iPad Air (2022) Specifications and Review in 2023

17-year-old suspect in fatal stabbing at Taylor Swift-themed dance event ID’d

Exercise vs Diet