agc_video_method.py 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  1. import configparser
  2. import glob
  3. import os
  4. import random
  5. import re
  6. import subprocess
  7. import sys
  8. import time
  9. import urllib.parse
  10. import json
  11. import requests
  12. from datetime import datetime, timedelta
  13. from urllib.parse import urlencode
  14. sys.path.append(os.getcwd())
  15. from common.db import MysqlHelper
  16. from common.material import Material
  17. from common import Common, Oss, Feishu
  18. config = configparser.ConfigParser()
  19. config.read('./config.ini') # 替换为您的配置文件路径
  20. class AgcVidoe():
  21. # 获取未使用的视频链接
  22. @classmethod
  23. def get_url_gs_list(cls, user_list, mark, limit_count):
  24. for i in range(5):
  25. user = random.choice(user_list)
  26. Common.logger("gs_video").info(f"account_id 为{user}")
  27. current_time = datetime.now()
  28. three_days_ago = current_time - timedelta(days=3)
  29. formatted_current_time = current_time.strftime("%Y-%m-%d")
  30. formatted_three_days_ago = three_days_ago.strftime("%Y-%m-%d")
  31. if limit_count == 1:
  32. url_list = f"""SELECT a.video_id, a.account_id, a.oss_object_key
  33. FROM agc_video_url a
  34. LEFT JOIN agc_video_deposit b
  35. ON a.oss_object_key = b.oss_object_key
  36. AND b.time = '{formatted_current_time}'
  37. WHERE b.video_id IS NULL
  38. AND a.account_id = '{user}'
  39. AND a.status = 1
  40. AND a.mark = '{mark}'
  41. LIMIT {limit_count};"""
  42. Common.logger("gs_video").info(f"{mark}sql{url_list} ")
  43. url_list = MysqlHelper.get_values(url_list, "prod")
  44. Common.logger("gs_video").info(f"{mark}查询数据{url_list} ")
  45. if url_list:
  46. return url_list
  47. else:
  48. url_list = f"""SELECT a.video_id, a.account_id, a.oss_object_key
  49. FROM agc_video_url a
  50. LEFT JOIN agc_video_deposit b
  51. ON a.oss_object_key = b.oss_object_key
  52. AND b.time >= '{formatted_three_days_ago}'
  53. AND b.time <= '{formatted_current_time}'
  54. WHERE b.video_id IS NULL
  55. AND a.account_id = '{user}'
  56. AND a.status = 1
  57. AND a.mark = '{mark}'
  58. LIMIT {limit_count};"""
  59. Common.logger("gs_video").info(f"{mark}sql{url_list} ")
  60. url_list = MysqlHelper.get_values(url_list, "prod")
  61. Common.logger("gs_video").info(f"{mark}查询数据{url_list} ")
  62. if url_list:
  63. if len(url_list) >= 30:
  64. return url_list
  65. return None
  66. # 获取未使用的视频链接
  67. @classmethod
  68. def get_url_list(cls, user_list, mark, limit_count):
  69. for i in range(5):
  70. user = str(random.choice(user_list))
  71. user = user.replace('(', '').replace(')', '').replace(',', '')
  72. current_time = datetime.now()
  73. three_days_ago = current_time - timedelta(days=3)
  74. formatted_current_time = current_time.strftime("%Y-%m-%d")
  75. formatted_three_days_ago = three_days_ago.strftime("%Y-%m-%d")
  76. if limit_count == 1:
  77. url_list = f"""SELECT a.video_id, a.account_id, a.oss_object_key
  78. FROM agc_video_url a
  79. LEFT JOIN agc_video_deposit b
  80. ON a.oss_object_key = b.oss_object_key
  81. AND b.time = '{formatted_current_time}'
  82. WHERE b.video_id IS NULL
  83. AND a.account_id = {user}
  84. AND a.status = 1
  85. AND a.mark = '{mark}'
  86. LIMIT {limit_count};"""
  87. url_list = MysqlHelper.get_values(url_list, "prod")
  88. if url_list:
  89. return url_list
  90. else:
  91. url_list = f"""SELECT a.video_id, a.account_id, a.oss_object_key
  92. FROM agc_video_url a
  93. LEFT JOIN agc_video_deposit b
  94. ON a.oss_object_key = b.oss_object_key
  95. AND b.time >= '{formatted_three_days_ago}'
  96. AND b.time <= '{formatted_current_time}'
  97. WHERE b.video_id IS NULL
  98. AND a.account_id = {user}
  99. AND a.status = 1
  100. AND a.mark = '{mark}'
  101. LIMIT {limit_count};"""
  102. url_list = MysqlHelper.get_values(url_list, "prod")
  103. if url_list:
  104. if len(url_list) >= 30:
  105. return url_list
  106. return None
  107. # 随机生成id
  108. @classmethod
  109. def random_id(cls):
  110. now = datetime.now()
  111. rand_num = random.randint(10000, 99999)
  112. oss_id = "{}{}".format(now.strftime("%Y%m%d%H%M%S"), rand_num)
  113. return oss_id
  114. # 获取已入库的用户id
  115. @classmethod
  116. def get_user_id(cls, channel_type, mark):
  117. account_id = f"""select account_id from agc_video_url where mark = '{mark}' and oss_object_key LIKE '%{channel_type}%' group by account_id ;"""
  118. account_id = MysqlHelper.get_values(account_id, "prod")
  119. return account_id
  120. # 获取已入库数量
  121. @classmethod
  122. def get_link_count(cls, mark, platform):
  123. current_time = datetime.now()
  124. formatted_time = current_time.strftime("%Y-%m-%d")
  125. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM agc_video_deposit WHERE time = '{formatted_time}' AND platform = '{platform}' and mark = '{mark}' GROUP BY audio, account_id) AS subquery;"""
  126. count = MysqlHelper.get_values(count, "prod")
  127. if count == None:
  128. count = 0
  129. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  130. return int(count)
  131. # 获取跟随脚本已入库数量
  132. @classmethod
  133. def get_link_gs_count(cls, mark):
  134. current_time = datetime.now()
  135. formatted_time = current_time.strftime("%Y-%m-%d")
  136. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM agc_video_deposit WHERE time = '{formatted_time}' and mark LIKE '%{mark}%' GROUP BY audio, account_id) AS subquery;"""
  137. count = MysqlHelper.get_values(count, "prod")
  138. if count == None:
  139. count = 0
  140. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  141. return int(count)
  142. # 获取跟随脚本站外已入库数量
  143. @classmethod
  144. def get_link_zw_count(cls, mark, platform):
  145. current_time = datetime.now()
  146. formatted_time = current_time.strftime("%Y-%m-%d")
  147. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM agc_video_deposit WHERE time = '{formatted_time}' and mark = '{mark}' GROUP BY audio, account_id) AS subquery;"""
  148. count = MysqlHelper.get_values(count, "prod")
  149. if count == None:
  150. count = 0
  151. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  152. return int(count)
  153. # 获取跟随脚本站内已入库数量
  154. @classmethod
  155. def get_link_zn_count(cls, mark, platform):
  156. current_time = datetime.now()
  157. formatted_time = current_time.strftime("%Y-%m-%d")
  158. count = f"""SELECT COUNT(*) AS total_count FROM ( SELECT audio, account_id FROM agc_video_deposit WHERE time = '{formatted_time}' AND platform = '{platform}' and mark = '{mark}' GROUP BY audio, account_id) AS subquery;"""
  159. count = MysqlHelper.get_values(count, "prod")
  160. if count == None:
  161. count = 0
  162. count = str(count).replace('(', '').replace(')', '').replace(',', '')
  163. return int(count)
  164. @classmethod
  165. def create_subtitle_file(cls, srt, s_path):
  166. # 创建临时字幕文件
  167. with open(s_path, 'w') as f:
  168. f.write(srt)
  169. @classmethod
  170. def convert_srt_to_ass(cls, s_path, a_path):
  171. # 使用 FFmpeg 将 SRT 转换为 ASS
  172. subprocess.run(["ffmpeg", "-i", s_path, a_path])
  173. @classmethod
  174. def get_cover(cls, uid):
  175. time.sleep(1)
  176. url = "https://admin.piaoquantv.com/manager/video/multiCover/listV2"
  177. payload = json.dumps({
  178. "videoId": uid,
  179. "range": "2h"
  180. })
  181. headers = {
  182. 'accept': 'application/json',
  183. 'accept-language': 'zh-CN,zh;q=0.9',
  184. 'cache-control': 'no-cache',
  185. 'content-type': 'application/json',
  186. 'cookie': 'SESSION=YjU3MzgwNTMtM2QyYi00YjljLWI3YWUtZTBjNWYwMGQzYWNl',
  187. 'origin': 'https://admin.piaoquantv.com',
  188. 'pragma': 'no-cache',
  189. 'priority': 'u=1, i',
  190. 'sec-ch-ua': '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
  191. 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'
  192. }
  193. response = requests.request("POST", url, headers=headers, data=payload)
  194. data = response.json()
  195. content = data["content"]
  196. if len(content) == 1:
  197. return content[0]["coverUrl"]
  198. max_share_count = 0
  199. selected_cover_url = ""
  200. for item in content:
  201. share_count = item.get("shareWeight")
  202. if share_count is not None and share_count > max_share_count:
  203. max_share_count = share_count
  204. selected_cover_url = item["coverUrl"]
  205. elif share_count == max_share_count and item["createUser"] == "用户":
  206. selected_cover_url = item["coverUrl"]
  207. return selected_cover_url
  208. # 新生成视频上传到对应账号下
  209. @classmethod
  210. def insert_piaoquantv(cls, oss_object_key, audio_title, pq_ids_list, cover, uid):
  211. for i in range(2):
  212. url = "https://vlogapi.piaoquantv.com/longvideoapi/crawler/video/send"
  213. headers = {
  214. 'User-Agent': 'PQSpeed/486 CFNetwork/1410.1 Darwin/22.6.0',
  215. 'cookie': 'JSESSIONID=4DEA2B5173BB9A9E82DB772C0ACDBC9F; JSESSIONID=D02C334150025222A0B824A98B539B78',
  216. 'referer': 'http://appspeed.piaoquantv.com',
  217. 'token': '524a8bc871dbb0f4d4717895083172ab37c02d2f',
  218. 'accept-language': 'zh-CN,zh-Hans;q=0.9',
  219. 'Content-Type': 'application/x-www-form-urlencoded'
  220. }
  221. if cover == None or cover == " ":
  222. cover = cls.get_cover(uid)
  223. payload = {
  224. 'coverImgPath': cover,
  225. 'deviceToken': '9ef064f2f7869b3fd67d6141f8a899175dddc91240971172f1f2a662ef891408',
  226. 'fileExtensions': 'MP4',
  227. 'loginUid': '69831373',
  228. 'networkType': 'Wi-Fi',
  229. 'platform': 'iOS',
  230. 'requestId': 'fb972cbd4f390afcfd3da1869cd7d001',
  231. 'sessionId': '362290597725ce1fa870d7be4f46dcc2',
  232. 'subSessionId': '362290597725ce1fa870d7be4f46dcc2',
  233. 'title': audio_title,
  234. 'token': '524a8bc871dbb0f4d4717895083172ab37c02d2f',
  235. 'uid': pq_ids_list[i],
  236. 'versionCode': '486',
  237. 'versionName': '3.4.12',
  238. 'videoFromScene': '1',
  239. 'videoPath': oss_object_key,
  240. 'viewStatus': '1'
  241. }
  242. encoded_payload = urlencode(payload)
  243. else:
  244. payload = {
  245. 'coverImgPath': '',
  246. 'deviceToken': '9ef064f2f7869b3fd67d6141f8a899175dddc91240971172f1f2a662ef891408',
  247. 'fileExtensions': 'MP4',
  248. 'loginUid': '69831373',
  249. 'networkType': 'Wi-Fi',
  250. 'platform': 'iOS',
  251. 'requestId': 'fb972cbd4f390afcfd3da1869cd7d001',
  252. 'sessionId': '362290597725ce1fa870d7be4f46dcc2',
  253. 'subSessionId': '362290597725ce1fa870d7be4f46dcc2',
  254. 'title': audio_title,
  255. 'token': '524a8bc871dbb0f4d4717895083172ab37c02d2f',
  256. 'uid': pq_ids_list[i],
  257. 'versionCode': '486',
  258. 'versionName': '3.4.12',
  259. 'videoFromScene': '1',
  260. 'videoPath': oss_object_key,
  261. 'viewStatus': '1'
  262. }
  263. encoded_payload = urlencode(payload)
  264. requests.request("POST", url, headers=headers, data=encoded_payload)
  265. return True
  266. # 获取视频链接
  267. @classmethod
  268. def get_audio_url(cls, uid, mark, mark_name):
  269. cookie = Material.get_houtai_cookie()
  270. url = f"https://admin.piaoquantv.com/manager/video/detail/{uid}"
  271. payload = {}
  272. headers = {
  273. 'authority': 'admin.piaoquantv.com',
  274. 'accept': 'application/json, text/plain, */*',
  275. 'accept-language': 'zh-CN,zh;q=0.9',
  276. 'cache-control': 'no-cache',
  277. 'cookie': cookie,
  278. 'pragma': 'no-cache',
  279. 'referer': f'https://admin.piaoquantv.com/cms/post-detail/{uid}/detail',
  280. 'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
  281. 'sec-ch-ua-mobile': '?0',
  282. 'sec-ch-ua-platform': '"macOS"',
  283. 'sec-fetch-dest': 'empty',
  284. 'sec-fetch-mode': 'cors',
  285. 'sec-fetch-site': 'same-origin',
  286. 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
  287. }
  288. response = requests.request("GET", url, headers=headers, data=payload)
  289. data = response.json()
  290. try:
  291. code = data["code"]
  292. if code != 0:
  293. Common.logger("video").info(
  294. f"未登录,请更换cookie,{data}")
  295. Feishu.bot('recommend', '管理后台', '管理后台cookie失效,请及时更换~', mark, mark_name)
  296. return ""
  297. audio_url = data["content"]["transedVideoPath"]
  298. audio_title = data["content"]['title']
  299. return audio_url, audio_title
  300. except Exception as e:
  301. Common.logger("video").warning(f"获取音频视频链接失败:{e}\n")
  302. return ""
  303. # 获取视频时长
  304. @classmethod
  305. def get_audio_duration(cls, video_url):
  306. ffprobe_cmd = [
  307. "ffprobe",
  308. "-i", video_url,
  309. "-show_entries", "format=duration",
  310. "-v", "quiet",
  311. "-of", "csv=p=0"
  312. ]
  313. output = subprocess.check_output(ffprobe_cmd).decode("utf-8").strip()
  314. return float(output)
  315. # 获取视频文件的时长(秒)
  316. @classmethod
  317. def get_video_duration(cls, video_file):
  318. result = subprocess.run(
  319. ["ffprobe", "-v", "error", "-show_entries", "format=duration",
  320. "-of", "default=noprint_wrappers=1:nokey=1", video_file],
  321. capture_output=True, text=True)
  322. return float(result.stdout)
  323. @classmethod
  324. def clear_mp4_files(cls, folder_path):
  325. # 获取文件夹中所有扩展名为 '.mp4' 的文件路径列表
  326. mp4_files = glob.glob(os.path.join(folder_path, '*.mp4'))
  327. if not mp4_files:
  328. return
  329. # 遍历并删除所有 .mp4 文件
  330. for mp4_file in mp4_files:
  331. os.remove(mp4_file)
  332. print(f"文件夹 '{folder_path}' 中的所有 .mp4 文件已清空。")
  333. # 计算需要拼接的视频
  334. @classmethod
  335. def concat_videos_with_subtitles(cls, videos, audio_duration, platform, mark):
  336. # 计算视频文件列表总时长
  337. if platform == "baokuai":
  338. total_video_duration = sum(cls.get_video_duration(video_file) for video_file in videos)
  339. else:
  340. total_video_duration = sum(cls.get_video_duration(video_file[3]) for video_file in videos)
  341. if platform == "koubo" or platform == "zhannei" or platform == "baokuai":
  342. # 视频时长大于音频时长
  343. if total_video_duration > audio_duration:
  344. return videos
  345. # 计算音频秒数与视频秒数的比率,然后加一得到需要的视频数量
  346. video_audio_ratio = audio_duration / total_video_duration
  347. videos_needed = int(video_audio_ratio) + 2
  348. trimmed_video_list = videos * videos_needed
  349. return trimmed_video_list
  350. else:
  351. # 如果视频总时长小于音频时长,则不做拼接
  352. if total_video_duration < audio_duration:
  353. Common.logger("video").info(f"{mark}的{platform}渠道时长小于等于目标时长,不做视频拼接")
  354. return ""
  355. # 如果视频总时长大于音频时长,则截断视频
  356. trimmed_video_list = []
  357. remaining_duration = audio_duration
  358. for video_file in videos:
  359. video_duration = cls.get_video_duration(video_file[3])
  360. if video_duration <= remaining_duration:
  361. # 如果视频时长小于或等于剩余时长,则将整个视频添加到列表中
  362. trimmed_video_list.append(video_file)
  363. remaining_duration -= video_duration
  364. else:
  365. trimmed_video_list.append(video_file)
  366. break
  367. return trimmed_video_list
  368. # 已使用视频链接存表
  369. @classmethod
  370. def insert_videoAudio(cls, video_files, uid, platform, mark):
  371. current_time = datetime.now()
  372. formatted_time = current_time.strftime("%Y-%m-%d")
  373. for j in video_files:
  374. insert_sql = f"""INSERT INTO agc_video_deposit (audio, video_id, account_id, oss_object_key, time, platform, mark) values ('{uid}', '{j[0]}', '{j[1]}', '{j[2]}', '{formatted_time}', '{platform}', '{mark}')"""
  375. MysqlHelper.update_values(
  376. sql=insert_sql,
  377. env="prod",
  378. machine="",
  379. )
  380. #文件没有则创建目录
  381. @classmethod
  382. def create_folders(cls, mark):
  383. oss_id = cls.random_id()
  384. video_path_url = config['PATHS']['VIDEO_PATH'] + mark + "/"
  385. # srt 目录
  386. s_path_url = config['PATHS']['VIDEO_PATH'] + mark + "/srt/"
  387. # oss 目录
  388. v_path_url = config['PATHS']['VIDEO_PATH'] + mark + "/oss/"
  389. if not os.path.exists(video_path_url):
  390. os.makedirs(video_path_url)
  391. if not os.path.exists(s_path_url):
  392. os.makedirs(s_path_url)
  393. if not os.path.exists(v_path_url):
  394. os.makedirs(v_path_url)
  395. # srt 文件地址
  396. s_path = s_path_url + mark + f"{str(oss_id)}.srt"
  397. # 最终生成视频地址
  398. v_path = v_path_url + mark + f"{str(oss_id)}.mp4"
  399. v_oss_path = v_path_url + mark + f"{str(oss_id)}oss.mp4"
  400. return s_path, v_path, video_path_url, v_oss_path
  401. # 视频拼接
  402. @classmethod
  403. def concatenate_videos(cls, videos, audio_duration, audio_video, platform, s_path, v_path, mark, v_oss_path ):
  404. video_files = cls.concat_videos_with_subtitles(videos, audio_duration, platform, mark)
  405. Common.logger("video").info(f"{mark}的{platform}视频文件:{video_files}")
  406. Common.logger("video").info(f"{mark}的{platform}渠道待生成视频为:{video_files}")
  407. if video_files == "":
  408. return ""
  409. print(f"{mark}的{platform}:开始拼接视频喽~~~")
  410. Common.logger("video").info(f"{mark}的{platform}:开始拼接视频喽~~~")
  411. if os.path.exists(s_path):
  412. # subtitle_cmd = f"subtitles={s_path}:force_style='Fontsize=11,Fontname=Hiragino Sans GB,Outline=0,PrimaryColour=&H000000,SecondaryColour=&H000000'"
  413. subtitle_cmd = f"subtitles={s_path}:force_style='Fontsize=12,Fontname=wqy-zenhei,Bold=1,Outline=0,PrimaryColour=&H000000,SecondaryColour=&H000000'"
  414. else:
  415. # subtitle_cmd = "drawtext=text='分享、转发给群友':fontsize=28:fontcolor=black:x=(w-text_w)/2:y=h-text_h-15"
  416. subtitle_cmd = "drawtext=text='分享、转发给群友':x=(w-text_w)/2:y=h-text_h-15:fontsize=28:fontcolor=black:fontfile=/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc"
  417. # 背景色参数
  418. background_cmd = "drawbox=y=ih-65:color=yellow@1.0:width=iw:height=0:t=fill"
  419. if platform == "koubo" or platform == "zhannei":
  420. text_ptah = cls.bk_text_folders(mark)
  421. with open(text_ptah, 'w') as f:
  422. for file in video_files:
  423. f.write(f"file '{file[3]}'\n")
  424. # 多线程数
  425. num_threads = 4
  426. ffmpeg_cmd_oss = [
  427. "ffmpeg",
  428. "-f", "concat",
  429. "-safe", "0",
  430. "-i", f"{text_ptah}", # 视频文件列表
  431. "-i", audio_video, # 音频文件
  432. "-c:v", "libx264",
  433. "-c:a", "aac",
  434. "-threads", str(num_threads),
  435. "-vf", f"scale=320x480,{background_cmd},{subtitle_cmd}", # 添加背景色和字幕
  436. "-t", str(int(audio_duration)), # 保持与音频时长一致
  437. "-map", "0:v:0", # 映射第一个输入的视频流
  438. "-map", "1:a:0", # 映射第二个输入的音频流
  439. "-y", # 覆盖输出文件
  440. v_oss_path
  441. ]
  442. try:
  443. subprocess.run(ffmpeg_cmd_oss)
  444. print("视频处理完成!")
  445. if os.path.isfile(text_ptah):
  446. os.remove(text_ptah)
  447. except subprocess.CalledProcessError as e:
  448. print(f"视频处理失败:{e}")
  449. else:
  450. VIDEO_COUNTER = 0
  451. FF_INPUT = ""
  452. FF_SCALE = ""
  453. FF_FILTER = ""
  454. ffmpeg_cmd = ["ffmpeg"]
  455. for videos in video_files:
  456. Common.logger("video").info(f"{mark}的{platform}视频:{videos[3]}")
  457. # 添加输入文件
  458. FF_INPUT += f" -i {videos[3]}"
  459. # 为每个视频文件统一长宽,并设置SAR(采样宽高比)
  460. FF_SCALE += f"[{VIDEO_COUNTER}:v]scale=320x480,setsar=1[v{VIDEO_COUNTER}];"
  461. # 为每个视频文件创建一个输入流,并添加到-filter_complex参数中
  462. FF_FILTER += f"[v{VIDEO_COUNTER}][{VIDEO_COUNTER}:a]"
  463. # 增加视频计数器
  464. VIDEO_COUNTER += 1
  465. # 构建最终的FFmpeg命令
  466. ffmpeg_cmd.extend(FF_INPUT.split())
  467. ffmpeg_cmd.extend(["-filter_complex", f"{FF_SCALE}{FF_FILTER}concat=n={VIDEO_COUNTER}:v=1:a=1[v][a]",
  468. "-map", "[v]", "-map", "[a]", v_path])
  469. # 多线程数
  470. num_threads = 4
  471. # 构建 FFmpeg 命令,生成视频
  472. ffmpeg_cmd_oss = [
  473. "ffmpeg",
  474. "-i", v_path, # 视频文件列表
  475. "-i", audio_video, # 音频文件
  476. "-c:v", "libx264", # 复制视频流
  477. "-c:a", "aac", # 编码音频流为AAC
  478. "-threads", str(num_threads),
  479. "-vf", f"{background_cmd},{subtitle_cmd}", # 添加背景色和字幕
  480. "-t", str(int(audio_duration)), # 保持与音频时长一致
  481. "-map", "0:v:0", # 映射第一个输入的视频流
  482. "-map", "1:a:0", # 映射第二个输入的音频流
  483. "-y", # 覆盖输出文件
  484. v_oss_path
  485. ]
  486. try:
  487. subprocess.run(ffmpeg_cmd)
  488. if os.path.isfile(v_path):
  489. subprocess.run(ffmpeg_cmd_oss)
  490. print("视频处理完成!")
  491. except subprocess.CalledProcessError as e:
  492. print(f"视频处理失败:{e}")
  493. print(f"{mark}的{platform}:视频拼接成功啦~~~")
  494. Common.logger("video").info(f"{mark}的{platform}:视频拼接成功啦~~~")
  495. return video_files
  496. # 常规任务
  497. @classmethod
  498. def video_stitching(cls, ex_list):
  499. pq_ids = ex_list["pq_id"]
  500. pq_ids_list = pq_ids.split(',')
  501. mark_name = ex_list['mark_name']
  502. mark = ex_list["mark"]
  503. feishu_id = ex_list["feishu_id"]
  504. video_call = ex_list["video_call"]
  505. parts = video_call.split(',')
  506. result = []
  507. for part in parts:
  508. sub_parts = part.split('--')
  509. result.append(sub_parts)
  510. link = result[0][0]
  511. yhmw_all_count = result[0][1]
  512. if int(yhmw_all_count) == 0:
  513. yhmw_count = 0
  514. else:
  515. yhmw_count = int(int(yhmw_all_count)/2)
  516. # 如果没有该文件目录则创建,有文件目录的话 则删除文件
  517. s_path, v_path, video_path_url, v_oss_path = cls.create_folders(mark)
  518. kb_count = int(result[1][1])
  519. channel = ['douyin', 'kuaishou', 'koubo']
  520. try:
  521. for platform in channel:
  522. limit_count = 35
  523. count = cls.get_link_count(mark, platform)
  524. if platform == "douyin" and count >= yhmw_count:
  525. continue
  526. elif platform == "kuaishou" and count >= yhmw_count:
  527. continue
  528. elif platform == "koubo":
  529. link = result[1][0]
  530. limit_count = 1
  531. if count >= kb_count or kb_count == 0:
  532. Feishu.bot('recommend', 'AGC完成通知', '今日常规自制视频拼接任务完成啦~', mark, mark_name)
  533. return mark
  534. # 获取音频类型+字幕+标题
  535. uid, srt, video_list, cover_status = Material.get_all_data(feishu_id, link, mark)
  536. # 获取已入库的用户id
  537. user_id = cls.get_user_id(platform, mark)
  538. # 获取 未使用的视频链接
  539. url_list = cls.get_url_list(user_id, mark, limit_count)
  540. if url_list == None:
  541. Common.logger("video").info(f"未使用视频链接为空:{url_list}")
  542. return ''
  543. videos = [list(item) for item in url_list]
  544. # 下载视频
  545. videos = Oss.get_oss_url(videos, video_path_url)
  546. if srt:
  547. # 创建临时字幕文件
  548. cls.create_subtitle_file(srt, s_path)
  549. Common.logger("video").info(f"S{mark}的{platform}渠道RT 文件目录创建成功")
  550. # 获取音频
  551. audio_video, audio_title = cls.get_audio_url(uid, mark, mark_name)
  552. Common.logger("video").info(f"{mark}的{platform}渠道获取需要拼接的音频成功")
  553. # 获取音频秒数
  554. audio_duration = cls.get_audio_duration(audio_video)
  555. Common.logger("video").info(f"{mark}的{platform}渠道获取需要拼接的音频秒数为:{audio_duration}")
  556. video_files = cls.concatenate_videos(videos, audio_duration, audio_video, platform, s_path, v_path, mark, v_oss_path)
  557. if video_files == "":
  558. Common.logger("video").info(f"{mark}的{platform}渠道使用拼接视频为空")
  559. return ""
  560. if os.path.isfile(v_oss_path):
  561. Common.logger("video").info(f"{mark}的{platform}渠道新视频生成成功")
  562. else:
  563. Common.logger("video").info(f"{mark}的{platform}渠道新视频生成失败")
  564. return ""
  565. # 随机生成视频oss_id
  566. oss_id = cls.random_id()
  567. # 获取新生成视频时长
  568. v_path_duration = cls.get_audio_duration(v_oss_path)
  569. if v_path_duration > audio_duration+3 or v_path_duration < audio_duration-3:
  570. print(f"{mark}的{platform}渠道最终生成视频秒数错误,生成了:{v_path_duration}秒,实际秒数{audio_duration}")
  571. Common.logger("video").info(f"{mark}的{platform}渠道最终生成视频秒数错误,生成了:{v_path_duration}秒,实际秒数{audio_duration}")
  572. return ""
  573. # 上传 oss
  574. Common.logger("video").info(f"{mark}的{platform}渠道上传到 OSS 生成视频id为:{oss_id}")
  575. oss_object_key = Oss.stitching_sync_upload_oss(v_oss_path, oss_id)
  576. status = oss_object_key.get("status")
  577. if status == 200:
  578. # 获取 oss 视频地址
  579. oss_object_key = oss_object_key.get("oss_object_key")
  580. Common.logger("video").info(f"{mark}的{platform}渠道拼接视频发送成功,OSS 地址:{oss_object_key}")
  581. time.sleep(10)
  582. # 已使用视频存入数据库
  583. Common.logger("video").info(f"{mark}的{platform}渠道开始已使用视频存入数据库")
  584. cls.insert_videoAudio(video_files, uid, platform, mark)
  585. Common.logger("video").info(f"{mark}的{platform}渠道完成已使用视频存入数据库")
  586. Common.logger("video").info(f"{mark}的{platform}渠道开始视频添加到对应用户")
  587. piaoquantv = cls.insert_piaoquantv(oss_object_key, audio_title, pq_ids_list, cover_status, uid)
  588. if piaoquantv:
  589. Common.logger("video").info(f"{mark}的{platform}渠道视频添加到对应用户成功")
  590. if os.path.isfile(v_oss_path):
  591. os.remove(v_oss_path)
  592. if os.path.isfile(v_path):
  593. os.remove(v_path)
  594. if os.path.isfile(s_path):
  595. os.remove(s_path)
  596. # 清空所有mp4数据
  597. cls.clear_mp4_files(video_path_url)
  598. return ''
  599. except Exception as e:
  600. Common.logger("video").warning(f"{mark}的视频拼接失败:{e}\n")
  601. return ''
  602. # 脚本跟随任务
  603. @classmethod
  604. def video_gs_stitching(cls, ex_list):
  605. pq_ids = ex_list["pq_id"]
  606. pq_ids_list = pq_ids.split(',') # 账号ID
  607. mark_name = ex_list['mark_name'] # 负责人
  608. mark = ex_list["mark"] # 标示
  609. feishu_id = ex_list["feishu_id"] # 飞书文档ID
  610. video_call = ex_list["video_call"]
  611. parts = video_call.split(',')
  612. result = []
  613. for part in parts:
  614. sub_parts = part.split('--')
  615. result.append(sub_parts)
  616. link = result[0][0] # 脚本链接
  617. count = result[0][1] # 生成条数
  618. zd_count = ex_list["zd_count"] # 生成总条数
  619. # # 总条数
  620. # result = re.match(r'([^0-9]+)', mark).group()
  621. # all_count = cls.get_link_gs_count(result)
  622. # if all_count >= int(zd_count):
  623. # Feishu.bot('recommend', 'AGC完成通知', '今日脚本跟随视频拼接任务完成啦~', mark.split("-")[0], mark_name)
  624. # return mark
  625. # 获取音频类型+字幕+标题
  626. uid, srt, video_list, cover = Material.get_all_data(feishu_id, link, mark)
  627. platform_list = ex_list["platform_list"] # 渠道
  628. # 如果没有该文件目录则创建,有文件目录的话 则删除文件
  629. s_path, v_path, video_path_url, v_oss_path = cls.create_folders(mark)
  630. platform = ''
  631. if platform_list:
  632. platform_name_list = random.choice(platform_list)
  633. platform_name = platform_name_list[1]
  634. platform_url = platform_name_list[0]
  635. if platform_name == "快手":
  636. platform = 'kuaishou'
  637. elif platform_name == "抖音":
  638. platform = 'douyin'
  639. zw_count = cls.get_link_zw_count(mark, "zhannei")
  640. if zw_count >= int(count):
  641. return video_call
  642. # 获取所有视频素材ID
  643. video_list = Material.get_user_id(feishu_id, platform_url)
  644. limit_count = 35
  645. else:
  646. platform = 'zhannei'
  647. zw_count = cls.get_link_zn_count(mark, platform)
  648. if zw_count >= int(count):
  649. return video_call
  650. limit_count = 1
  651. Common.logger("gs_video").info(f"{mark}的{platform} 开始查询 {video_list}")
  652. url_list = cls.get_url_gs_list(video_list, mark, limit_count)
  653. if url_list == None:
  654. Common.logger("gs_video").info(f"{mark}的{platform} 渠道 视频画面不足无法拼接")
  655. return
  656. videos = [list(item) for item in url_list]
  657. try:
  658. # 下载视频
  659. videos = Oss.get_oss_url(videos, video_path_url)
  660. if srt:
  661. # 创建临时字幕文件
  662. cls.create_subtitle_file(srt, s_path)
  663. Common.logger("gs_video").info(f"S{mark}的{platform}渠道RT 文件目录创建成功")
  664. # 获取音频
  665. audio_video, audio_title = cls.get_audio_url(uid, mark, mark_name)
  666. Common.logger("gs_video").info(f"{mark}的{platform}渠道获取需要拼接的音频成功")
  667. # 获取音频秒数
  668. audio_duration = cls.get_audio_duration(audio_video)
  669. Common.logger("gs_video").info(f"{mark}的{platform}渠道获取需要拼接的音频秒数为:{audio_duration}")
  670. video_files = cls.concatenate_videos(videos, audio_duration, audio_video, platform, s_path, v_path, mark, v_oss_path)
  671. if video_files == "":
  672. Common.logger("gs_video").info(f"{mark}的{platform}渠道使用拼接视频为空")
  673. return ""
  674. if os.path.isfile(v_oss_path):
  675. Common.logger("gs_video").info(f"{mark}的{platform}渠道新视频生成成功")
  676. else:
  677. Common.logger("gs_video").info(f"{mark}的{platform}渠道新视频生成失败")
  678. return ""
  679. # 随机生成视频oss_id
  680. oss_id = cls.random_id()
  681. # 获取新生成视频时长
  682. v_path_duration = cls.get_audio_duration(v_oss_path)
  683. if v_path_duration > audio_duration+3 or v_path_duration < audio_duration-3:
  684. print(f"{mark}的{platform}渠道最终生成视频秒数错误,生成了:{v_path_duration}秒,实际秒数{audio_duration}")
  685. Common.logger("gs_video").info(f"{mark}的{platform}渠道最终生成视频秒数错误,生成了:{v_path_duration}秒,实际秒数{audio_duration}")
  686. return ""
  687. # 上传 oss
  688. Common.logger("gs_video").info(f"{mark}的{platform}渠道上传到 OSS 生成视频id为:{oss_id}")
  689. oss_object_key = Oss.stitching_sync_upload_oss(v_oss_path, oss_id)
  690. status = oss_object_key.get("status")
  691. if status == 200:
  692. # 获取 oss 视频地址
  693. oss_object_key = oss_object_key.get("oss_object_key")
  694. Common.logger("gs_video").info(f"{mark}的{platform}渠道拼接视频发送成功,OSS 地址:{oss_object_key}")
  695. time.sleep(10)
  696. # 已使用视频存入数据库
  697. Common.logger("gs_video").info(f"{mark}的{platform}渠道开始已使用视频存入数据库")
  698. cls.insert_videoAudio(video_files, uid, platform, mark)
  699. Common.logger("gs_video").info(f"{mark}的{platform}渠道完成已使用视频存入数据库")
  700. Common.logger("gs_video").info(f"{mark}的{platform}渠道开始视频添加到对应用户")
  701. piaoquantv = cls.insert_piaoquantv(oss_object_key, audio_title, pq_ids_list, cover, uid)
  702. if piaoquantv:
  703. Common.logger("gs_video").info(f"{mark}的{platform}渠道视频添加到对应用户成功")
  704. if os.path.isfile(v_oss_path):
  705. os.remove(v_oss_path)
  706. if os.path.isfile(v_path):
  707. os.remove(v_path)
  708. if os.path.isfile(s_path):
  709. os.remove(s_path)
  710. # 清空所有mp4数据
  711. for file_path in videos:
  712. os.remove(file_path[3])
  713. print(f"已删除文件:{file_path[3]}")
  714. return ''
  715. except Exception as e:
  716. Common.logger("gs_video").warning(f"{mark}的视频拼接失败:{e}\n")
  717. return ''
  718. # 爆款跟随任务
  719. @classmethod
  720. def video_bk_stitching(cls, ex_list):
  721. pq_ids = ex_list["pq_id"]
  722. pq_ids_list = pq_ids.split(',') # 账号ID
  723. mark_name = ex_list['mark_name'] # 负责人
  724. mark = ex_list["mark"] # 标示
  725. feishu_id = ex_list["feishu_id"] # 飞书文档ID
  726. video_call = ex_list["video_call"] #脚本sheet
  727. platform = 'baokuai'
  728. list_data = Material.get_allbk_data(feishu_id, video_call, mark)
  729. if len(list_data) == 0:
  730. Feishu.bot('recommend', 'AGC脚本通知', f'今日没有爆款视频拼接任务', mark.split("-")[0], mark_name)
  731. return mark
  732. # 如果没有该文件目录则创建,有文件目录的话 则删除文件
  733. s_path, v_path, video_path_url, v_oss_path = cls.create_folders(mark)
  734. for data in list_data:
  735. try:
  736. uid = data['uid'] # 音频id
  737. srt = data['text'] # srt
  738. videos = data['video']
  739. cover = data['cover']
  740. if ',' in videos:
  741. videos = videos.split(',')
  742. else:
  743. videos = [videos]
  744. if srt:
  745. # 创建临时字幕文件
  746. cls.create_subtitle_file(srt, s_path)
  747. Common.logger("bk_video").info(f"S{mark} 文件目录创建成功")
  748. # 获取音频
  749. audio_video, audio_title = cls.get_audio_url(uid, mark, mark_name)
  750. Common.logger("bk_video").info(f"{mark}获取需要拼接的音频成功")
  751. # 获取音频秒数
  752. audio_duration = cls.get_audio_duration(audio_video)
  753. video = random.choice(videos)
  754. video_url = cls.get_zn_video(video, mark, mark_name)
  755. download_video = Oss.get_bk_url(video_url, video_path_url, video)
  756. if download_video:
  757. video_files = cls.bk_concatenate_videos(download_video, audio_duration, audio_video, platform, s_path, v_path, mark, v_oss_path)
  758. if video_files == "":
  759. Common.logger("bk_video").info(f"{mark}的{platform}渠道使用拼接视频为空")
  760. continue
  761. if os.path.isfile(v_oss_path):
  762. Common.logger("bk_video").info(f"{mark}的{platform}渠道新视频生成成功")
  763. else:
  764. Common.logger("bk_video").info(f"{mark}的{platform}渠道新视频生成失败")
  765. continue
  766. # 随机生成视频oss_id
  767. oss_id = cls.random_id()
  768. # 获取新生成视频时长
  769. v_path_duration = cls.get_audio_duration(v_oss_path)
  770. if v_path_duration > audio_duration + 3 or v_path_duration < audio_duration - 3:
  771. print(f"{mark}最终生成视频秒数错误,生成了:{v_path_duration}秒,实际秒数{audio_duration}")
  772. Common.logger("gs_video").info(
  773. f"{mark}最终生成视频秒数错误,生成了:{v_path_duration}秒,实际秒数{audio_duration}")
  774. continue
  775. # 上传 oss
  776. Common.logger("bk_video").info(f"{mark}上传到 OSS 生成视频id为:{oss_id}")
  777. oss_object_key = Oss.stitching_sync_upload_oss(v_oss_path, oss_id)
  778. status = oss_object_key.get("status")
  779. if status == 200:
  780. # 获取 oss 视频地址
  781. oss_object_key = oss_object_key.get("oss_object_key")
  782. Common.logger("bk_video").info(f"{mark}拼接视频发送成功,OSS 地址:{oss_object_key}")
  783. time.sleep(10)
  784. Common.logger("bk_video").info(f"{mark}开始视频添加到对应用户")
  785. piaoquantv = cls.insert_piaoquantv(oss_object_key, audio_title, pq_ids_list, cover, uid)
  786. if piaoquantv:
  787. Common.logger("bk_video").info(f"{mark}视频添加到对应用户成功")
  788. if os.path.isfile(v_oss_path):
  789. os.remove(v_oss_path)
  790. if os.path.isfile(v_path):
  791. os.remove(v_path)
  792. if os.path.isfile(s_path):
  793. os.remove(s_path)
  794. # 清空所有mp4数据
  795. for file_path in download_video:
  796. os.remove(file_path)
  797. print(f"已删除文件:{file_path}")
  798. random_wait_time = random.randint(10, 80)
  799. time.sleep(random_wait_time)
  800. else:
  801. Common.logger("bk_video").info(f"{mark}的视频下载视频")
  802. continue
  803. except Exception as e:
  804. Common.logger("bk_video").warning(f"{mark}的视频拼接失败:{e}\n")
  805. continue
  806. Feishu.bot('recommend', 'AGC完成通知', f'今日脚本爆款视频拼接任务完成,共{len(list_data)}条', mark.split("-")[0], mark_name)
  807. return mark
  808. @classmethod
  809. def get_zn_video(cls, video, mark, mark_name):
  810. cookie = Material.get_houtai_cookie()
  811. url = f"https://admin.piaoquantv.com/manager/video/detail/{video}"
  812. payload = {}
  813. headers = {
  814. 'authority': 'admin.piaoquantv.com',
  815. 'accept': 'application/json, text/plain, */*',
  816. 'accept-language': 'zh-CN,zh;q=0.9',
  817. 'cache-control': 'no-cache',
  818. 'cookie': cookie,
  819. 'pragma': 'no-cache',
  820. 'referer': f'https://admin.piaoquantv.com/cms/post-detail/{video}/detail',
  821. 'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
  822. 'sec-ch-ua-mobile': '?0',
  823. 'sec-ch-ua-platform': '"macOS"',
  824. 'sec-fetch-dest': 'empty',
  825. 'sec-fetch-mode': 'cors',
  826. 'sec-fetch-site': 'same-origin',
  827. 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
  828. }
  829. response = requests.request("GET", url, headers=headers, data=payload)
  830. data = response.json()
  831. code = data["code"]
  832. if code != 0:
  833. if "-" in mark:
  834. mark1 = mark.split("-")[0]
  835. Common.logger("video").info(
  836. f"未登录,请更换cookie,{data}")
  837. Feishu.bot('recommend', '管理后台', '管理后台cookie失效,请及时更换~', mark1, mark_name)
  838. return
  839. video_url = data["content"]["transedVideoPath"]
  840. return video_url
  841. # text文件没有则创建目录
  842. @classmethod
  843. def bk_text_folders(cls, mark):
  844. oss_id = cls.random_id()
  845. v_text_url = config['PATHS']['VIDEO_PATH'] + mark + "/text/"
  846. if not os.path.exists(v_text_url):
  847. os.makedirs(v_text_url)
  848. # srt 文件地址
  849. text_path = v_text_url + mark + f"{str(oss_id)}.text"
  850. return text_path
  851. # 爆款视频拼接
  852. @classmethod
  853. def bk_concatenate_videos(cls, videos, audio_duration, audio_video, platform, s_path, v_path, mark, v_oss_path):
  854. text_ptah = cls.bk_text_folders(mark)
  855. video_files = cls.concat_videos_with_subtitles(videos, audio_duration, platform, mark)
  856. with open(text_ptah, 'w') as f:
  857. for file in video_files:
  858. f.write(f"file '{file}'\n")
  859. Common.logger("video").info(f"{mark}的{platform}视频文件:{video_files}")
  860. if video_files == "":
  861. return ""
  862. print(f"{mark}的{platform}:开始拼接视频喽~~~")
  863. Common.logger("video").info(f"{mark}的{platform}:开始拼接视频喽~~~")
  864. if os.path.exists(s_path):
  865. # subtitle_cmd = f"subtitles={s_path}:force_style='Fontsize=11,Fontname=Hiragino Sans GB,Outline=0,PrimaryColour=&H000000,SecondaryColour=&H000000'"
  866. subtitle_cmd = f"subtitles={s_path}:force_style='Fontsize=12,Fontname=wqy-zenhei,Bold=1,Outline=0,PrimaryColour=&H000000,SecondaryColour=&H000000'"
  867. else:
  868. # subtitle_cmd = "drawtext=text='分享、转发给群友':fontsize=28:fontcolor=black:x=(w-text_w)/2:y=h-text_h-15"
  869. subtitle_cmd = "drawtext=text='分享、转发给群友':x=(w-text_w)/2:y=h-text_h-15:fontsize=28:fontcolor=black:fontfile=/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc"
  870. # 背景色参数
  871. background_cmd = "drawbox=y=ih-65:color=yellow@1.0:width=iw:height=0:t=fill"
  872. # 多线程数
  873. num_threads = 4
  874. # 构建 FFmpeg 命令,生成视频
  875. ffmpeg_cmd_oss = [
  876. "ffmpeg",
  877. "-f", "concat",
  878. "-safe", "0",
  879. "-i", f"{text_ptah}", # 视频文件列表
  880. "-i", audio_video, # 音频文件
  881. "-c:v", "libx264",
  882. "-c:a", "aac",
  883. "-threads", str(num_threads),
  884. "-vf", f"scale=320x480,{background_cmd},{subtitle_cmd}", # 添加背景色和字幕
  885. "-t", str(int(audio_duration)), # 保持与音频时长一致
  886. "-map", "0:v:0", # 映射第一个输入的视频流
  887. "-map", "1:a:0", # 映射第二个输入的音频流
  888. "-y", # 覆盖输出文件
  889. v_oss_path
  890. ]
  891. try:
  892. subprocess.run(ffmpeg_cmd_oss)
  893. print("视频处理完成!")
  894. if os.path.isfile(text_ptah):
  895. os.remove(text_ptah)
  896. except subprocess.CalledProcessError as e:
  897. print(f"视频处理失败:{e}")
  898. print(f"{mark}:视频拼接成功啦~~~")
  899. Common.logger("video").info(f"{mark}:视频拼接成功啦~~~")
  900. return video_files