我正在使用python 3.6,这是我项目中的一个模块-
import os
import time
from moviepy.video.io.VideoFileClip import VideoFileClip
def add_audio_to_file(original_video, dest_video):
suffix = original_video.split(".")[-1]
directory_path = os.path.dirname(dest_video)
temp_name = os.path.join(directory_path, "temp_vid_{}.{}".format(time.time(), suffix))
os.rename(dest_video, temp_name)
os.chmod(original_video, 777)
orig_videoclip = VideoFileClip(original_video)
audioclip = orig_videoclip.audio
redorded_videoclip = VideoFileClip(temp_name)
with_audio_clip = redorded_videoclip.set_audio(audioclip)
with_audio_clip.write_videofile(dest_video, progress_bar=False, threads=6, verbose=False)
os.remove(temp_name)
我收到以下错误:
Traceback (most recent call last):
File "C:\Users\Borat\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\Borat\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "C:\MOT_Server\olympus-skeleton\core\step\step_action\utils\async_queue_reader.py", line 56, in _start_reading_from_queue
self._new_objects_in_queue_function(queue_objects)
File "C:\MOT_Server\olympus-skeleton\core\step\step_action\handler\async_handler.py", line 29, in _listener_to_handler_queue_messages_handler
messages = self._handle_function(messages)
File "C:\MOT_Server\olympus-skeleton\core\step\step.py", line 261, in process
processed_messages = handler(curr_messages)
File "C:\MOT_Server\olympus-skeleton\core\step\step.py", line 239, in _handle_message
final_messages = self._process(messages_to_process) or []
File "C:\MOT_Server\olympus-skeleton\components\steps\output_step\output_step.py", line 40, in _process
publisher.publish(messages)
File "C:\MOT_Server\olympus-skeleton\core\publisher\publisher.py", line 28, in publish
self._publish(messages)
File "C:\MOT_Server\olympus-skeleton\components\publishers\filesystem_cleaner_publisher\filesystem_cleaner_publisher.py", line 32, in _publish
files_to_delete = self._serializer.serialize(message)
File "C:\MOT_Server\olympus-skeleton\components\serializers\mot_serializers\job_completed_verifier_serializer.py", line 182, in serialize
self._add_audio_to_vid(original_video, dest_video)
File "C:\MOT_Server\olympus-skeleton\components\serializers\mot_serializers\job_completed_verifier_serializer.py", line 201, in _add_audio_to_vid
add_audio_to_file(original_video, dest_video)
File "C:\MOT_Server\olympus-skeleton\utils\recorder_utils\audio_utils.py", line 17, in add_audio_to_file
orig_videoclip = VideoFileClip(original_video)
File "C:\Users\Borat\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 91, in __init__
fps_source=fps_source)
File "C:\Users\Borat\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 33, in __init__
fps_source)
File "C:\Users\Borat\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 259, in ffmpeg_parse_infos
proc.terminate()
File "C:\Users\Borat\AppData\Local\Programs\Python\Python36\lib\site-packages\gevent\subprocess.py", line 982, in terminate
TerminateProcess(self._handle, 1)
PermissionError: [WinError 5] Access is denied
我检查了权限,一切似乎正常。另外,我尝试使用os.chmod(original_video, 777)
更改权限,但仍然没有成功。