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.
audio.mp3 + image.jpg = video.mp4
I can fixed using 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.