zhangyong 8 月之前
父节点
当前提交
a55b9c23d5
共有 1 个文件被更改,包括 10 次插入5 次删除
  1. 10 5
      common/ffmpeg.py

+ 10 - 5
common/ffmpeg.py

@@ -2,6 +2,7 @@
 import subprocess
 import time
 
+from data_channel.data_help import dataHelp
 
 
 class FFmpeg():
@@ -122,7 +123,8 @@ class FFmpeg():
     def video_ggduration(cls, new_video_path, video_path_url, pw_random_id, gg_duration_total):
         gg_duration_url = video_path_url + str(pw_random_id) + 'gg_duration.mp4'
         # 获取视频时长
-        total_duration = cls.get_video_duration(new_video_path)
+        total_duration = dataHelp.video_duration(new_video_path)
+        # total_duration = cls.get_video_duration(new_video_path)
         duration = int(total_duration) - int(gg_duration_total)
         if int(total_duration) < int(gg_duration_total):
             return new_video_path
@@ -151,7 +153,7 @@ class FFmpeg():
         # 获取视频的原始宽高信息
         jpg_url = video_path_url + str(pw_random_id) + 'png.jpg'
         # 获取视频时长
-        total_duration = cls.get_video_duration(new_video_path)
+        total_duration = dataHelp.video_duration(new_video_path)
         time_offset = total_duration - 1  # 提取倒数第一秒的帧
         # 获取视频最后一秒,生成.jpg
         subprocess.run(
@@ -191,7 +193,7 @@ class FFmpeg():
         single_video_srt = video_path_url + str(pw_random_id) +'video_zm.srt'
         single_video_txt = video_path_url + str(pw_random_id) +'video_zm.txt'
         single_video = video_path_url + str(pw_random_id) +'video_zm.mp4'
-        duration = cls.get_video_duration(new_video_path)
+        total_duration = dataHelp.video_duration(new_video_path)
         start_time = cls.seconds_to_srt_time(0)
         end_time = cls.seconds_to_srt_time(duration)
         # zm = '致敬伟大的教员,为整个民族\n感谢老人家历史向一代伟人'
@@ -239,7 +241,9 @@ class FFmpeg():
         # 片尾位置
         pw_url_path = video_path_url + str(pw_random_id) + 'pw_video.mp4'
         # 获取视频时长
-        pw_duration = cls.get_video_duration(pw_url)
+        pw_duration = dataHelp.video_duration(pw_url)
+
+        # pw_duration = cls.get_video_duration(pw_url)
         time.sleep(2)
         # 添加字幕 wqy-zenhei  Hiragino Sans GB
         height = 1080
@@ -301,7 +305,8 @@ class FFmpeg():
         single_video_url = video_path_url + 'single_video.mp4'
         single_video_srt = video_path_url + 'single_video.srt'
         # 获取时长
-        duration = cls.get_video_duration(new_video_path)
+        duration = dataHelp.video_duration(new_video_path)
+        # duration = cls.get_video_duration(new_video_path)
         start_time = cls.seconds_to_srt_time(2)
         end_time = cls.seconds_to_srt_time(duration)
         single_video_txt = video_path_url + 'single_video.txt'