How to make mplayer use subtitles?

2

I am trying to use subtitles with a mkv file in the following way:

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

but only the video did play, but without any subtitles. I also pressed several buttons while playing the video ('j', 'u', 's') but without any change.

OS: MacOS 10.13.16 mplayer: 1.3.0-4.2.1

Maybe I am missing something? Or the mplayer must be compiled in some special, complicated manner? Or a library is missing? Or its because its a mac?

Is there a way to use the subtitles in the srt file with a mkv video with mplayer?


I have tried as suggested in the comment to set the config as shown here. But I get the following error when playing the mkv file with the srt file in the same folder:

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

The first two entries in the srt file are as follows:

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>

Current content of .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

When I just play the file as follows

mplayer -v video.mkv

the video plays fine with audio, but without subtitles. The output in the console is the following:

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

Full mplayer install output:

$ 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
  /usr/local/Cellar/mplayer/1.3.0: 11 files, 26.9MB

Alex

Posted 2018-10-06T08:33:47.563

Reputation: 337

Try to set in ~/.mplayer/config the setting that are found here.

– harrymc – 2018-10-06T18:55:40.147

Thanks for the information, but now I get an error. See the updated question... – Alex – 2018-10-07T07:04:42.497

That advice was apparently for another version of mplayer, possibly not for the Mac. I would suggest anyway to check the config file for subtitle-related entries. – harrymc – 2018-10-07T08:37:14.557

Yes, and what should I put in the config file so that it works...? – Alex – 2018-10-07T09:28:07.553

I don't know - maybe you should post it here. – harrymc – 2018-10-07T11:17:51.773

But I asked the question to get an answer. I have a problem using subtitles with mplayer. That is why I am asking a question here. I hope to get an answer on how to solve my problem. Because I do not know how to solve that problem. Therefore I asked a question. - Maybe you misunderstand what 'StackOverflow' is used for... – Alex – 2018-10-07T13:51:33.500

Maybe you misunderstood : You are supposed to work with us on your problem and to supply any additional information we require. Anyway. I'm out of here. – harrymc – 2018-10-07T14:42:58.680

So what additional information do you require...? – Alex – 2018-10-08T15:56:27.160

How did you install/compile mplayer? With brew? Some other way? – dirkt – 2018-10-10T06:05:04.197

I do not remember how I installed mplayer. Probably with 'brew'... – Alex – 2018-10-10T06:11:24.013

Could you post the contents of your ~/.mplayer/config file? – harrymc – 2018-10-10T07:36:59.153

See updated question... – Alex – 2018-10-10T10:18:14.873

Do You see a line starting with SUB:? – Tomasz Jakub Rup – 2018-10-10T12:30:29.953

No... I do not see such a line... – Alex – 2018-10-10T14:12:31.507

Please show full output – Tomasz Jakub Rup – 2018-10-11T03:58:13.903

Full output of what? The mplayer command? The config file? The subtitle file? – Alex – 2018-10-11T08:44:39.610

@Alex, full output of mplayer command – Tomasz Jakub Rup – 2018-10-13T04:19:16.463

@TomaszJakubRup: Complete output added – Alex – 2018-10-14T06:59:35.317

@Alex please run mplayer -v video.mkv and show output line starting with Configuration: and all section Clip info: – Tomasz Jakub Rup – 2018-10-14T12:58:56.793

@TomaszJakubRup: I updated the question... – Alex – 2018-10-16T06:09:55.400

Updated question... – Alex – 2018-10-16T12:53:44.023

Answers

1

You probably have mplayer without freetype and fontconfig

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

Possible solutions:

  • Install bitmap fonts from mplayer site and uncompress it to ~/.mplayer (for details see mplayer documentation

  • You say You installed mplayer with brew. Install mplayer again with freetype and fontconfig support.

    Uninstall mplayer and:

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

    In theory mplayer can detect fontconfig and freetype and enable it.

EDIT:

To list all possible flags use:

brew info mplayer

Tomasz Jakub Rup

Posted 2018-10-06T08:33:47.563

Reputation: 598

How to install mplayer with flags? I searched for it, but only found brew install mplayr. Also on the font site: Which file to download? Or all of it? – Alex – 2018-10-16T08:39:40.850

Warning: mplayer: this formula has no --with-fontconfig option so it will be ignored! – Alex – 2018-10-16T08:52:42.907

@Alex see my edit – Tomasz Jakub Rup – 2018-10-16T10:27:41.257

Thanks for the update, but for the two libraries it said they have been already installed (i.e. Warning: fontconfig 2.13.1 is already installed and up-to-date and the same for the other). Re-installing mplayer thus still did not fix the problem. Maybe its impossible to have subtitles on a mac? – Alex – 2018-10-16T12:12:09.820

@Alex Please show full brew install mplayer output – Tomasz Jakub Rup – 2018-10-16T12:18:03.710

I accepted the answer, although not resolved. Mac computers are just the worst of the worst. They are all just trash.

I run the mplayer command on Ubuntu, and it works absoutely fine. Thanks for your time and for your patience, – Alex – 2018-10-16T12:59:44.377

You accepted not my answer, but thanks. – Tomasz Jakub Rup – 2018-10-16T13:03:56.497

Here we go! Now it should be ok... – Alex – 2018-10-16T13:07:20.237

@Alex brew install mplayer install mplayer from bottle (binary version, without freetype and fontconfig). brew install --build-from-source mplayer install mplayer from source. – Tomasz Jakub Rup – 2018-10-17T07:28:42.553

0

Partial answer:

I tried a homebrew-install of mplayer with the file test5.mkv with subtitles from the matroska test suite (to make the results reproducable).

Like in your log, I get the error message Cannot load bitmap font 'Arial', while the other log messages indicate that the subtitle track itself is properly recognized.

So the problem seems to be loading the fonts. I tried a few variation with -font (both a path and a fontconfig pattern), with and without -fontconfig. I also installed the raw bitmap fonts provided by mplayer. I also tried creating the subfont.ttf symlink. It always complains the bitmap font cannot be loaded, no matter if it's really a raw bitmap font, or a truetype font.

I also discovered that while homebrew lists fontconfig as a dependency, mplayer itself complains when started with -v -v that it is not built with fontconfig enabled.

So all this seems to indicate that the homebrew built is broken for some reason.

Next step for me (if I needed mplayer) would be to compile mplayer from source and find out if there are configuration errors when homebrew bottles it, but I am not sure if you want (or can) go so far, if I should be successful.

Another option would be to complain to whoever manages the homebrew formula, and have them look into it.

dirkt

Posted 2018-10-06T08:33:47.563

Reputation: 11 627