```

def step_7_mp4_to_ts(merge_video_list):

"""

将处理好的视频合并在一起

:param merge_video_list: 视频列表

:return:

"""

video_ts_list = []

# 视频合并前,将mp4转为ts

for mp4_path in merge_video_list:

ts_path_temp = mp4_path.lower().replace('mp4', 'ts')

cmd_mp4_ts = f'ffmpeg -i {mp4_path} -vcodec copy -acodec aac -loglevel quiet {ts_path_temp} -y'

print(f"mp4转ts命令:{cmd_mp4_ts}")

ffmpeg_code = subprocess.call(cmd_mp4_ts, shell=True)

print(f"mp4转ts视频的结果,ffmpeg_code:{ffmpeg_code}")

if ffmpeg_code == 0:

video_ts_list.append(ts_path_temp)

else:

raise Exception("mp4转ts异常")

print("*" * 100)

return video_ts_list

def step_8_merge_video(video_ts_list):

print(f"开始合并TS视频,生成mp4视频:{video_ts_list}")

# 合并视频保存的地址

first_video_path = os.path.join(fr"{project_path}\video_temp", f"merge_{get_now_time()}.mp4")

concat_string = "concat:" + "|".join(video_ts_list)

cmd_concat = f'ffmpeg -i "{concat_string}" -acodec copy -vcodec copy -absf aac_adtstoasc ' \

f'-movflags +faststart -loglevel quiet {first_video_path} -y'

print(f"TS视频合并的命令:{cmd_concat}")

ffmpeg_code = subprocess.call(cmd_concat, shell=True)

print(f"合并视频的结果,ffmpeg_code:{ffmpeg_code}")

if ffmpeg_code == 0:

return first_video_path

else:

raise Exception("TS视频合并异常")

```