【问题标题】:Python PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: mp4 filePython PermissionError: [WinError 32] 该进程无法访问该文件,因为它正被另一个进程使用:mp4 文件
【发布时间】:2020-02-11 17:32:04
【问题描述】:

我目前收到此错误 PermissionError: [WinError 32] 该进程无法访问该文件,因为它正被另一个进程使用:'smallvideos/file1.mp4'

我尝试了不同的方法来关闭文件,但没有运气,不知道我在这里做错了什么。

def create_file(today):
list_of_clips = []

with open("video_names.txt") as clip_file:
    read_file = clip_file.read()
    lines = read_file.splitlines()

clip_file = open("video_names.txt")

for line in lines:
    #Creates video in 720p - keeps original aspect ratio
    video = VideoFileClip(line, target_resolution=(720, None))
    list_of_clips.append(video)

    os.remove(line)

filename = "combinedVideo_" + str(today) + ".mp4"

final_clip = concatenate_videoclips(list_of_clips, method='compose')
final_clip.write_videofile(filename)

return filename

【问题讨论】:

    标签: python


    【解决方案1】:

    这基本上是权限错误,您只需要在删除之前关闭文件即可。获取文件大小信息后。

    clip_file.close()

    【讨论】:

    猜你喜欢
    • 2019-11-26
    • 2015-11-13
    • 2015-01-28
    • 2017-06-02
    • 2021-09-21
    • 2020-10-31
    • 2021-09-28
    • 2018-10-28
    • 2023-01-14
    相关资源
    最近更新 更多