mpv – matoken's blog https://matoken.org/blog Is there no plan B? Thu, 19 Feb 2026 22:17:01 +0000 ja hourly 1 https://wordpress.org/?v=6.9.4 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg mpv – matoken's blog https://matoken.org/blog 32 32 yt-dlpでYouTubeの字幕ファイルのダウンロードに失敗(HTTP Error 429: Too Many Requests) https://matoken.org/blog/2026/02/20/yt-dlp_subtitle_429error/ https://matoken.org/blog/2026/02/20/yt-dlp_subtitle_429error/#respond Thu, 19 Feb 2026 22:17:00 +0000 https://matoken.org/blog/?p=5258

Tokyo Linux Users Group のTechnical Meeting のビデオがYouTube にアップロードされていると先日の #kagolug で教えてもらったので観てみようと思いました.
でもTLUG は英語です.以前はWisper.cpp で文字起こし & 機械翻訳で字幕を作っていましたが最近のYouTube の文字起こしは大分良くなっているのでそれを使おうとローカルにビデオと字幕をdl しようとしたところ字幕のダウンロードに失敗しました.

適当な解像度のビデオとオーディオ,それと英語の文字起こし字幕と,それを日本語に翻訳したものをダウンロードしようとしました.

$ yt-dlp -f 244+251 yYgF87nqyKI --write-auto-subs --sub-langs ja,en_orig
[youtube] Extracting URL: yYgF87nqyKI
[youtube] yYgF87nqyKI: Downloading webpage
[youtube] yYgF87nqyKI: Downloading android vr player API JSON
[youtube] yYgF87nqyKI: Downloading web safari player API JSON
[youtube] yYgF87nqyKI: Downloading player 4c5cf06a-tv
[youtube] [jsc:deno] Solving JS challenges using deno
[youtube] yYgF87nqyKI: Downloading m3u8 information
[info] yYgF87nqyKI: Downloading subtitles: ja
[info] yYgF87nqyKI: Downloading 1 format(s): 244+251
[info] Writing video subtitles to: CDImage - Cam [yYgF87nqyKI].ja.vtt
WARNING: The extractor specified to use impersonation for this download, but no impersonate target is available. If you encounter errors, then see  https://github.com/yt-dlp/yt-dlp#impersonation  for information on installing the required dependencies
ERROR: Unable to download video subtitles for 'ja': HTTP Error 429: Too Many Requests

*Too Many Requests* とか言われてしまいました.今日初めて実行したのになんで?

--verbose オプションを付けてみましたがよくわかりません

[info] Writing video subtitles to: CDImage - Cam [yYgF87nqyKI].ja.vtt
[debug] Invoking http downloader on "https://www.youtube.com/api/timedtext?v=yYgF87nqyKI&ei=M4WXaZnECfax2roP_YqAqAc&caps=asr&opi=112496729&xoaf=5&xowf=1&xospf=1&hl=en&ip=0.0.0.0&ipbits=0&expire=1771562915&sparams=ip%2Cipbits%2Cexpire%2Cv%2Cei%2Ccaps%2Copi%2Cxoaf&signature=1B0AC6AA8FB20AFE9B45B2F66DBB1000F04DE626.909918AF43ACD2AFD3E0C2C61E53A3C72E49AB6C&key=yt8&kind=asr&lang=en&fmt=vtt&tlang=ja"
WARNING: The extractor specified to use impersonation for this download, but no impersonate target is available. If you encounter errors, then see  https://github.com/yt-dlp/yt-dlp#impersonation  for information on installing the required dependencies
ERROR: Unable to download video subtitles for 'ja': HTTP Error 429: Too Many Requests
Traceback (most recent call last):
  File "/home/matoken/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 4449, in _write_subtitles
    self.dl(sub_filename, sub_copy, subtitle=True)
    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matoken/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 3285, in dl
    return fd.download(name, new_info, subtitle)
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matoken/bin/yt-dlp/yt_dlp/downloader/common.py", line 480, in download
    ret = self.real_download(filename, info_dict)
  File "/home/matoken/bin/yt-dlp/yt_dlp/downloader/http.py", line 362, in real_download
    establish_connection()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/home/matoken/bin/yt-dlp/yt_dlp/downloader/http.py", line 119, in establish_connection
    ctx.data = self.ydl.urlopen(request)
               ~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/matoken/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 4260, in urlopen
    return self._request_director.send(req)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/home/matoken/bin/yt-dlp/yt_dlp/networking/common.py", line 117, in send
    response = handler.send(request)
  File "/home/matoken/bin/yt-dlp/yt_dlp/networking/_helper.py", line 194, in wrapper
    return func(self, *args, **kwargs)
  File "/home/matoken/bin/yt-dlp/yt_dlp/networking/common.py", line 359, in send
    return self._send(request)
           ~~~~~~~~~~^^^^^^^^^
  File "/home/matoken/bin/yt-dlp/yt_dlp/networking/_requests.py", line 361, in _send
    raise HTTPError(res, redirect_loop=max_redirects_exceeded)
yt_dlp.networking.exceptions.HTTPError: HTTP Error 429: Too Many Requests

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/matoken/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 1698, in wrapper
    return func(self, *args, **kwargs)
  File "/home/matoken/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 1854, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matoken/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 1913, in process_ie_result
    ie_result = self.process_video_result(ie_result, download=download)
  File "/home/matoken/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 3096, in process_video_result
    self.process_info(new_info)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/home/matoken/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 189, in wrapper
    return func(self, *args, **kwargs)
  File "/home/matoken/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 3353, in process_info
    sub_files = self._write_subtitles(info_dict, temp_filename)
  File "/home/matoken/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 4457, in _write_subtitles
    raise DownloadError(msg)
yt_dlp.utils.DownloadError: Unable to download video subtitles for 'ja': HTTP Error 429: Too Many Requests

ISSUES を探すと既知の問題のようでワークアラウンドがありました.

FreeTube is adding a PO token to their subtitles requests. But FreeTube doesn’t use auto-translated subs AFAICT.
# Manual subtitles and original language automatic captions are not affected by this HTTP Error 429 issue.

Only subtitles/captions that have been automatically translated into another language are affected. So you may be able to get the subs you want without a problem if you are precise with your --sub-langs and --write-subs vs --write-auto-subs arguments.

But if you want translated auto subs,
# there are 2 known ways of avoiding this HTTP Error 429:

  • Pass fresh cookies to yt-dlp from a browser session where you’ve very recently loaded auto-translated subs

  • Wait ~60 seconds after extraction and before downloading the auto subs, e.g. --sleep-subtitles 60

(Either of these 2 methods will work individually, you do not need to combine them)

ということでとりあえず --sleep-subtitles 60 を付けて実行することで字幕ダウンロード時にsleep して怒られずに字幕をダウンロードすることができました.

$ yt-dlp -f 244+251 yYgF87nqyKI --write-auto-subs --sub-langs ja,en_orig --sleep-subtitles 60

そしてmpv 等でこんな感じで字幕を2つ表示しながら視聴可能に :)

$ mpv --sub-files='CDImage - Cam [yYgF87nqyKI].en.vtt:CDImage - Cam [yYgF87nqyKI].ja.vtt' --secondary-sid=2 'CDImage - Cam [yYgF87nqyKI].webm'

mpv 2subs

環境
$ yt-dlp --version
2026.02.04
$ deno --version
deno 2.6.8 (stable, release, x86_64-unknown-linux-gnu)
v8 14.5.201.2-rusty
typescript 5.9.2
$ lsb_release -dr
Description:    Debian GNU/Linux forky/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2026/02/20/yt-dlp_subtitle_429error/feed/ 0
i3 wm環境でmpvを任意の場所に https://matoken.org/blog/2024/11/28/i3-mpv-anywhere-in-wm-environment/ https://matoken.org/blog/2024/11/28/i3-mpv-anywhere-in-wm-environment/#respond Wed, 27 Nov 2024 21:04:56 +0000 https://matoken.org/blog/?p=4259

最近PC作業中に動画をウィンドウ表示,最前面に表示しています.
i3 wm環境でファイラーからmpvで動画を再生,フローティングウィンドウ表示に切り替え,サイズ調整,位置調整,全てのワークスペースで表示としていますが毎回これをやるのが面倒なので設定しました.

実際の操作は以下のような感じ.たくさんの動画を一度に開けばまだいいですが,1つの動画を何度も再生するには面倒です.

  • Mod4+shift+spaceでフローティングウィンドウに切り替え

  • Mod4+rでリサイズモードに, jkl;でサイズ調整,escでリサイズモード解除

  • Mod4+shift+j k l ;で位置調整

  • Mod4+shift+wで全てのワークスペースで表示

Note

全てのワークスペースに表示はこの設定を使っています.

i3 wmでの設定

まずi3 wmの設定でmpvをフローティングウィンドウで起動,スティッキーを有効にして全ワークスペースで表示されるようにします.

$ grep mpv ~/.config/i3/config
for_window [class="mpv"] floating enable
for_window [class="mpv"] sticky enable

Mod4+shift+rで設定反映して,mpvを起動して動作確認します.

mpvの設定

次にmpvの設定ファイルでウィンドウサイズや位置を設定します.
mpvの設定ファイルはパッケージに含まれているものをベースにしました.すでにある場合はそれを利用しましょう.

$ ls ~/.config/mpv/mpv.conf
ls: cannot access '/home/matoken/.config/mpv/mpv.conf': No such file or directory
$ mkdir ~/config/mpv
$ zcat /usr/share/doc/mpv/mpv.conf.gz > ~/.config/mpv/mpv.conf

次に好みのテキストエディタで~/.config/mpv/mpv.confを開いて編集します.
#geometry=50%:50% の行をコメントを消し以下のように設定しました.

geometry=45%-50-80

geometryのオプション形式は以下のようになっています.

[W[%][xH[%]]][{+-}X[%]{+-}Y[%]] | [X[%]:Y[%]]

ここではWを45%にして画面の45%のサイズに,-50で右下から50pix左に,-80で右下から80pix上に配置しています.

はじめWxHは動画に対する設定だと思い100%を超える設定がうまく行かないと悩んでしまいました.
こういうときコマンドラインから実行するとわかりやすいです.

$ mpv --geometry=120%
Option geometry: invalid geometry: '120%'
Valid format: [W[%][xH[%]]][{+-}X[%]{+-}Y[%]] | [X[%]:Y[%]]
Error parsing option geometry (option parameter could not be parsed)
Setting commandline option --geometry=120% failed.
Exiting... (Fatal error)

環境

$ dpkg-query -W mpv i3
i3      4.24-1
mpv     0.38.0-1+b1
$ lsb_release -dr
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2024/11/28/i3-mpv-anywhere-in-wm-environment/feed/ 0
Wayland 環境で任意のウィンドウを最前面に維持する https://matoken.org/blog/2023/02/26/keep-any-window-on-top-in-wayland-environment/ https://matoken.org/blog/2023/02/26/keep-any-window-on-top-in-wayland-environment/#respond Sun, 26 Feb 2023 13:35:26 +0000 https://matoken.org/blog/?p=3853

メディアプレイヤーのmpv で動画を最前面に表示しながら別のアプリケーションを利用したいので T を押して最前面にせってしようとしますがうまく行きません.

mpv(1)だとこんな感じで合っていそう.

Keyboard Control
       T      Toggle stay-on-top (see also --ontop).

引数の --ontop や,Linux ではおそらく関係のない --ontop-level も試してみましたが駄目です.

OPTIONS
       --ontop
              Makes the player window stay on top of other windows.

              On Windows, if combined with fullscreen mode, this causes mpv to be treated as exclusive fullscreen window that bypasses the Desktop Window Manager.

       --ontop-level=<window|system|desktop|level>
              (macOS only) Sets the level of an ontop window (default: window).

              window On top of all other windows.

              system On top of system elements like Taskbar, Menubar and Dock.

              desktop
                     On top of the Dekstop behind windows and Desktop icons.

              level  A level as integer.

Wayland のせいだろうか?と検索すると当たりのようです.

ワークアラウンドとして Alt+space で出てきたメニューから 「最前面に維持する」を選ぶことで実現できました.

wayland window stay ontop

環境
$ dpkg-query -W libwayland-server0 gnome-shell mpv
gnome-shell     43.2-2
libwayland-server0:amd64        1.21.0-1
libwayland-server0:i386 1.21.0-1
mpv     0.35.1-1
$ lsb_release -a
Distributor ID: Debian
Description:    Debian GNU/Linux bookworm/sid
Release:        n/a
Codename:       bookworm
$ arch
x86_64
]]>
https://matoken.org/blog/2023/02/26/keep-any-window-on-top-in-wayland-environment/feed/ 0