mpv

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Mpv and the translation is 69% complete.
Other languages:

mpv はフリーでオープンソースなコマンドラインメディアプレイヤーです。mplayer2 をベースとしており、さらに遡ればオリジナルの MPlayer をベースとしています。派生元との類似点は多いものの、全体としては mpv は完全に異なるプログラムとして扱われるべきです。

インストール

USE フラグ

デフォルトの USE 設定は以下のコア機能を提供します: CLI プレイヤー、Xorg サポート、音声と動画の再生、オンスクリーンディスプレイ (OSD) とオンスクリーンコントローラ (OSC)、そして Lua スクリプティングインターフェースです。

通常はハードウェア動画デコード機能も欲しいでしょう。mpv は VAAPIVDPAU ハードウェアデコード API の両方を、それぞれ vaapi および vdpau USE フラグを介してサポートしています。システムで利用できる API を手動で有効にする必要があります。mpv はまた、nvenc USE フラグを介して NVDEC ハードウェアデコード API もサポートしています (プロプライエタリな nvidia-drivers が必要です)。

機能の完全な一覧については、下の USE フラグの一覧を参照してください。

USE flags for media-video/mpv Media player for the command line

X Add support for X11
alsa Add support for media-libs/alsa-lib (Advanced Linux Sound Architecture)
aqua Include support for the Mac OS X Aqua (Carbon/Cocoa) GUI
archive Enable support for various archive formats via app-arch/libarchive
bluray Enable playback of Blu-ray filesystems
cdda Add Compact Disk Digital Audio (Standard Audio CD) support
cli Enable the command-line player
coreaudio Build the CoreAudio driver on Mac OS X systems
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
drm Enable Kernel Mode Setting / Direct Rendering Manager based video outputs
dvb Add support for DVB (Digital Video Broadcasting)
dvd Add support for DVDs
egl Enable EGL (Embedded-System Graphics Library, interfacing between windowing system and OpenGL/GLES) support
gamepad Enable gamepad input support
iconv Enable support for the iconv character set conversion library
jack Add support for the JACK Audio Connection Kit
javascript Enable javascript support
jpeg Add JPEG image support
lcms Add lcms support (color management engine)
libcaca Add support for colored ASCII-art graphics
libmpv Enable the shared library and headers (used by frontends / plugins)
lua Enable Lua scripting, OSC (On Screen Controller) GUI, and net-misc/yt-dlp support
mmal Enable Multi-Media Abstraction Layer (MMAL) decoding support: Available e.g. on the Raspberry Pi
nvenc Add support for NVIDIA Encoder/Decoder (NVENC/NVDEC) API for hardware accelerated encoding and decoding on NVIDIA cards (requires x11-drivers/nvidia-drivers)
openal Add support for the Open Audio Library
opengl Enable support for OpenGL-based video backends (Note: deprecated for X11, USE=egl provides the newer support for -gpu-api=opengl)
pipewire Enable sound support via native PipeWire backend
pulseaudio Add sound server support via media-libs/libpulse (may be PulseAudio or PipeWire)
raspberry-pi Enable support for the Raspberry Pi
rubberband Enable high quality pitch correction via media-libs/rubberband
sdl Enable media-libs/libsdl2 based video and audio outputs (Note: these outputs exist for compatibility reasons only, avoid if possible)
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
sixel Enable support for the sixel video backend using media-libs/libsixel
sndio Enable sound support via media-sound/sndio
soc Use additional media-video/ffmpeg patches for efficient playback on some SoCs (e.g. ARM, RISC-V)
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
tools Install extra tools: mpv_identify.sh, mpv_idet.sh, and umpv
uchardet Enable subtitles charset discovery via app-i18n/uchardet
vaapi Enable Video Acceleration API for hardware decoding
vdpau Enable the Video Decode and Presentation API for Unix acceleration interface
vulkan Add support for 3D graphics and computing via the Vulkan cross-platform API
wayland Enable dev-libs/wayland backend
xv Add in optional support for the Xvideo extension (an X API for video playback)
zimg Enable libzimg support (for vf_fingerprint)
zlib Add support for zlib compression

Emerge

root #emerge --ask media-video/mpv

追加のソフトウェア

YouTube や他の人気のあるストリーミングウェブサイトの URL を直接再生するには、net-misc/yt-dlp をインストールしてください:

root #emerge --ask net-misc/yt-dlp

GTK GUI フロントエンドのためには media-video/celluloid をインストールしてください:

root #emerge --ask media-video/celluloid

設定

mpv は通常は設定を必要としません。しかしながら、デフォルトの挙動の多くの側面を変更することができます。 設定のうち最重要な 2 つの部分は、プレイヤーの設定とキーバインディングです。どちらについても以下で簡単に説明します。

プレイヤー設定

プレイヤー設定は、~/.config/mpv/mpv.conf ファイルに option=value 構文を使用して置くべきです。 # の後ろにあるものはすべてコメントとみなされます。

ほとんどすべてのコマンドラインオプションは、プレイヤー設定として設定することができます。多くの場合、--option=value コマンドライン引数と等価な設定は option=value になります。値なしで動作するオプションは、yes に設定することで有効化でき、no に設定することで無効化できます。

異なる設定を簡単に使い分けるために、設定ファイルでプロファイルを定義することができます。プロファイルは [my-profile] のように、角括弧で囲まれた名前で始まります。それに続くオプションはすべて、このプロファイルの一部となります。プロファイルの定義を終了するには、別のプロファイルを開始するか、以降を通常のオプションとするためにプロファイル名 default を使用してください。

利用可能なオプションの完全な一覧は、マニュアルを参照してください。

ファイル ~/.config/mpv/mpv.confプレーヤー設定例
# シークを常に (例えば HTTP ストリームのローカルキャッシュ内でも) 許可する
force-seekable=yes
# 動画が無い場合でも常に動画ウィンドウを開く
force-window=yes
# プレイリストの終わりに到達したときに終了しない
keep-open=yes
# 終了時に現在の再生位置を常に保存する
save-position-on-quit=yes
 
# 'high-quality' プロファイルを作成する
[high-quality]
# このプロファイルの説明
profile-desc="High quality rendering"
# デフォルトの 'opengl-hq' プロファイルからすべての設定を取り込む
profile=opengl-hq
# より良いパフォーマンスのためにバンディング低減を無効化する
deband=no

キーバインディング

キーバインディングは、~/.config/mpv/input.conf ファイルに key command 構文を使用して置くべきです。 # の後ろにあるものはすべてコメントとみなされます。

利用可能なコマンドの完全な一覧は、マニュアルを参照してください。

ファイル ~/.config/mpv/input.confキーバインディング例
# Ctrl+q でプレーヤーを閉じる
Ctrl+q quit
# D で現在のファイルをプレイリストから削除する
D playlist-remove current
# R で現在のプレイリストをシャッフルする
R playlist-shuffle

mpv のコントリビュータたちの、高度な実世界での設定です: [1][2]

使い方

ユーザスクリプトとプラグイン

mpv のコア機能は、Lua または JavaScript のスクリプトか、C プラグインを使って、拡張することができます。

~/.config/mpv/scripts/ ディレクトリのすべてのスクリプトとプラグインは自動的にロードされます。あるいは --script=/path/to/your/script.file のようにして、コマンドラインから手動でスクリプトまたはプラグインをロードすることもできます。

複数の Lua スクリプトが mpv に付属しており、これらは /usr/share/mpv/lua/ ディレクトリにインストールされます。上流の wiki にもサードパーティ製スクリプトおよびプラグインの膨大なリストがあります。

トラブルシューティング

重要
mpv に関する問題がある場合は、--log-file オプションでファイルへのログ出力を有効化するか、-v オプションで詳細な端末出力を有効化してください。

FFmpeg/Libav/libass 等の更新後に映像が乱れる、またはクラッシュする

TLDR: Gentoo のバグとして報告した後、mpv を再ビルドしてください。

FFmpeg/Libav/libass はいずれも、マイナーリリース間でときどき ABI 非互換な破壊的変更を導入することで知られています。 通常これらのライブラリのスロットはマイナーリリース間で変化せず、そのため自動的な mpv の再ビルドが発生しません。 このことが、これらのライブラリの以前のバージョン向けにコンパイルされた mpv に問題を引き起こします。問題は機能の部分的な障害から、突然のクラッシュまで多岐にわたります。

こうした事例に対する上流の回答は「他のプログラムが適切な ABI 互換性を維持できないのは私たちの問題ではない。mpv を再ビルドしてください」といった感じです。まずは発生している障害をメンテナに通知するために Gentoo バグを報告し、mpv を再ビルドしてください。

"mpv was compiled against a different version of FFmpeg..." メッセージ

mpv に何の問題もなければ、このメッセージは無視してください。そうでない場合は、これらの指示に従ってください。

ハードウェア動画デコーディングの障害/高い CPU 使用率

ハードウェアデコーディングに関する問題が無いか mpv ログを確認してください。動画再生中に CPU 使用率が高くなるのは、ハードウェアデコーディングに障害がある兆候です。

まず、ハードウェアが必要な動画コーデックに対応しているか確認してください。GPU が VAAPI および VDPAU デコーディング API を利用して対応しているコーデックの一覧は、それぞれ vainfo および vdpauinfo コマンドを利用して確認できます。再生した動画ファイルで使用されているコーデックは mpv ログ内で確認できます。GPU が必要なコーデックに対応しているが、mpv がハードウェアデコーディングを行っていない場合は、--hwdec-codecs=all オプションを試してみてください。

次に、ツリーで利用可能な非 live (9999 以外) で最新のバージョンの mpv を使用していることを確認してください。 最新バージョンへの更新で問題が解決する場合は、Gentoo のバグとして報告してください。

それでも解決しない場合、いくつか試してみることがあります:

  • --hwdec=auto-copy で、コピーバックを利用したハードウェアデコーダを有効化してください。
  • VAAPI のみ: --vo=vaapi--hwdec=vaapi または --hwdec=vaapi-copy とともに利用して、vaapi の出力を使用してください。
  • VDPAU のみ: --vo=vdpau--hwdec=vdpau または --hwdec=vdpau-copy とともに利用して、vdpau の出力を使用してください。
  • VDPAU のみ: --opengl-backend=x11 で、opengl の出力のために X11/GLX バックエンドを使用してください。
  • Intel GPU のみ: x11-base/xorg-server に含まれる modesetting Xorg ドライバを使用してください。
  • --opengl-dumb-mode=yes で、opengl 出力のために dumb-mode を有効化してください。
  • --vo=xv--hwdec=auto-copy とともに利用して、xv 出力を使用してください。

Tearing

Tearing is a video playback defect when displayed objects aren't properly lined up horizontally. Please refer to the upstream FAQ.

Feature X is broken/unavailable with Libav

Quote from upstream: "Libav is basically unsupported by mpv, except it still sort of compiles and many things work" [3]. Patches are welcome for any issues regarding Libav.

更新メモ

Upstream maintains a list of user-visible changes. The most important ones are discussed below.

Volume in 0.18.1

Since version 0.18.1 the software volume control is always enabled. This means that volume controls don't change the system volume, e.g. per-application volume with PulseAudio.

If you want to restore the previous behaviour, define the following key bindings:

ファイル ~/.config/mpv/input.conf
MOUSE_BTN5 add ao-volume -2
MOUSE_BTN6 add ao-volume +2
9 add ao-volume -2
0 add ao-volume +2
/ add ao-volume -2
* add ao-volume +2
m cycle ao-mute
VOLUME_DOWN add ao-volume -2
VOLUME_UP add ao-volume +2
MUTE cycle ao-mute
メモ
This covers only default volume key bindings as of version 0.18.0.

OSC in 0.21.0

In version 0.21.0 the default OSC layout was changed to bottombar.

If you want to restore the previous layout, add the following OSC settings:

ファイル ~/.config/mpv/lua-settings/osc.conf
layout=box
seekbarstyle=slider
deadzonesize=0
minmousemove=3
メモ
This covers only the default OSC layout as of version 0.20.0.

Deprecated VO/AO sub-options in 0.21.0

In version 0.21.0 all VO/AO sub-options were deprecated and replaced by options.

If you've been using those, refer to this replacement list.

Subtitles with .txt extension in 0.24.0

Since version 0.24.0 subtitles with .txt extension are no longer recognized as subtitles and thus no longer autoloaded. Please refer to the offending commit's message and this upstream issue for more info.

If you want to restore the previous behavior, use the following Lua script: autoloadtxt.lua.

Deprecated audio/video filters in 0.25.0

In version 0.25.0 many builtin audio and video filters were deprecated.

If you've been using those, migrate to FFmpeg/Libav filters.

関連項目

外部資料