Код: Выделить всё
import os
from moviepy.video.io.VideoFileClip import VideoFileClip
from moviepy.video.VideoClip import TextClip
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
import subprocess
import moviepy.config as conf
from moviepy.audio.io.AudioFileClip import AudioFileClip
import pyttsx3
я пробовал выполнить этот файл в командной строке в его каталоге
Код: Выделить всё
python movie.py
Код: Выделить всё
public void callPythonFile() {
try {
// Directory where the Python script is located
final File scriptDirectory = new File("src/main/resources/movie-python");
// Command to run the Python script
final String command = "python movie.py";
// Start the process with the script directory as the working directory
ProcessBuilder processBuilder = new ProcessBuilder(command.split(" "));
processBuilder.directory(scriptDirectory);
Process process = processBuilder.start();
// Read output from the process
InputStream inputStream = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
// Wait for the process to finish
int exitCode = process.waitFor();
if (exitCode != 0) {
throw new RuntimeException("Python script exited with non-zero code: " + exitCode);
}
System.out.println("Python script exited with code: " + exitCode);
} catch (IOException | InterruptedException e) {
throw new RuntimeException("Error executing Python script: " + e.getMessage(), e);
}
}
Код: Выделить всё
video_with_text.write_videofile(temp_file, codec='libx264', audio_codec='aac')
Подробнее здесь: https://stackoverflow.com/questions/783 ... springboot