pycharmers.utils.audio_utils module¶
-
pycharmers.utils.audio_utils.
synthesize_audio
(video_path: str, audio_path: str, out_path: Optional[str] = None, use_moviepy: bool = False) → str[source]¶ Use
ffmpeg
directly ormoviepy
to synthesize audio (@audio_path
) to video (@video_path
)- Parameters
video_path (str) – The path to video fiile.
audio_path (str) – The path to audio (video) fiile.
out_path (Optional[str], optional) – The path to the created video (with audio) file. Defaults to
None
.use_moviepy (bool) – Whether to use
moviepy
to synthesize audio or not. Defaults toTrue
- Returns
The path to the created video (with audio) file.
- Return type
str
- Raises
FileNotFoundError – When
audio_path
is not found.TypeError – When there is no audio in
audio_path
Examples
>>> from pycharmers.utils import synthesize_audio >>> # Prepare Audio file (.mp3) >>> synthesize_audio(audio_path="sound.mp3", video_path="no_sound.mp4") >>> # Prepare Video with Audio file (.mp4) >>> synthesize_audio(audio_path="sound.mp4", video_path="no_sound.mp4")