I just want to execute this code with os.system('command') in ffmpeg drawtext() but unable to execute it just because of ' (apostrophe) , it fails
The code goes here ->
the \f is working as \n but I'm using that for seprating word
from PIL import ImageFont
import os
def create_lines(longline, start, end, fontsize=75, fontfile='OpenSansCondensedBold.ttf'):
fit = fit_text(longline, 700, fontfile)
texts = []
now = 0
# breaking line on basis of '\f'
for wordIndex in range(len(fit)):
if fit[wordIndex] == '\f' or wordIndex == len(fit)-1:
texts.append(fit[now:wordIndex+1].strip('\f'))
now = wordIndex
# adding multiple lines to video
string = ''
count = 0
for line in texts:
string += f''',drawtext=fontfile={fontfile}:fontsize={fontsize}:text='{line[enter image description here](https://i.stack.imgur.com/iuceq.png)}':fontcolor=black:bordercolor=white:borderw=4:x=(w-text_w)/2:y=(h-text_h)/2-100+{count}:'enable=between(t,{start},{end})' '''
count += 100
print(string)
return string
def createVideo(content):
input_video = 'video.mp4'
output_video = 'output.mp4'
font_file = 'BebasKai.ttf'
text_file = 'OpenSansCondensedBold.ttf'
font_size = 75
font_color = 'white'
part1 = create_lines(content[1], 0.5, 7)
part2 = create_lines(content[2], 7.5, 10)
os.system(
f"""ffmpeg -i {} -vf "drawtext=fontfile={font_file}:fontsize={95}:text={content[0]}:fontcolor={font_color}:box=1:[email protected]:boxborderw=20:x=(w-text_w)/2:y=(h-text_h)/4-100{str(part1)}{str(part2)}" -c:v libx264 -c:a aac -t 10 {output_video} -y""")
my_text =['The Brain', "Your brain can't multitask effectively", "Multitasking is a myth, it's just rapid switching between tasks"]
createVideo(my_text)
what I want is that, I would able to execute this correctly