【问题标题】:How to merge mp3 and mp4 in python / Mute a mp4 file and add a mp3 file on it如何在 python 中合并 mp3 和 mp4 / 将 mp4 文件静音并在其上添加 mp3 文件
【发布时间】:2020-09-14 16:58:11
【问题描述】:

我想在 python 中合并一个 mp3 和一个 mp4,如果可能的话,使用 moviepy 库。

但是我的 mp4 视频里面有声音,所以我想之前删除这个声音。

【问题讨论】:

    标签: python ffmpeg moviepy


    【解决方案1】:

    我很难找到有用的东西,所以我想很多人也可能有这个困难,所以这里是对我有用的代码:

    def combine_audio(vidname, audname, outname, fps=60): 
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    combine_audio("test.mp4", "test.mp3", "test_over.mp4") # i create a new file
    combine_audio("test.mp4", "test.mp3", "test.mp4") # i rewrite on the same file```
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-09
      • 2016-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-18
      相关资源
      最近更新 更多