Есть ли способ записать текст в видео без перекодирования? Я спрашиваю об этом, потому что при записи в WEBM процесс перекодирования происходит со скоростью около 0,1x. Альтернативно, есть ли более быстрый способ быстрого рендеринга видео высокого качества с повторным кодированием, например, запись во временный файл?
def processVideo(self):
print("creating video")
# File location management
font_path = self.input_path / "CalSans-Regular.ttf"
background_path = self.input_path / "new_video_background.webm"
audio_path = self.sound_output_path
video_ouput_path = self.parent_path / "new_result.webm"
sound_input = ffmpeg.input(str(audio_path))
video_input = ffmpeg.input(str(background_path))
# Adding captions
print(self.text_caption)
previous_timepoint = 0
for caption, timepoint in zip(self.text_caption, self.timepoints, strict=False):
# Text caption and timepooints are lists where the end of the words in text_caption correspond
# to the timepoint with the same index in timepoint
video_input = video_input.drawtext(
text=caption,
fontfile = font_path,
x='w-text_w/2',
y='h-text_h/2',
escape_text=True,
fontsize= 32,
bordercolor = "black",
borderw = 4,
enable=f'between(t,{previous_timepoint},{timepoint["timeSeconds"]})'
)
previous_timepoint = timepoint["timeSeconds"]
# Combining sound and video and writing output
command = ffmpeg.output(sound_input, video_input, str(video_ouput_path), codec='copy').overwrite_output().global_args('-shortest')
print("args =", command)
print(command.get_args())
command.run()
print("done!")
File "c:\Desktop\Projects\video_project\main.py", line 239, in
post_list[0].processVideo()
~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "c:\Desktop\Projects\video_project\main.py", line 223, in processVideo
command.run()
~~~~~~~~~~~^^
File "C:\Desktop\Projects\video_project\.venv\Lib\site-packages\ffmpeg\_run.py", line 313, in run
process = run_async(
stream_spec,
......
overwrite_output=overwrite_output,
)
File "C:\Desktop\Projects\video_project\.venv\Lib\site-packages\ffmpeg\_run.py", line 284, in run_async
return subprocess.Popen(
~~~~~~~~~~~~~~~~^
args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "C:\AppData\Local\Programs\Python\Python313\Lib\subprocess.py", line 1038, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pass_fds, cwd, env,
^^^^^^^^^^^^^^^^^^^
......
gid, gids, uid, umask,
^^^^^^^^^^^^^^^^^^^^^^
start_new_session, process_group)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\AppData\Local\Programs\Python\Python313\Lib\subprocess.py", line 1550, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
# no special security
^^^^^^^^^^^^^^^^^^^^^
......
cwd,
^^^^
startupinfo)
^^^^^^^^^^^^
FileNotFoundError: [WinError 206] The filename or extension is too long