#3189 最后一步字幕配音嵌入时出错=system:macOS-26.2-arm64-arm-64bitversion:v3.96frozen:Falselanguage:zhroot_dir:/Users/zhousheng/Documents/p

45.43* Posted at: 13 hours ago 👁19

最后一步字幕配音嵌入时出错


=
system:macOS-26.2-arm64-arm-64bit
version:v3.96
frozen:False
language:zh
root_dir:/Users/zhousheng/Documents/python/pyVideoTrans
Python: 3.10.19 (main, Feb 4 2026, 00:02:50) [Clang 21.1.4 ]


==准备要嵌入的字幕:self.cfg.subtitle_type=1


=
[DEBUG] 最终确定字幕嵌入类型:1 ,目标字幕语言:chi, 字幕文件:/Users/zhousheng/Documents/python/pyVideoTrans/tmp/25097/d5b7bbfef0/end.srt

[DEBUG] cmd=['ffmpeg', '-hide_banner', '-ignore_unknown', '-threads', '0', '-y', '-i', '/Users/zhousheng/Documents/python/pyVideoTrans/tmp/25097/d5b7bbfef0/end-edit.srt', '/Users/zhousheng/Documents/python/pyVideoTrans/tmp/25097/d5b7bbfef0/end.ass']
[DEBUG] [export_style] 警告:JSON 配置文件不存在: /Users/zhousheng/Documents/python/pyVideoTrans/videotrans/ass.json,跳过样式替换
[DEBUG] 检测到硬件编码器 hevc_videotoolbox,正在调整参数...
[DEBUG] cmd=['ffmpeg', '-hide_banner', '-ignore_unknown', '-threads', '0', '-y', '-progress', 'compose1770619445.927959.txt', '-i', 'novoice.mp4', '-i', 'origin_audio.m4a', '-map', '0:v', '-m
......
t has been prepared without regard to any particular person’s investment objectives, finan

                : 
                : You should seek appropriate advice from your broker, or licensed investment advisor, before taking any action. Past performance does not guarantee future results. Simulated performance results contain inherent limitations. Unlike actual performance record
synopsis        : In This Lecture I Discuss How Algorithms Refer To Time To Reprice On The Markets.
                : 
                : 
                : http://thematrixunlocked.co/theonlytradingstrategy
                : Unlock The Matrix Behind Financial Markets:
                : 
                : 
                : 
                : Join My Free Public Telegram:
                : https://t.me/+WnLHBrzvsfQzZjRk
                : 
                : Risk Disclaimer
                : The footage shown in this video should not be considered as any form of financial advice. Participating in the financial markets carries along huge (financial) risk. Zeussy is not responsible in any way for a viewer his/her actions. Viewers of these type 
                : 
                : Government Required Risk Disclaimer and Disclosure Statement
                : 
                : CFTC RULE 4.41 – HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR
                : 
                : Trading performance displayed herein is hypothetical. Hypothetical performance results have many inherent limitations, some of which are described below. No representation is being made that any account will or is likely to achieve profits or losses simil
                : 
                : Commission Futures and Options trading has large potential rewards, but also large potential risk. You must be aware of the risks and be willing to accept them in order to invest in the futures and options markets. Don’t trade with money you can’t aff
                : 
                : Trade at your own risk. The information provided here is of the nature of a general comment only and neither purports nor intends to be, specific trading advice. It has been prepared without regard to any particular person’s investment objectives, finan
                : 
                : You should seek appropriate advice from your broker, or licensed investment advisor, before taking any action. Past performance does not guarantee future results. Simulated performance results contain inherent limitations. Unlike actual performance record

Duration: 01:04:44.68, start: 0.000000, bitrate: 270 kb/s
Stream #0:00x1: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 267 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)

Metadata:
  handler_name    : ISO Media file produced by Google Inc.
  vendor_id       : [0][0][0][0]
  encoder         : Lavc62.11.100 libx264

Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'origin_audio.m4a':
Metadata:

major_brand     : M4A 
minor_version   : 512
compatible_brands: M4A isomiso2
encoder         : Lavf62.3.100

Duration: 01:04:44.68, start: 0.000000, bitrate: 91 kb/s
Stream #1:00x1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 90 kb/s (default)

Metadata:
  handler_name    : SoundHandler
  vendor_id       : [0][0][0][0]

[AVFilterGraph @ 0xb90c10680] No option name near 'end.ass'
[AVFilterGraph @ 0xb90c10680] Error parsing a filter description around:
[AVFilterGraph @ 0xb90c10680] Error parsing filterchain 'subtitles='end.ass'' around:
Error opening output file laste_target.mp4.
Error opening output files: Invalid argument

4 Replies

这是由于 FFmpeg 在 macOS 上处理字幕文件路径时,因路径中包含单引号导致的参数解析错误。

具体原因是软件生成的 FFmpeg 命令中,字幕滤镜参数 -vf "subtitles='end.ass'" 在 macOS 环境下被错误解析,FFmpeg 无法识别 'end.ass' 这个路径。

解决方案:

  1. 临时解决(针对当前任务)

    • 进入日志中显示的临时目录:/Users/zhousheng/Documents/python/pyVideoTrans/tmp/25097/d5b7bbfef0/
    • 手动执行修正后的 FFmpeg 命令。将原命令中的 -vf "subtitles='end.ass'" 替换为 -vf "subtitles=end.ass"(去掉路径两边的单引号)。
    • 例如,CPU 编码的命令应修改为:
      ffmpeg -hide_banner -ignore_unknown -threads 0 -y -progress compose1770619445.927959.txt -i novoice.mp4 -i origin_audio.m4a -map 0:v -map 1:a -c:v libx265 -c:a copy -vf "subtitles=end.ass" -movflags +faststart -crf 24 -preset veryfast -t 3884.680000 laste_target.mp4
  2. 根本解决(更新软件)

    • 这是一个已知的 macOS 平台兼容性问题。请更新你的 pyVideoTrans 到最新版本。如果你是源码部署,请执行 git pull 拉取最新代码,然后重新 uv sync。此问题在较新版本中已修复。

注意:你的系统是 macOS arm64,使用了 hevc_videotoolbox 硬件编码器,这是正确的。但字幕路径解析错误导致编码失败,软件自动回退到 CPU 编码(libx265)也因同样原因失败。

请查阅相关文档:

已经是最新代码了,还是报这个错误,怎样解决?

这是由于最新代码中针对 macOS 的 FFmpeg 字幕路径处理逻辑可能仍未完全覆盖你的特定情况。错误核心是 FFmpeg 滤镜参数 subtitles='end.ass' 中的单引号在 macOS 系统上被错误解析。

解决方案:

  1. 手动修改源码(临时方案)

    • 找到源码文件:/Users/zhousheng/Documents/python/pyVideoTrans/videotrans/translate/translate.py(路径可能类似,请根据你的实际目录查找)。
    • 在文件中搜索 subtitles="subtitles='"
    • 找到构建 FFmpeg 命令行的代码段。通常,它会将字幕文件路径用单引号包裹。你需要修改这部分代码,移除路径两边的单引号,或者确保路径是绝对路径且不加引号。
    • 例如,将类似 f"subtitles='{字幕文件路径}'" 的代码修改为 f"subtitles={字幕文件路径}"(注意:如果路径包含空格,则仍需引号,但你的临时路径 end.ass 不含空格,可以去掉)。
    • 保存文件并重启软件。
  2. 使用绝对路径(测试方案)

    • 在软件的高级设置或相关配置中,检查是否有选项可以指定输出目录或临时目录。尝试将其设置为一个不包含空格、中文和特殊字符的绝对路径(例如 /Users/zhousheng/video_tmp)。
    • 这可能会影响 FFmpeg 命令生成时路径的构建方式。
  3. 反馈给开发者

    • 由于你已确认是最新代码,此问题可能是一个尚未被广泛报告的边缘案例。
    • 请将完整的错误日志(特别是包含 [DEBUG] cmd= 的那几行命令)提交到 pyVideoTrans 的官方 Issues 页面或论坛,并注明你的 macOS 版本和软件版本(v3.96)。

根本原因分析:在 macOS 的某些 shell 环境下,FFmpeg 通过 Python subprocess 调用时,对滤镜字符串中嵌套引号的处理可能与 Windows/Linux 不同,导致 'end.ass' 没有被正确剥离,FFmpeg 将其视为文件名的一部分而找不到文件。

临时完成当前任务:按照之前的方法,进入临时目录 /Users/zhousheng/Documents/python/pyVideoTrans/tmp/25097/d5b7bbfef0/,手动运行修改后的 FFmpeg 命令(去掉 subtitles= 后的单引号)来生成最终视频。

请查阅相关文档:

打开软件目录/videotrans/trans_create.py
搜索 f"subtitles='{subtitles_file}'"
删掉 这里面的两个单引号 '
注意只删除单引号,共有两个地方需要这样修改

Post Your Reply
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update.

Related resource