| 
					
				 | 
			
			
				@@ -196,7 +196,39 @@ class FFmpeg(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @classmethod 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def video_640(cls, video_path, file_path): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         video_url = file_path + 'pixelvideo.mp4' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ffmpeg_cmd = f"ffmpeg -i {video_path} -vf 'scale=640:trunc(ih*640/iw/2)*2' {video_url}" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ffmpeg_cmd = f"ffmpeg -i {video_path} -vf 'scale=360:640' {video_url}" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        subprocess.run(ffmpeg_cmd, shell=True) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return video_url 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    """视频拼接到一起""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @classmethod 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    def h_b_video(cls, video_path, pw_path, file_path, zm): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        video_url = file_path + 'hbvideo.mp4' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        single_video_srt = file_path + 'single_video.srt' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        # 获取时长 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        duration = cls.get_video_duration(video_path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        pw_duration = cls.get_video_duration(pw_path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if duration == 0 or pw_duration == 0: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return video_url 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        duration = pw_duration + duration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        start_time = cls.seconds_to_srt_time(2) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        end_time = cls.seconds_to_srt_time(duration) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        single_video_txt = file_path + 'single_video.txt' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        with open(single_video_txt, 'w') as f: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            f.write(f"file '{video_path}'\n") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if zm: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            # 如果有 zm,则写入字幕文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            with open(single_video_srt, 'w') as f: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                f.write(f"1\n{start_time} --> {end_time}\n<font color=\"red\">\u2764\uFE0F</font>{zm}\n\n") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            # 字幕命令,包含字幕文件路径 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            subtitle_cmd = f"subtitles={single_video_srt}:force_style='Fontsize=14,Fontname=wqy-zenhei,Outline=2,PrimaryColour=&H00FFFF,SecondaryColour=&H000000,Bold=1,MarginV=20'" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            # 如果没有 zm,则不使用字幕文件,直接使用样式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            subtitle_cmd = f"force_style='Fontsize=14,Fontname=wqy-zenhei,Outline=2,PrimaryColour=&H00FFFF,SecondaryColour=&H000000,Bold=1,MarginV=20'" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        # 最终的ffmpeg命令,加入字幕命令 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ffmpeg_cmd = f"ffmpeg -i {video_path} -i {pw_path} -filter_complex '[0:v]scale=360:640[v1]; [1:v]scale=360:640[v2]; [v1][0:a][v2][1:a]concat=n=2:v=1:a=1[outv][outa]' -map '[outv]' -map '[outa]' {subtitle_cmd} {video_url}" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         subprocess.run(ffmpeg_cmd, shell=True) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return video_url 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -330,22 +362,18 @@ class FFmpeg(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     单个视频拼接 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @classmethod 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    def single_video(cls, video_paths, file_path, zm): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    def single_video(cls, video_path, file_path, zm): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         single_video_url = file_path + 'single_video.mp4' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         single_video_srt = file_path + 'single_video.srt' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # 获取时长 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        durations = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for video in video_paths: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            duration = cls.get_video_duration(video) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            durations += duration  # 累加时长 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if durations == 0: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        duration = cls.get_video_duration(video_path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if duration == 0: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return single_video_url 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         start_time = cls.seconds_to_srt_time(2) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        end_time = cls.seconds_to_srt_time(durations) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        end_time = cls.seconds_to_srt_time(duration) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         single_video_txt = file_path + 'single_video.txt' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         with open(single_video_txt, 'w') as f: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for video in video_paths: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                f.write(f"file '{video}'\n") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            f.write(f"file '{video_path}'\n") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if zm: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             with open(single_video_srt, 'w') as f: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 f.write(f"1\n{start_time} --> {end_time}\n<font color=\"red\">\u2764\uFE0F</font>{zm}\n\n") 
			 |