Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.42k stars 1.55k forks source link

Exported audio/video with audio sounds terrible #1984

Open Looki2000 opened 1 year ago

Looki2000 commented 1 year ago

Expected Behavior

I want to save sine wave as audio file in its original quality.

Actual Behavior

The exported file have many sample skipping which results in a very awful sounding audio.

Steps to Reproduce the Problem

  1. run the following code:
    
    import moviepy.editor as mp
    from moviepy.audio.AudioClip import AudioArrayClip
    import numpy as np

audio_sample_rate = 48000

duration = 48000 time = np.arange(duration) frequency = 500 audio = np.sin(2 np.pi frequency (time / 24000)) 0.9

mono to stereo

audio = np.repeat(audio, 2).reshape((-1, 2))

create audio clip

audio_clip = AudioArrayClip(audio, fps=audio_sample_rate)

audio_clip.write_audiofile("audio.wav", fps=audio_sample_rate)



2. Listen to audio.wav and see in the audacity how bad the waveform looks.

#### Specifications

  - Python Version: 3.11.3
  - MoviePy Version: 1.0.3
  - Platform Name: Windows
  - Platform Version: 10