无法将选项值 xxx.srt 解析为 ffmpeg 中的图像大小

it_*_*ure 3 windows parsing ffmpeg

我已经在 Windows 中为 ffmpeg 设置了环境变量,想要使用 ffmpeg 将 srt 文件嵌入到我的 mp4 文件中:

ffmpeg -i f:\sample\dance.mp4 -vf subtitles='f:\sample\dance.srt'  f:\sample\out.mp4
Run Code Online (Sandbox Code Playgroud)

它遇到一个奇怪的错误:

Press [q] to stop, [?] for help
[subtitles @ 0000000002c2fd00] Unable to parse option value "sampledance.srt" as
 image size
    Last message repeated 1 times
[subtitles @ 0000000002c2fd00] Error setting option original_size to value sampl
edance.srt.
[Parsed_subtitles_0 @ 00000000005410c0] Error applying options to the filter.
[AVFilterGraph @ 0000000002940440] Error initializing filter 'subtitles' with ar
gs 'f:\sample\dance.srt'
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!
Run Code Online (Sandbox Code Playgroud)

我将文件复制dance.mp4dance.srtf:\ffmpeg\bin然后执行以下操作:

cd  \d  f:\ffmpeg\bin
ffmpeg -i dance.mp4 -vf subtitles=dance.srt   out.mp4
Run Code Online (Sandbox Code Playgroud)

它工作正常,如何让 ffmpeg f:\sample\dance.srt正确解析选项值,使命令在我的 Windows 中正常执行?

ffmpeg -i f:\sample\dance.mp4 -vf subtitles='f:\sample\dance.srt'  f:\sample\out.mp4
Run Code Online (Sandbox Code Playgroud)

@kesh,写成下面这样是没有用的:

ffmpeg -i f:\sample\dance.mp4 -vf "subtitles='f:\sample\dance.srt'"  f:\sample\out.mp4
Run Code Online (Sandbox Code Playgroud)

Rot*_*tem 5

FFmpeg 过滤器图的解析规则与其他参数使用的规则不同。

由于'e\sample\dance.srt'是过滤器图参数的值,因此我们必须在每个特殊字符之前添加转义字符:

ffmpeg -i e:\sample\dance.mp4 -vf subtitles='e\:\\sample\\dance.srt' e:\sample\out.mp4
Run Code Online (Sandbox Code Playgroud)

该主题在关于过滤器图转义的注释(以及其他地方)中进行了描述。