0

So far i tried:

from moviepy.editor import *
videoclip = VideoFileClip("filename.mp4")
audioclip = AudioFileClip("audioname.mp3")

new_audioclip = CompositeAudioClip([audioclip])
videoclip.audio = new_audioclip
videoclip.write_videofile("new_filename.mp4")

But it takes very long time. I'd like to do it without re encoding. i also prefer opening video or audio clip from bytes in moviepy

not me
  • 1

1 Answers1

0

One way to do it is using ffmpeg_merge_video_audio from FFMPEG tools.

ffmpeg_merge_video_audio - merges video file video and audio file audio into one movie file output.
By default the merging is performed without re-encoding.


Code sample:

from moviepy.video.io import ffmpeg_tools
ffmpeg_tools.ffmpeg_merge_video_audio("filename.mp4", "audioname.mp3", 'new_filename.mp4')  # Merge audio and video without re-encoding

Note:
As far as I know, it's not possible to do it "from bytes" using MoviePy.

Rotem
  • 30,366
  • 4
  • 32
  • 65