Browse Source

时光相册-视频生成 修改文件路径

linhaohong 11 months ago
parent
commit
e95b589a95
2 changed files with 11 additions and 8 deletions
  1. 7 5
      CeleryTask/TimeAlbumTask.py
  2. 4 3
      Controller/TimeAlbumController.py

+ 7 - 5
CeleryTask/TimeAlbumTask.py

@@ -21,7 +21,7 @@ def generate_video(image_files, output_path):
     start_xvfb.delay()  # 确保 Xvfb 已经启动
     start_xvfb.delay()  # 确保 Xvfb 已经启动
     try:
     try:
         video_files = []
         video_files = []
-        music_path = "static/temp/music.mp3"
+        music_path = "/web/test/ASJServer/static/temp/music.mp3"
         # 定义特效列表
         # 定义特效列表
         transitions = [
         transitions = [
             "BowTieHorizontal.glsl",
             "BowTieHorizontal.glsl",
@@ -44,7 +44,7 @@ def generate_video(image_files, output_path):
                 'ffmpeg', '-loop', '1', '-i', image_files[i],
                 'ffmpeg', '-loop', '1', '-i', image_files[i],
                 '-loop', '1', '-i', image_files[i + 1],
                 '-loop', '1', '-i', image_files[i + 1],
                 '-filter_complex',
                 '-filter_complex',
-                f'gltransition=duration=1:offset=0.7:source=static/gl-transitions/{transitions[i]}',
+                f'gltransition=duration=1:offset=0.7:source=/web/test/ASJServer/static/temp/{transitions[i]}',
                 '-t', '2', output_video
                 '-t', '2', output_video
             ]
             ]
 
 
@@ -57,8 +57,10 @@ def generate_video(image_files, output_path):
 
 
         # 拼接视频
         # 拼接视频
         final_output = os.path.join(output_path, 'final_output.mp4')
         final_output = os.path.join(output_path, 'final_output.mp4')
-        subprocess.run(['ffmpeg', '-f', 'concat', '-safe', '0', '-i', 'filelist.txt', '-c', 'copy', final_output],
-                       check=True)
+        subprocess.run(
+            ['ffmpeg', '-f', 'concat', '-safe', '0', '-i', '/web/test/ASJServer/static/temp/filelist.txt', '-c', 'copy',
+             final_output],
+            check=True)
 
 
         # 添加背景音乐
         # 添加背景音乐
         final_output_with_music = os.path.join(output_path, 'final_output_with_music.mp4')
         final_output_with_music = os.path.join(output_path, 'final_output_with_music.mp4')
@@ -68,7 +70,7 @@ def generate_video(image_files, output_path):
         # 清理临时文件
         # 清理临时文件
         for video in video_files:
         for video in video_files:
             os.remove(video)
             os.remove(video)
-        os.remove('static/temp/filelist.txt')
+        os.remove('/web/test/ASJServer/static/temp/filelist.txt')
     except Exception as e:
     except Exception as e:
         LOGGER.info(f'视频合成失败: {e}')
         LOGGER.info(f'视频合成失败: {e}')
 
 

+ 4 - 3
Controller/TimeAlbumController.py

@@ -32,10 +32,11 @@ class TimeAlbum(View):
         # 下载图片保存地址
         # 下载图片保存地址
 
 
         # 收集图片文件路径
         # 收集图片文件路径
-        image_files = ['static/temp/image1.jpg', 'static/temp/image2.jpg', 'static/temp/image3.jpg', 'static/temp/image4.jpg',
-                       'static/temp/image5.jpg']
+        image_files = ['/web/test/ASJServer/static/temp/image1.jpg', '/web/test/ASJServer/static/temp/image2.jpg',
+                       '/web/test/ASJServer/static/temp/image3.jpg', '/web/test/ASJServer/static/temp/image4.jpg',
+                       '/web/test/ASJServer/static/temp/image5.jpg']
 
 
-        output_path = 'static/temp/'
+        output_path = '/web/test/ASJServer/static/temp'
 
 
         # 调用 Celery 任务
         # 调用 Celery 任务
         generate_video.delay(image_files, output_path)
         generate_video.delay(image_files, output_path)