简体   繁体   English

命名文件 output moviepy ffmpeg

[英]Naming file output moviepy ffmpeg

I am trying to name clips from a moviepy ffmpeg output based on text in dataframe columns.我正在尝试根据 dataframe 列中的文本命名来自moviepy ffmpeg output 的剪辑。 I can create the clips but am having trouble with the naming as Im not sure how to loop through the list and add it to the output file name.我可以创建剪辑,但在命名时遇到问题,因为我不确定如何遍历列表并将其添加到 output 文件名中。

example data frame示例数据框

import pandas as pd

data = [["Park","Road",4, 10], ["Road","Street", 80, 95], ["Street","Park",120, 132]] 
df = pd.DataFrame(data, columns = ["Origin", "Destination","Start", "End"])

print (df)

Origin|产地| Destination|目的地| Start |开始 | End结尾

0 | 0 | Park |公园 | Road |道路 | 4 | 4 | 10 10

1 | 1 | Road |道路 | Street |街道 | 80 | 80 | 95 95

2 | 2 | Street|街道| Park |公园 | 120| 120| 132 132

Id like the output file to show the Origin and Destination text我喜欢 output 文件来显示起点和终点文本

videoParkRoad1视频公园路1

videoRoadStreet2视频RoadStreet2

videoStreetPark3视频StreetPark3

the code I have at the moment我现在的代码

filename="D:\video" + str(i+1) + ".mp4"

returns返回

video1视频1

video2视频2

video3视频3

Hope this makes sense希望这是有道理的

Thanks谢谢

Code:代码:

import pandas as pd

for i in range(len(df)):
    filename = "video" + str(df.iloc[i,0]) + str(df.iloc[i, 1]) + str(i+1)
    print(filename)

Output: Output:

videoParkRoad1
videoRoadStreet2
videoStreetPark3

I hope it would be helpful.我希望它会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM