[英]Python - How i can combine a image with an mp3 file?
I'm making a little script to automate uploading a videos.我正在制作一个小脚本来自动上传视频。
So the data that the script give me, for example:所以脚本给我的数据,例如:
- 'I kicked all my friends off my HBO account because they were horrid to me last night and now they can’t watch the Game of Thrones premiere..jpg'
- 'I kicked all my friends off my HBO account because they were horrid to me last night and now they can’t watch the Game of Thrones premiere..mp3'
I want to combine both files to a single mp4 file.我想将这两个文件合并为一个 mp4 文件。
audio.mp3 + image.jpg = video.mp4
I can fixed using ffmpeg.我可以使用 ffmpeg 进行修复。
import subprocess
def video(image_file: str, mp3_file: str, video_file: str) -> None:
# audio.mp3 + image.jpg = video.mp4
if image_file == "":
print("no image")
else:
subprocess.call([
"ffmpeg", "-loop", "1", "-i", image_file, "-i", mp3_file, "-c:v",
"libx264", "-tune", "stillimage", "-c:a", "aac", "-b:a", "192k",
"-shortest", video_file
])
return None
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.