输出的视频没有声音 [英] Output video has no sound

查看:389
本文介绍了输出的视频没有声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Moviepy中连接视频时,在输出文件中没有声音,我尝试使用各种参数但没有任何提示.

When I concatenate videos in Moviepy I get no sound in the output file, I try using various parameters but no clue.

这是我的代码:

import moviepy.editor as mp
import os

dir_path = os.path.dirname(os.path.realpath(__file__))
clip1 = mp.VideoFileClip("V1.mp4")
clip2 = mp.VideoFileClip(dir_path+"\\V2.mp4")
clip3 = mp.VideoFileClip(dir_path+"\\V3.mp4")

output_movie = 'new_movie1.mp4'

final_clip = mp.concatenate_videoclips([clip1,clip2,clip3])

final_clip.write_videofile(output_movie, remove_temp=False, bitrate="5000k",audio=True, audio_codec="aac",codec='mpeg4')

我尝试了codec="libx264"

推荐答案

我通过添加临时音频文件路径来解决此问题.只需将您的最后一行代码更改为此:

I solved this by adding a temporary audio file path. Just change your final line of code to this:

final_clip.write_videofile(output_movie, temp_audiofile='temp-audio.m4a', remove_temp=True, codec="libx264", audio_codec="aac")

您正在指定MoviePy可以在哪里存储其临时音频文件.另外,将参数remove_temp更改为True,这样临时文件将被自动清理.

You're specifying where MoviePy can store its temp audio file. Also, change the parameter remove_temp to True so the temp file will be cleaned up automatically.

这篇关于输出的视频没有声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆