with open("C:/Users/user/Documents/1mg/li1.txt", "r", encoding="utf-8") as f:

    text = f.read().strip()

words = text.split()
lines = [" ".join(words[i:i+7]) for i in range(0, len(words), 7)]
lines = lines[::-1]  # reverse the lines list

# Calculate the total height of all the lines
total_height = len(lines) * 80

commands = []
for i, line in enumerate(lines):
    # Calculate the position of this line based on the total height
    y_pos = 430 - total_height // 2 + i * 80
   
    command = f"drawtext=fontfile=/Users/user/AppData/Local/Microsoft/Windows/Fonts/LATO-BLACK.TTF:text='{line}':x=(w-tw)/2+20*sin(PI*t/2):y={y_pos}:fontcolor=black:fontsize=40:shadowcolor=black:shadowx=0:shadowy=0:box=1:boxcolor=#FDDF5B:boxborderw=20:enable='between(t,0,50)'"
    commands.append(command)

filtergraph = ",".join(commands)
subprocess.run([
    "ffmpeg",
    "-i", "C:/Users/user/Documents/1mg/860.mp4",
    "-vf", filtergraph,
    "C:/Users/user/Documents/1mg/featuretextwhite.mp4"
])

os.system("ffmpeg -i C:/Users/user/Documents/1mg/featurewithname.mp4 -i \"C:/Users/user/Documents/1mg/featuretextwhite.mp4\" -filter_complex \"[0:v][1:v]overlay=shortest=1:x=1050:y=200, format=yuv420p\" C:/Users/user/Documents/1mg/li1.mp4")
os.system("ffmpeg  -stream_loop -1 -i C:/Users/user/Documents/1mg/li1.mp4 -i \"C:/Users/user/Documents/1mg/li1.m4a\" -shortest -map 0:v:0 -map 1:a:0 -y -c copy -bsf:v h264_mp4toannexb -f mpegts \"C:/Users/user/Documents/1mg/li1.ts\"")

0 comments:

Post a Comment

 
Top