I do have x
file which contain a list of mp3
files where i would like to convert each mp3
file to mp4
file with a static
.png
photo.
Seems the only way here is to use ffmpeg
but idk how to achieve it.
i made the script to take an input of mp3
folder and one .png
photo`.
then it's will create new folder x-converted
where i would like to convert each mp3
to mp4
with the static png
with same name such as file1.mp3
to became file1.mp4
here's my code :
import os
import sys
from pathlib import Path
import shutil
if len(sys.argv) != 3 or not sys.argv[2].endswith("png"):
print("Make sure to provide two arguments only\nSecond arugment should be .png")
exit()
def CheckFile():
try:
files = []
for path in os.listdir(sys.argv[1]):
full_path = os.path.join(sys.argv[1], path)
if os.path.isfile(full_path):
files.append(full_path)
mp3 = [x for x in files if x.endswith(".mp3")]
if len(mp3) >= 1:
return mp3, sys.argv[2], sys.argv[1]
else:
print(
"Make Sure That You've at least 1 Mp3 file")
exit()
except FileNotFoundError:
print("Sorry, This File Is Not Exist!")
exit()
def Convert():
mp3, jpg, name = CheckFile()
name = f"{Path(name).name}-converted"
shutil.rmtree(name, ignore_errors=True)
os.mkdir(name)
os.chdir(name)
# from here i don't know how to use `ffmpeg`
Convert()