在FFmpeg字幕文件名中转义特殊字符
问题描述:
如果您的字幕文件名是“Hi,y'all.srt”,那么如何正确转义FFmpeg?逗号作品使用反斜线转义,但无论我尝试什么样的技巧,我都无法让报价工作!在FFmpeg字幕文件名中转义特殊字符
$ ffmpeg -vf subtitles="Hi\, y\\\'all.srt" -t 1 -f null -
ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.42)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-libass --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-vda
libavutil 55. 58.100/55. 58.100
libavcodec 57. 89.100/57. 89.100
libavformat 57. 71.100/57. 71.100
libavdevice 57. 6.100/57. 6.100
libavfilter 6. 82.100/6. 82.100
libavresample 3. 5. 0/3. 5. 0
libswscale 4. 6.100/4. 6.100
libswresample 2. 7.100/2. 7.100
libpostproc 54. 5.100/54. 5.100
[Parsed_subtitles_0 @ 0x7fba7af36080] Shaper: FriBidi 0.19.7 (SIMPLE) HarfBuzz-ng 1.4.8 (COMPLEX)
[Parsed_subtitles_0 @ 0x7fba7af36080] Unable to open Hi, yall.srt
[AVFilterGraph @ 0x7fba7ad05d60] Error initializing filter 'subtitles' with args 'Hi, y\all.srt'
Error reinitializing filters!
Failed to inject frame into filter network: No such file or directory
Error while processing the decoded data for stream #0:0
Conversion failed!
答
在Windows 7中,这个工程:
subtitles="Hi\, y\\\'all.srt"
不在MacOS 1-4个反斜杠工作。我尝试了所有其他可以想象的变体,比如''subtitles = a \''''''b.srt'',它会稍微改变错误信息:'无法打开a,b.srt'和'错误初始化过滤器字幕args'a,'b.srt'。 (注意第一条错误消息中缺少引号。)所以这对我来说似乎是一个错误。你怎么看? – forthrin
尝试,但没有用引号括住过滤器字符串,就像在我的回答中一样。我假设你是在MacOS上。 – Mulvya
它看起来像你的答案缺失。无论如何,我尝试没有周围的报价。不适用于任何数量的反斜杠。 – forthrin