---
title: メディア操作マニュアル
url: https://doc.liz6.com/ja/devops/media-ops
locale: ja
area: devops
tags:
- devops
date: 2026-06-30
modified: 2026-07-16
description: 'メディア操作マニュアル オーディオ/ビデオ関連の操作。PipeWire の管理、音量制御、デバイスルーティング、録音、およびトラブルシューティングを含みます。 アーキテクチャ概要 PipeWire アーキテクチャ: データフローはアプリからハードウェアへ、WirePlumber/pipewire-pulse は管理層 …'
---

# メディア操作マニュアル

オーディオ/ビデオ関連の操作。PipeWire の管理、音量制御、デバイスルーティング、録音、およびトラブルシューティングを含みます。

## アーキテクチャ概要

<svg viewBox="0 0 720 340" xmlns="http://www.w3.org/2000/svg" font-family="-apple-system,'Source Han Sans CN','Microsoft YaHei',sans-serif" role="img" aria-label="PipeWire 音声アーキテクチャ: アプリからハードウェアへのデータフロー、WirePlumber セッションポリシー層と pipewire-pulse 互換レイヤーの位置">
  <defs><marker id="mopah" markerWidth="10" markerHeight="8" refX="8" refY="3" orient="auto"><path d="M0,0 L8,3 L0,6 Z" fill="#475569"/></marker></defs>
  <rect width="720" height="340" fill="#ffffff"/>
  <text x="360" y="28" text-anchor="middle" font-size="17" font-weight="700" fill="#1f2933">PipeWire アーキテクチャ: データフローはアプリからハードウェアへ、WirePlumber/pipewire-pulse は管理層</text>
  <rect x="123" y="55" width="70" height="34" rx="6" fill="#e2e8f0"/>
  <text x="158" y="76" text-anchor="middle" font-size="12" font-weight="700" fill="#334155">アプリ</text>
  <line x1="193" y1="72" x2="209" y2="72" stroke="#475569" stroke-width="1.6" marker-end="url(#mopah)"/>
  <rect x="211" y="55" width="170" height="34" rx="6" fill="#4f46e5"/>
  <text x="296" y="76" text-anchor="middle" font-size="11" font-weight="700" fill="#ffffff">PipeWire (media.session)</text>
  <line x1="381" y1="72" x2="397" y2="72" stroke="#475569" stroke-width="1.6" marker-end="url(#mopah)"/>
  <rect x="399" y="55" width="110" height="34" rx="6" fill="#e2e8f0"/>
  <text x="454" y="76" text-anchor="middle" font-size="12" font-weight="700" fill="#334155">ALSA ドライバ</text>
  <line x1="509" y1="72" x2="525" y2="72" stroke="#475569" stroke-width="1.6" marker-end="url(#mopah)"/>
  <rect x="527" y="55" width="70" height="34" rx="6" fill="#e2e8f0"/>
  <text x="562" y="76" text-anchor="middle" font-size="12" font-weight="700" fill="#334155">ハードウェア</text>
  <line x1="296" y1="89" x2="296" y2="121" stroke="#475569" stroke-width="1.6" marker-end="url(#mopah)"/>
  <rect x="96" y="123" width="400" height="48" rx="8" fill="#f0fdfa" stroke="#99f6e4"/>
  <text x="296" y="143" text-anchor="middle" font-size="13" font-weight="700" fill="#115e59">WirePlumber</text>
  <text x="296" y="161" text-anchor="middle" font-size="11" fill="#0f766e">セッションポリシーマネージャー、pipewire-media-session の後継</text>
  <line x1="296" y1="171" x2="296" y2="203" stroke="#475569" stroke-width="1.6" marker-end="url(#mopah)"/>
  <rect x="96" y="205" width="400" height="48" rx="8" fill="#ffedd5"/>
  <text x="296" y="225" text-anchor="middle" font-size="13" font-weight="700" fill="#9a3412">pipewire-pulse</text>
  <text x="296" y="243" text-anchor="middle" font-size="11" fill="#c2410c">PulseAudio 互換層、従来のアプリ用</text>
  <rect x="40" y="273" width="640" height="48" rx="8" fill="#eef2ff" stroke="#c7d2fe"/>
  <text x="360" y="293" text-anchor="middle" font-size="12.5" fill="#3730a3">オーディオ/ビデオデータは上段(アプリ→PipeWire→ALSA→ハードウェア)を流れます。WirePlumber がルーティングポリシーを管理し、pipewire-pulse が互換層となります。</text>
  <text x="360" y="311" text-anchor="middle" font-size="12.5" fill="#3730a3">pactl は pipewire-pulse を操作し、wpctl は PipeWire 原生層を操作します。トラブルシューティングの際は、どちらの層を通過しているかをまず明確にしてください。</text>
</svg>

重要概念:
- **PipeWire** = 統一されたオーディオ/ビデオサービス。PulseAudio と JACK を同時に置き換えます。
- **WirePlumber** = デバイスのホットプラグ/自動ルーティングポリシー (イヤホンが挿された場合や HDMI 出力への切り替えなど)
- **pipewire-pulse** = PulseAudio 互換層。PA アプリが PipeWire を透過的に使用できるようにします。
- **pactl** は pipewire-pulse を操作し、**wpctl** は PipeWire 原生層を操作します。

## ステータス確認

```bash
# サービス状態
systemctl --user status pipewire wireplumber pipewire-pulse

# PipeWire 原生情報
pw-cli info                          # PipeWire サービス概要
pw-dump                              # 完全ダンプ (ノード/ポート/リンク)
pw-top                               # リアルタイムパフォーマンスモニタリング (htop に類似)
pw-cli list-objects                  # すべてのオブジェクトをリスト

# WirePlumber デバイス
wpctl status                         # デバイスの概要 (sink/source/デフォルトデバイス)
wpctl inspect <id>                   # 特定のデバイス/ノードの詳細表示

# PulseAudio 互換層
pactl info                           # PulseAudio サービス情報
pactl list sinks                     # すべてのオーディオ出力をリスト
pactl list sources                   # すべてのオーディオ入力 (モニター含む) をリスト
pactl list cards                     # サウンドカード情報 (プロファイル/ポート)
pactl list sink-inputs               # 再生中のオーディオストリーム
pactl list modules                   # ロードされているモジュール

# ハードウェア
aplay -l                             # ALSA 再生デバイスリスト
arecord -l                           # ALSA 録音デバイスリスト
lspci | grep -i audio                # PCI オーディオデバイス
cat /proc/asound/cards               # カーネル視点のサウンドカード
```

## 音量制御

```bash
# wpctl (推奨、PipeWire 原生)
wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+      # デフォルト出力を +5%
wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-      # デフォルト出力を -5%
wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.5      # 50% に設定
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle     # ミュート切り替え
wpctl set-volume <sink-id> 0.75                # 指定された sink を 75% に設定

# pactl (PulseAudio 互換層)
pactl set-sink-volume @DEFAULT_SINK@ +5%
pactl set-sink-volume @DEFAULT_SINK@ 50%
pactl set-sink-mute @DEFAULT_SINK@ toggle

# amixer (ALSA 低レベル、ハードウェア直接制御)
amixer scontrols                      # シンプルミキサーコントロールをリスト
amixer sget Master                    # Master 音量を確認
amixer sset Master 80%                # Master を 80% に設定
amixer sset Master 5%+                # Master を +5%
amixer sset Master toggle             # ミュート切り替え
amixer sset Headphone 70%
```

## オーディオルーティング (出力デバイスの切替)

```bash
# 利用可能な sink をリストして切替
wpctl status                          # 対象 sink の ID を確認
wpctl set-default <sink-id>           # デフォルト出力に設定
wpctl inspect <sink-id>               # 切替が有効になったことを確認

# 現在の再生ストリームを指定された sink に移行
pactl list sink-inputs                # sink-input ID を確認
pactl move-sink-input <input-id> <sink-id>

# 特定のデバイスに切替 (名前で指定)
SINK=$(pactl list sinks short | grep -i "hdmi\|analog\|usb" | head -1 | awk '{print $1}')
pactl set-default-sink "$SINK"

# サウンドカードのプロファイルを確認 (アナログ/デジタル/HDMI 切替)
pactl list cards
pactl set-card-profile <card-name> output:analog-stereo
pactl set-card-profile <card-name> output:hdmi-stereo
pactl set-card-profile <card-name> output:iec958-stereo  # SPDIF
```

## WirePlumber / PipeWire の再起動

```bash
# 音声スタック全体の再起動 (ソフトリブート、アプリ側は気づかない)
systemctl --user restart pipewire pipewire-pulse wireplumber

# WirePlumber のみ再起動 (デバイスリストの更新)
systemctl --user restart wireplumber

# 完全リセット (一旦停止させてから再起動)
systemctl --user stop pipewire pipewire-pulse wireplumber
sleep 1
systemctl --user start pipewire wireplumber pipewire-pulse
```

## トラブルシューティング

```bash
# 1. 音声出力があるか確認
paplay /usr/share/sounds/alsa/Front_Center.wav    # テスト音
speaker-test -t sine -f 440 -l 1                   # 440Hz 正弦波 (PA/PW をバイパス)

# 2. pipewire-pulse がハングしていないか確認 (よくあるケース: Chrome の動画が固まる)
pactl info 2>&1                                    # エラーやタイムアウトがないか確認
paplay /usr/share/sounds/alsa/Front_Center.wav     # 終了コードが 124 の場合、pipewire-pulse がハングしている
# 修正: systemctl --user restart pipewire-pulse

# 3. プロセスがサウンドカードを独占していないか確認
fuser /dev/snd/*                                   # どのプロセスがオーディオデバイスを占有しているか
lsof /dev/snd/*                                    # より詳細な情報

# 4. ALSA 層が正常か確認
aplay -D hw:0,0 /usr/share/sounds/alsa/Front_Center.wav  # PipeWire をバイパスして直接再生
speaker-test -D hw:0,0 -t sine -f 440 -l 1
# ALSA 直接再生は正常だが PipeWire では音が出ない場合 → PipeWire 層の問題
# ALSA でもエラーが出る場合 → ドライバ/ハードウェアの問題

# 5. USB/HDMI のホットプラグで反応がない場合
wpctl status                          # デバイスが出現しているか確認
systemctl --user restart wireplumber  # デバイスリストの強制更新
journalctl --user -u wireplumber -f   # WirePlumber のログ確認

# 6. Bluetooth オーディオ
bluetoothctl connect XX:XX:XX:XX:XX:XX
# 接続後、wireplumber が BT sink を自動作成し、wpctl status で確認可能
# 表示されない場合: systemctl --user restart wireplumber

# 7. 同時複数出力 (必要な場合)
pactl load-module module-combine-sink   # 結合 sink を作成し、すべてのデバイスに同時に出力
# アンロード: pactl unload-module module-combine-sink
```

### よくある症状のクイックリファレンス

| 症状 | 考えられる原因 | コマンド |
|------|---------|------|
| Chrome の動画のプログレスバーが進まない、バッファリング中 | pipewire-pulse のハング | `systemctl --user restart pipewire-pulse` |
| 完全に音が出ない | デフォルト sink が間違っている | `wpctl status` で default sink を確認 |
| イヤホンを挿しても自動切替されない | WirePlumber が反応していない | `systemctl --user restart wireplumber` |
| 一部のアプリからは音が出るが、一部は出ない | 異なる sink を経由している | `pactl list sink-inputs` でルーティングを確認 |
| Bluetooth ヘッドセットは接続されたが音が出ない | BT プロファイルが落ちている | `pactl list cards` でプロファイルを確認 |

## 録音

```bash
# スクリーン録画 (PipeWire + wf-recorder、Wayland 原生)
wf-recorder -f output.mp4                    # フルスクリーン録画
wf-recorder -g "$(slurp)" -f output.mp4      # 領域選択録画
wf-recorder --audio -f output.mp4            # オーディオ付き (pipewire が必要)
wf-recorder --audio=HDMI -f output.mp4       # 特定のオーディオソースを指定

# オーディオ録音 (PipeWire)
pw-record output.wav                          # デフォルト入力デバイスで録音
pw-record --target=<node-id> output.wav       # 入力ソースを指定

# PulseAudio 互換
parecord output.wav                           # デフォルトマイクで録音
parecord --device=<source> output.wav         # 入力ソースを指定
parec --device=<sink>.monitor output.wav      # システム出力を録音 (内部録音)

# スクリーンショット (Wayland/Hyprland)
grim screenshot.png                           # フルスクリーン
grim -g "$(slurp)" screenshot.png             # 領域選択
grim - | wl-copy                              # クリップボードにコピー
```

## 音量/メディアキー

Hyprland のメディアキーバインド例 (`hyprland.lua`):

```lua
-- 音量制御 (wpctl)
hl.dsp.bind({"SUPER"}, "XF86AudioRaiseVolume",  function() hl.exec("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+") end)
hl.dsp.bind({"SUPER"}, "XF86AudioLowerVolume",  function() hl.exec("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-") end)
hl.dsp.bind({"SUPER"}, "XF86AudioMute",         function() hl.exec("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle") end)
hl.dsp.bind({"SUPER"}, "XF86AudioMicMute",      function() hl.exec("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle") end)

-- 再生制御 (playerctl、インストールが必要)
hl.dsp.bind({}, "XF86AudioPlay",  function() hl.exec("playerctl play-pause") end)
hl.dsp.bind({}, "XF86AudioNext",  function() hl.exec("playerctl next") end)
hl.dsp.bind({}, "XF86AudioPrev",  function() hl.exec("playerctl previous") end)
```

`playerctl` のその他の使用方法:
```bash
playerctl play-pause                  # 現在のプレイヤーを制御
playerctl -p spotify next             # 特定のプレイヤーを指定
playerctl -a play-pause               # すべてのプレイヤーを制御
playerctl -l                          # 制御可能なプレイヤーをリスト
playerctl metadata                    # 現在の曲情報
playerctl metadata --format '{{artist}} - {{title}}'
```

## ビデオ/コーデック情報

```bash
ffprobe video.mp4                     # 動画の完全な情報
ffprobe -v quiet -show_streams video.mp4 | grep codec  # コーデックのみ表示
ffprobe -v quiet -show_entries stream=codec_name,width,height video.mp4

# ハードウェアエンコード/デコードのサポートを確認
vainfo                                # VA-API (Intel/AMD)
vulkaninfo | grep -i video            # Vulkan Video 拡張機能
ffmpeg -encoders | grep vaapi         # 利用可能な VA-API エンコーダ
```

## ファームウェア

```bash
# AMD GPU ファームウェア (エンコード/デコード/表示)
ls /lib/firmware/amdgpu/              # gc_*, psp_*, sdma_*, vcn_* など
dmesg | grep -i "firmware\|amdgpu"    # ファームウェアロードログ

# SOF (Sound Open Firmware、Intel 音声 DSP)
dmesg | grep -i sof
ls /lib/firmware/intel/sof/
```
