select_video_path = "/root/web/source/select_video/" videos = os.listdir(select_video_path) for video in videos: video_name = os.path.join("select_video/",video) break copyfile("/root/web/source/"+video_name,"/root/web/source/now_video/"+ video) copyfile("/root/web/source/bing1_1.MP4", "/root/web/source/input_har.mp4") return_state = 200把这段代码改写成输出读取选择视频中的全部视频并输出
时间: 2023-09-15 18:21:33 浏览: 89
使用硬解,批量转码,双击运行bat文件,既可以把该文件下得所有视频进行批量转码
可以将代码改为以下形式:
```
import shutil
select_video_path = "/root/web/source/select_video/"
videos = os.listdir(select_video_path)
for video in videos:
video_path = os.path.join(select_video_path, video)
shutil.copy(video_path, "/root/web/source/now_video/" + video)
print("Copied", video_path, "to", "/root/web/source/now_video/" + video)
shutil.copy("/root/web/source/bing1_1.MP4", "/root/web/source/input_har.mp4")
print("Copied /root/web/source/bing1_1.MP4 to /root/web/source/input_har.mp4")
return_state = 200
```
这样,每次循环时就会输出一个视频的路径,并将其复制到目标路径。同时也会输出 MP4 文件的复制过程。
阅读全文