python - python for loop result in ffmpeg command
问题描述
hi im trying to insert for loop results in a ffmpeg command i tried some code but all i get is first text with no sound and it glitches and freezes i tried many modification but no success i appreciate if you have any ideas that would be great, the imported text from api should display only the duration of audio file here is my code:
import requests
import json
import os
import requests
import http.client
import io
import subprocess
response = requests.get('http://api.quran.com:3000/api/v3/chapters/2/verses?text_type=image&language=ar&recitation=10')
json = json.loads(response.content)
data= json['verses']
#print(data)
for i in data:
input_text = i['text_madani']
input_duration = i['audio']['duration']
input_mp3 = i['audio']['url']
input_img = i['image']['url']
# print(input_duration)
command = f'''ffmpeg -re -stream_loop -1 \
-i img2.jpeg \
-i {input_mp3} \
-vf 'pad=ceil(iw/2)*2:ceil(ih/2)*2,drawtext=enable='between(t, n, {input_duration})':text={input_text}:fontsize=90:x=50:y=50:fontcolor=black@0.8' \
-c:v libx264 -preset veryfast -b:v 3000k \
-maxrate 3000k -bufsize 6000k -pix_fmt yuv420p -g 50 \
-c:a aac -b:a 160k \
-ac 2 -ar 44100 \
-y -f flv rtmp://localhost/hls/test'''
print(command)
os.system(command)
解决方案
推荐阅读
- android - 刚刚发布的应用,未与 Google AdMob 关联
- python - 如何获取箱线图中每个中位数的值?
- mysql - 计算与 2 个枚举列相关的平均值
- reactjs - 从 redux 获得第一个响应后如何调用支持的 API?
- r - 我基本上试图运行一个模拟循环,从我的储蓄账户金额中减去生活费用
- mysql - 如何根据源列值的长度从第二个连接表中选择可以连接到两列中的任何一列的行
- java - Google 应用引擎 Maven 原型 HelloWorld 端点项目
- c++ - 迭代器的模板参数:函数在调用时推断类型?
- java - 如何在viewpager中显示片段之间的高程阴影?
- python - 无法使用 python 和 opencv 保存视频