渲染后再to annexb,使用新逻辑拼接

This commit is contained in:
2025-01-22 14:31:59 +08:00
parent 4c05846986
commit 29bb80f3b9
3 changed files with 16 additions and 4 deletions

View File

@ -21,6 +21,19 @@ def to_annexb(file):
else:
return file
def re_encode_and_annexb(file):
if not os.path.exists(file):
return file
logger.info("ReEncodeAndAnnexb: %s", file)
ffmpeg_process = subprocess.run(["ffmpeg", "-y", "-hide_banner", "-i", file, "-c:v", "h264_qsv", "-global_quality", "28", "-look_ahead", "1", "-bsf:v", "h264_mp4toannexb",
"-f", "mpegts", file+".ts"])
logger.info("ReEncodeAndAnnexb: %s, returned: %s", file, ffmpeg_process.returncode)
if ffmpeg_process.returncode == 0:
os.remove(file)
return file+".ts"
else:
return file
def start_render(ffmpeg_task: FfmpegTask):
logger.info(ffmpeg_task)
if not ffmpeg_task.need_run():
@ -64,7 +77,7 @@ def duration_str_to_float(duration_str: str) -> float:
def probe_video_info(video_file):
# 获取宽度和高度
result = subprocess.run(
["ffprobe.exe", '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'stream=width,height:format=duration', '-of',
["ffprobe", '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'stream=width,height:format=duration', '-of',
'csv=s=x:p=0', video_file],
stderr=subprocess.STDOUT,
**subprocess_args(True)