Pre-history
I really like mplayer
because:
- it is very powerful;
- yet quite easy to use from command-line;
- has sane defaults;
- no GUI which just stands between me and video I want to watch.
So far, so good. The only thing that bothered me for a while is that subtitles are enabled by default.
I download subtitles quite often, but use them rarely, mostly when I don’t get
something. For such workflow it would be ideal to have subtitles loaded
always, but displayed only when I need them (on pressing v
key), thus
subtitles should be disabled by default.
Looking for a solution
It sounds like an easy task, doesn’t it? Well, I spend quite a lot of time to solve it. Initially I expected to find a simple command line option which does the trick. I tried these two:
-nosub
Disables any otherwise auto-selected internal subtitles (as e.g. the Matroska/mkv demuxer supports). Use -noautosub to disable the loading of external subtitle files.
-noautosub
Turns off automatic subtitle file loading.
The -noautosub
worked fine with external subtitles, but hitting v
didn’t
enable subtitles. The options don’t suppress displaying subtitles, they
disable loading of them, making loading later impossible (one would have to
restart mplayer without specifying them). Such behaviour obviously doesn’t fit
the desired workflow.
Reading man mplayer
further lead me to the -input
command. It wasn’t clear
whether it’s of any help, but the description mentioned some new commands that
are not listed in the manual. Other “strange” options are -list-options
and
-list-properties
. The first one gives a list of regular options, but output
of the second one contained something new to me, in particular (mplayer
-list-properties | grep sub
):
sub Integer -1 No sub_source Integer -1 2 sub_vob Integer -1 No sub_demux Integer -1 No sub_file Integer -1 No sub_delay Float No No sub_pos Integer 0 100 sub_alignment Integer 0 2 sub_visibility Flag 0 1 sub_forced_only Flag 0 1 sub_scale Float 0 100 teletext_subpage Integer 0 64
See it? sub_visibility
, that’s it! All that’s left is to set it, that
sounds easy again, but neither mplayer -sub_visibility=0 ...
nor mplayer
-input sub_visibility=0
works.
What about that -input
command? mplayer -input cmdlist | grep property
:
osd_show_property_te String [Integer] [Integer] set_property String String get_property String step_property String [Float] [Integer]
OK, trying mplayer -input 'set_property sub_visibility 0'
, and fail again.
Consulting man mplayer
again reveals the following: one has to put the
command to a file and pass it to mplayer -input file=<path/to/file>
.
Finally…
The solution
$ echo set_property sub_visibility 0 > ~/.mplayer/init $ cat ~/.mplayer/init set_property sub_visibility 0 $ mplayer -input file=$HOME/.mplayer/init video.mkv