Linux mplayer uses configuration files and loads subtitles

Source: Internet
Author: User

Linux mplayer is a common system, so I learned to study Linux mplayer. Here I will introduce the application of Linux mplayer in detail and hope it will be useful to you.

First add the source Livna source Repository: # yum install livna 

If the above command fails to be executed, use this sentence: # rpm-ivh http://rpm.livna.org/livna-release.rpm to add the Fusion source repository next: # rpm-Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rp m # rpm-Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm is the final scene: # yum install mplayer-gui # yum install xine # yum install vlc to tell the truth, each installation of this is a headache, now I finally found a simple and feasible solution!

Problems encountered

1, cannot prepare subtitle font.
Vim/etc/mplayer. conf
# Use fontconfig for font selection
Fontconfig = yes
Change
# Use fontconfig for font selection
Fontconfig = no

2. Create a font Link
Ln-s/usr/share/fonts/zh_CN/TrueType/MSYH. TTF ~ /. Mplayer/subfont. ttf
Among them, the green bottom is the font you selected.

3, new-face failed. Maybe the font path is wrong.
# Cp/usr/share/fonts/zh_CN/TrueType/zysong. ttf/home/xu your username)/. mplayer/subfont. ttf

4. No Image
(1) set mplayer-preferences-video to x11.
(2) download the following four files from http://www.mplayerhq.hu/MPlayer/releases/codecs/
All-20071007.tar.bz2
Essential-amd64-20071007.tar.bz2
Windows-all-20071007.zip
Windows-essential-20071007.zip
Decompress the above four files to the/usr/lib/codecs/directory. Note that the extracted files are placed in the preceding directory, not a folder.

Linux has been installed for a while, but it is really troublesome to watch a movie on windows. Because Linux mplayer in the system can neither zoom in or zoom in the screen, nor drop subtitles to blame me ). A few days ago, I was tired of switching the system, so I was determined to deal with Linux mplayer and no longer had to go to a movie in windows. I have been working on Linux mplayer for the past few days. System Environment: Ubuntu 7.04 Linux kernel 2.6.20-16-genric & Slackware 12.0 Linux kernel 2.6.21.5-smp

I. Installation

I am using source code compilation and installation. I personally think that I can have a better understanding of the installation of Linux mplayer. Installation requires a total of two files, can be downloaded to the Linux mplayer official website, here are two addresses: MPlayer v1.0rc1 source // MPlayer source code http://www1.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc1.tar.bz2 Linux x86 20061022 // MPlayer various decoder, so many files can be played by the http://www1.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2 to download the above files to one of your projects such as/home/YOURNAME/Desktop/MPlayer to decompress them, in the Linux mplayer folder, the essential-20061022 and MPlayer-1.0rc1 subfolders are generated.
Before installation, check whether you meet the dependencies of the following software packages.
Sudo apt-get install build-essential
Sudo apt-get install libpng-dev
Sudo apt-get install libgtk1.2-dev
# If you find that some software package dependencies are missing during the compilation process below,
Go to the official website to check what you have and install it on your own.

Open your terminal and switch to/home/YOURNAME/Desktop/MPlayer.
I installed mplayer in/opt/mplayer because/opt is a separate partition on my machine. If I reinstall the system next time, I can not Format this partition, the new system can still use the file program here. If you don't think it is necessary, skip this step. The default installation path for mplayer is/usr/local. Enter the following command:
Sudo mkdir/opt/mplayer
Sudo mkdir/opt/mplayer/codecs
# Here is a comment. If you select the default installation path, it is
# Sudo mkdir/usr/local/lib/codecs

Then, the decoded file is taken into a directory:
Sudo cp essential-20061022/*/opt/mplayer/codecs/
# Here is the comment, if you choose the default installation path, then it is # sudo cp essential-20061022/*/usr/local/lib/codecs/then cd MPlayer-1.0rc1
./Configure-prefix =/opt/mplayer/-enable-largefiles-enable-menu-enable-freetype-with-codecsdir =/opt/mplayer/codecs/
# Here is a comment. If you select the default path
#./Configure-prefix =/usr/local/mplayer/-enable-largefiles-enable-menu-enable-freetype-with-codecs =/usr/local/lib/codecs/

The meanings of parameters are described as follows:
-Prefix =/opt/mplayer/Linux mplayer installation path
-Enable-largefiles Supports files larger than 2 GB.
-Enable-menu: supports OSD menus.
-Enable-freetype supports ttf fonts.
-With-codecsdir =/opt/mplayer/codecs decoder installation path

If the default installation path is not selected, run the following command; otherwise, Skip:
Sudo ln-s/opt/mplayer/bin/mplayer/usr/local/bin/mplayer
Sudo ln-s/opt/mplayer/bin/mencoder/usr/local/bin/mencoder
# You can enter mplayer in the terminal to open mplayer directly.
Sudo ln-s/opt/mplayer/man/man1/mplayer.1/usr/local/man/man1/mplayer.1
Sudo ln-s/opt/mplayer/man/man1/mencoder.1/usr/local/man/man1/mencoder.1
# Mplayer man document

If you re-run the above command after reinstalling the system, you still need to enter it again :) Because/usr/local/bin is an environment variable, When you directly enter Linux mplayer in the terminal, the system will go to these directories to find the Linux mplayer command.

Here, I did not add the-enable-gui parameter during compilation, that is, it has the function of the graphic front-end. You can also add it, but you can search for the installation of skin. I personally think that the command line + config configuration file is sufficient.

Ii. Subtitle Loading

After Linux mplayer is installed and the movie is downloaded, you have to do two things before watching the movie.

1. Subtitle
Generally, subtitles are downloaded from a movie. If you do not download Subtitles from the shooter network. The most common subtitle formats are idx + sub and srt. Subtitle formats include graphic and text formats. The graphic subtitles are composed of IDX and SUB files. IDX is an index file, including the subtitle display time and attributes. The SUB file is a subtitle file. Text Format subtitle extensions include SRT, SMI, SSA, and SUB. SRT Subtitles are the most popular.

For idx + sub subtitles, keep the following file order in the same directory:
Movfile-CD1.avi
Movfile-CD1.idx
Movfile-CD1.sub
Movfile-CD2.avi
Movfile-CD2.idx
Movfile-CD2.sub

If it is srt, it is:
Movfile-CD1.avi
Movfile-CD1.chs.srt # Simplified Chinese
Movfile-CD1.cht.srt # traditional Chinese
Movfile-CD1.Eng.srt # English

PS: Because idx + sub is a subtitle in the graphic format, you cannot specify a third-party font or adjust the font size, however, the integration of Chinese and English language also removes many issues such as coding and garbled characters due to srt Subtitles.

2. Font
Find a ttf font in your system. There are many fonts in the system. I chose/usr/share/fonts/truetype/arphic/ukai. ttf. If you like simhei. ttf in windows, you can also use simhei. ttf.

Idx + sub subtitles are very simple, as long as you keep what I said above, cut to the directory where the file is located in the terminal, then: mplayer movfile-CD1.avi so that Linux mplayer will automatically load subtitles, you can use the j key to switch between Chinese and English subtitles.

Srt Subtitles should be like this: mplayer movfile-CD1.avi-sub movfile-CD1.chs.srt-font/usr/share/fonts/truetype/arphic/ukai. ttf-subcp cp936: mplayer + movie file name +-sub + subtitle file +-font + font file +-subcp + font encoding. Currently, only Simplified Chinese fonts can be played.

3. Detailed introduction of fonts and srt Subtitles

The above-subcp cp936 parameter is related to srt subtitle encoding, you can use the enca movfile-CD1.chs.srt to view the subtitle encoding, the general correspondence is as follows:
Subtitle encoding __________________-subcp parameter ______ gb __________________ gb _ gb2312 __________________ gb2312 _____ big5 __________________ big5 _____ utf8 ______________ utf8

In general, the Chinese Simplified chs Subtitles can be displayed in the traditional Chinese format with cp936). If garbled characters exist, add parameters according to the results of enca. All English Subtitles can be used. Chs uses cp936 for laziness. We will talk about it later: so. If you want to watch subtitles in any language, you only need to change-sub to the corresponding subtitle file and-subcp to the correct encoding.

The font parameter is followed by the path of the ttf font file. Do not bother with each input? The following two methods are provided:
1. Enter ln-s/usr/share/fonts/truetype/arphic/ukai. ttf ~ in the terminal ~ /. Mplayer/subfont. ttf
If you have a separate ttf font file, rename it as subfont. ttf and place it in ~ /. Mplayer.

2. Open/home/YOURNAME/. mplayer/config and add a line of content:
Font =/usr/share/fonts/truetype/arphic/ukai. ttf

In fact, Linux mplayer also supports another font-bitmap font. Why do I mention it now, because I want to be less competitive with ttf fonts. To broaden your horizons, I would like to mention how to use this font. By the way, it's still srt Subtitles.

1. Download the bitmap font;
You need to download the Simplified Chinese text. Download the corresponding file according to the encoding format of your subtitle file. The simplified Chinese text can be gb2312, And the gbk font, that is, the file name contains gb2312 or gbk );
In traditional Chinese, you need to find the big5 font;
It's okay to use the above font for English subtitles. If you like different font styles, you can download them here.

2. Load the font;
For example, I downloaded the gb2312-kai font, then you will find that there are two folders, gkai00mp16 and gkai00mp24, the number represents one of the disadvantages of the font size: to change the font, You need to download different font files ). Each folder must contain a font. desc and several other files. Switch to the directory where the movie file is located in the terminal, and then:
Linux mplayer movfile-CD1.avi-sub movfile.-CD1.chs. srt-font/home/YOURNAME/Desktop/gkai00mp16/font. desc-unicode
If you use cht for subtitle files at this time, it will be garbled ............ English subtitles can also be loaded.

However, bitmap fonts have many disadvantages, but Linux mplayer supports them very well. I had trouble with ttf fonts. bitmap can load subtitles as long as all of the above conditions are met.

4. Use the configuration file

Now, srt Subtitles cannot switch between Chinese and English subtitles as idx + sub subtitles. The following describes the configuration file of Linux mplayer to implement some useful functions. This file is/home/YOURNAME/. mplayer/config
Paste my own:

Zoom = yes # video screen Scaling
On top = yes # top display
Sub-fuzziness = 1 # automatically load all subtitles with movie file names in the same directory
Sub-autoscale = 2 # subtitle position
Subfont-text-scale = 2.5 # subtitle font size
Subcp = utf8 #

Sub-fuzziness is the key to switching between different subtitles.
-Sub-fuzziness
Adjust matching fuzziness when searching for subtitles:
0 exact match
1 load all subs containing movie name
2 load all subs in the current directory
This is evident. Subfont-text-scale you can try it with different parameters until you feel the font size and your taste. By the way, this parameter is only valid for ttf fonts. It cannot change the size of subtitles embedded in idx + sub and rmvb. As for subcp, I used utf8 in my configuration file because I passed:
Enconv movfile-CD1.chs.srt movfile-CD1.cht.srt movfile-CD1.Eng.srt-x utf8
No matter what the original subtitle encoding is, it is converted into utf8 format. In this way, with the sub-fuzziness parameter above, you can switch between Simplified Chinese, traditional Chinese, and English subtitles when playing a movie. :) well, through this configuration file and ~ /. Subfont under mplayer. ttf, the original Linux mplayer movfile-CD1.avi-sub movfile-CD1.chs.srt-font/usr/share/fonts/truetype/arphic/ukai. ttf-subcp cp936 long command, now only:
Movfile-CD1.avi mplayer
That's all.

  1. Install the Linux PPStream System in Fedora to compile and install the package Library
  2. Introduction and application of common Linux software
  3. Linux chromium cannot be used through yum Installation
  4. Describes how to install PPStream in Linux.
  5. Run the Linux kernel and start Fedora.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.