0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windows にてログインユーザとして yt-dlp を使うメモ

Last updated at Posted at 2025-02-19

最近になって以下のエラーになるときは

login しないとダウンロードできないようになった

ERROR: [youtube] Sign in to confirm you’re not a bot. This helps protect our community. Learn more

事前準備

専用の Google Account を新規に作る

常用のアカウントでこれをやるのは危険です。

yt-dlp をgithub からダウンロード

pip コマンドでインストールできるバージョンは、大昔のものです。

Get cookies.txt LOCALLY 拡張を入れる

Opera browserを使うのがおすすめ。

ダウンロードする

cookies.txt を取得する

専用の Google Account でYoutubeにログイン。そしてGet cookies.txt LOCALLY 拡張 を起動して、www.youtube.com_cookies.txt ファイルを入手します。

yt-dlp コマンドを実行

以下でダウンロードできるようになる。

yt-dlp --cookies www.youtube.com_cookies.txt https://www.youtube.com/watch?v=▲▲▲

おまけ

ffmpeg を使って、音声のみを切り出す

まずはcodec をチェック

$ ffmpeg -i hoge.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'hoge.mp4':
 Metadata:
  major_brand   : mp42
  minor_version  : 0
  compatible_brands: isommp42
  encoder     : Google
 Duration: 00:10:29.01, start: 0.000000, bitrate: 547 kb/s
 Stream #0:00x1: Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 640x360 [SAR 1:1 DAR 16:9], 448 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
   Metadata:
    handler_name  : ISO Media file produced by Google Inc.
    vendor_id    : [0][0][0][0]
 Stream #0:10x2: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)
   Metadata:
    handler_name  : ISO Media file produced by Google Inc.
    vendor_id    : [0][0][0][0]
At least one output file must be specified

ここで注目すべきは、Audio: aac (LC) という部分です。そのため、出力ファイル名の拡張子は aac にしなければなりません。

$ ffmpeg -i hoge.mp4 -acopy hoge.aac

ここでもし拡張子を .m4a などした場合には、再エンコードが発生しますのでご注意を。。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?