[英]Python - How i can combine a image with an mp3 file?
我正在制作一個小腳本來自動上傳視頻。
所以腳本給我的數據,例如:
- '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'
我想將這兩個文件合並為一個 mp4 文件。
audio.mp3 + image.jpg = video.mp4
我可以使用 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.