如何让 mplayer 使用字幕?

如何让 mplayer 使用字幕?

我正在尝试按以下方式在 mkv 文件中使用字幕:

mplayer video.mkv
mplayer -sub video.srt video.mkv
mplayer video.mkv -sub video.srt

但只播放了视频,没有字幕。播放视频时我还按了几个按钮(“j”、“u”、“s”),但没有任何变化。

操作系统:MacOS 10.13.16 mplayer:1.3.0-4.2.1

也许我遗漏了什么?或者mplayer必须以某种特殊、复杂的方式进行编译?或者缺少库?或者是因为它是 Mac?

有没有办法将 srt 文件中的字幕与 mkv 视频一起使用mplayer


我已尝试按照评论中的建议设置配置,如下所示这里mkv。但是我在播放与srt文件在同一个文件夹下的文件时出现以下错误:

Warning unknown option subfont-text-scale at line 3
Warning unknown option subfont-osd-scale at line 4
The fontconfig option can't be used in a config file.
Error parsing option fontconfig=yes at line 5

srt 文件中的前两个条目如下:

1
00:00:00,000 --> 00:00:05,000
<font face="Hiruko" size="38">Test</font>

2
00:00:05,000 --> 00:00:14,060
<font face="Hiruko" size="38">Subs: English</font>

当前内容.mplayer/config

# Write your default config options here!
subalign=2
font = "Arial"
subcp = iso8859-1
# Set font.
#font=/home/osmo/.fonts/microsoft-vista/calibri.ttf

# Set font encoding.
subfont-encoding=unicode

# Set subtitle file encoding.
unicode=yes
utf8=yes

当我按如下方式播放文件时

mplayer -v video.mkv

视频播放正常,音频正常,但没有字幕。控制台中的输出如下:

Configuration: --cc=clang --host-cc=clang --disable-cdparanoia --prefix=/usr/local/Cellar/mplayer/1.3.0 --disable-x11
CommandLine: '-v' 'video.mkv'
Using Darwin accurate timing
get_path('input.conf') -> '/Users/adietz/.mplayer/input.conf'
Reading optional input config file /Users/adietz/.mplayer/input.conf: No such file or directory
Reading optional input config file /usr/local/Cellar/mplayer/1.3.0/etc/mplayer/input.conf: No such file or directory
Falling back on default (hardcoded) input config
Can't init Apple Remote.
get_path('video.mkv.conf') -> '/Users/adietz/.mplayer/video.mkv.conf'

Playing video.mkv.
get_path('sub/') -> '/Users/adietz/.mplayer/sub/'
[file] File size is 745530259 bytes
STREAM: [file] video.mkv
STREAM: Description: File
STREAM: Author: Albeu
STREAM: Comment: based on the code from ??? (probably Arpi)
libavformat version 57.25.100 (internal)
Configuration: --enable-gpl --enable-postproc
LAVF_check: Matroska / WebM
libavformat file format detected.
st:0 removing common factor 1000000 from timebase
st:1 removing common factor 1000000 from timebase
[matroska,webm @ 0x103b35490]Before avformat_find_stream_info() pos: 5647 bytes read:32768 seeks:0
[h264 @ 0x103b53440]user data:"x264 - core 125 r2200 999b753 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:1:1 analyse=0x3:0x133 me=umh subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=4 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=0 open_gop=0 weightp=2 keyint=240 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.40 aq=1:1.00"
[h264 @ 0x103b53440]user data:"x264 - core 125 r2200 999b753 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:1:1 analyse=0x3:0x133 me=umh subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=4 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=0 open_gop=0 weightp=2 keyint=240 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.40 aq=1:1.00"
[h264 @ 0x103b53440]no picture 
[matroska,webm @ 0x103b35490]All info found
[matroska,webm @ 0x103b35490]After avformat_find_stream_info() pos: 213450 bytes read:229205 seeks:0 frames:12
==> Found video stream: 0
======= VIDEO Format ======
  biSize 82
  biWidth 1440
  biHeight 1080
  biPlanes 1
  biBitCount 0
  biCompression 875967048='H264'
  biSizeImage 0
Unknown extra header dump: [1] [64] [0] [28] [ff] [e1] [0] [19] [67] [64] [0] [28] [ac] [d9] [80] [5a] [2] [27] [e5] [c0] [44] [0] [0] [f] [a4] [0] [2] [ee] [2] [3c] [60] [c6] [68] [1] [0] [6] [68] [e9] [70] [6c] [b2] [2c] 
===========================
[lavf] stream 0: video (h264), -vid 0
==> Found audio stream: 1
======= WAVE Format =======
Format Tag: 61868 (0xF1AC)
Channels: 2
Samplerate: 48000
avg byte/sec: 0
Block align: 1
bits/sample: 24
cbSize: 34
Unknown extra header dump: [10] [0] [10] [0] [0] [1] [89] [0] [1e] [54] [b] [b8] [3] [70] [4] [6d] [31] [30] [6b] [fc] [52] [fd] [5d] [86] [7e] [6f] [3] [e] [0] [89] [52] [77] [46] [67] 
==========================================================================
[lavf] stream 1: audio (flac), -aid 0
LAVF: 1 audio and 1 video streams found
LAVF: build 3742052
VIDEO:  [H264]  1440x1080  0bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:44  fourcc:0x34363248  size:1440x1080  fps:23.976  ftime:=0.0417
2018-10-16 08:08:13.995 mplayer[62669:997915] *** WARNING: Textured window <NSWindow: 0x7fa16f51f4a0> is getting an implicitly transparent titlebar. This will break when linking against newer SDKs. Use NSWindow's -titlebarAppearsTransparent=YES instead.
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 57.24.102 (internal)
Configuration: --enable-gpl --enable-postproc
INFO: libavcodec init OK!
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
Clip info:
 encoder: libebml v1.2.3 + libmatroska v1.3.0
 creation_time: 2012-09-12 10:05:57
Load subtitles in ./
get_path('sub/') -> '/Users/adietz/.mplayer/sub/'
[file] File size is 43583 bytes
STREAM: [file] ./video.srt
STREAM: Description: File
STREAM: Author: Albeu
STREAM: Comment: based on the code from ??? (probably Arpi)
SUB: Detected subtitle file format: subviewer
SUB: opened iconv descriptor.
SUB: closed iconv descriptor.
SUB: Read 318 subtitles, 0 bad line(s).
SUB: Adjusted 102 subtitle(s).
SUB: Added subtitle file (1): ./video.srt

完整mplayer安装输出:

$ brew install mplayer
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/mplayer-1.3.0.high_sierra.bottle.tar.gz
Already downloaded: /Users/adietz/Library/Caches/Homebrew/downloads/2c54638881d1afb804282a3afa22709af0d3dec157559541892847a555610955--mplayer-1.3.0.high_sierra.bottle.tar.gz
==> Pouring mplayer-1.3.0.high_sierra.bottle.tar.gz

答案1

你可能mplayer没有freetypefontconfig

Configuration: --cc=clang --host-cc=clang --disable-cdparanoia --prefix=/usr/local/Cellar/mplayer/1.3.0 --disable-x11
Configuration: --enable-gpl --enable-postproc

可能的解决方案:

  • 安装位图字体mplayer 网站并将其解压缩到~/.mplayer(有关详细信息,请参阅mplayer 文档

  • 您说您安装mplayerbrewmplayer再次安装freetypefontconfig支持。

    卸载mplayer并:

    brew install freetype
    brew install fontconfig
    brew install --build-from-source mplayer
    

    理论上mplayer可以检测fontconfigfreetype启用它。

编辑:

要列出所有可能的标志,请使用:

brew info mplayer

答案2

部分答案:

mplayer我尝试使用test5.mkv带有字幕的文件进行自制安装matroska 测试套件(以使结果可重复)。

就像在您的日志中一样,我收到了错误消息Cannot load bitmap font 'Arial',而其他日志消息表明字幕轨道本身已被正确识别。

所以问题似乎出在加载字体上。我尝试了一些变体-font(包括路径和字体配置模式),有和没有-fontconfig。我还安装了原始位图字体由 mplayer 提供。我也尝试创建subfont.ttf符号链接。它总是抱怨无法加载位图字体,无论它真的是原始位图字体还是 TrueType 字体。

我还发现,虽然 Homebrew 被列为fontconfig依赖项,但它mplayer在启动时会抱怨-v -v它不是在启用 fontconfig 的情况下构建的。

所以,所有这一切似乎表明,自制软件由于某种原因被破坏了。

对于我来说,下一步(如果我需要 mplayer)将是从源代码编译 mplayer,并找出 homebrew 装瓶时是否存在配置错误,但我不确定你是否愿意(或可以)走这么远,如果我应该成功的话。

另一种选择是向管理自制啤酒配方的人投诉,并让他们调查此事。

相关内容