差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
| python:youtube-dl [2020/07/24 04:28] – [youtube-dl - YouTube や他の動画サイトから動画をダウンロード] ともやん | python:youtube-dl [2022/05/08 08:02] (現在) – [youtube-dl - YouTube や他の動画サイトから動画をダウンロード] ともやん | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | < | + | ~~CLOSETOC~~ |
| - | < | + | |
| - | #result pre, #mincode pre { | + | |
| - | overflow: scroll; | + | |
| - | overflow-x: hidden; | + | |
| - | font-size: 10px; | + | |
| - | } | + | |
| - | # | + | |
| - | height: 400px; | + | |
| - | overflow: scroll; | + | |
| - | overflow-x: hidden; | + | |
| - | font-size: 10px; | + | |
| - | } | + | |
| - | #logo { | + | |
| - | background-color: | + | |
| - | width: fit-content; | + | |
| - | padding: 2px 10px; | + | |
| - | } | + | |
| - | #logo p { | + | |
| - | margin: 0; | + | |
| - | } | + | |
| - | </ | + | |
| - | </ | + | |
| ====== youtube-dl - YouTube や他の動画サイトから動画をダウンロード ====== | ====== youtube-dl - YouTube や他の動画サイトから動画をダウンロード ====== | ||
| + | {{python: | ||
| youtube-dl は、YouTube などの動画共有サービスから動画のダウンロードや音声の抽出を行うコマンドラインプログラムである。\\ | youtube-dl は、YouTube などの動画共有サービスから動画のダウンロードや音声の抽出を行うコマンドラインプログラムである。\\ | ||
| Python で書かれているのでクロスプラットフォームである。Unlicense の下で配布されている。\\ | Python で書かれているのでクロスプラットフォームである。Unlicense の下で配布されている。\\ | ||
| [[wpjp> | [[wpjp> | ||
| - | ===== ダウンロード ===== | + | [[: |
| + | |||
| + | ===== pip によるインストール ===== | ||
| + | **youtube-dl** CUI\\ | ||
| + | < | ||
| + | $ pip install youtube-dl | ||
| + | </ | ||
| + | |||
| + | **youtube-dl-gui** GUI\\ | ||
| + | < | ||
| + | $ pip install youtube-dl-gui | ||
| + | </ | ||
| + | |||
| + | ===== ダウンロードによるインストール | ||
| [[windows: | [[windows: | ||
| < | < | ||
| 行 37: | 行 29: | ||
| **youtube-dl-gui** のバイナリインストーラは以下からダウンロードできる。\\ | **youtube-dl-gui** のバイナリインストーラは以下からダウンロードできる。\\ | ||
| [[https:// | [[https:// | ||
| + | |||
| + | ===== ダウンロード形式の指定 ===== | ||
| + | **mp4** コンテナに最高画質/ | ||
| + | < | ||
| + | <WRAP prewrap 100%> | ||
| + | < | ||
| + | $ youtube-dl --format " | ||
| + | </ | ||
| + | </ | ||
| + | <WRAP prewrap 100% #result> | ||
| + | < | ||
| + | [youtube] PQhWrgVWHXU: | ||
| + | [download] Destination: | ||
| + | [download] 100% of 101.66MiB in 00:18 | ||
| + | [download] Destination: | ||
| + | [download] 100% of 4.72MiB in 00:01 | ||
| + | [ffmpeg] Merging formats into " | ||
| + | Deleting original file 吉幾三「百年桜」MV(2020年4月29日発売)-PQhWrgVWHXU.f137.mp4 (pass -k to keep) | ||
| + | Deleting original file 吉幾三「百年桜」MV(2020年4月29日発売)-PQhWrgVWHXU.f140.m4a (pass -k to keep) | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | **m4a** コンテナに最高音質で音声のみ保存する。\\ | ||
| + | youtube-dl が **AtomicParsley** を使用して m4a にサムネイル画像を埋め込むので、予め [[windows: | ||
| + | Windows の場合は [[windows: | ||
| + | <WRAP prewrap 100%> | ||
| + | < | ||
| + | $ scoop install atomicparsley | ||
| + | </ | ||
| + | </ | ||
| + | <WRAP prewrap 100% #result> | ||
| + | < | ||
| + | Installing ' | ||
| + | AtomicParsley-win32-0.9.0.zip (438.9 KB) [================================================] 100% | ||
| + | Checking hash of AtomicParsley-win32-0.9.0.zip ... ok. | ||
| + | Extracting AtomicParsley-win32-0.9.0.zip ... done. | ||
| + | Linking ~\scoop\apps\atomicparsley\current => ~\scoop\apps\atomicparsley\0.9.0 | ||
| + | Creating shim for ' | ||
| + | ' | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | <WRAP prewrap 100%> | ||
| + | < | ||
| + | $ youtube-dl -f bestaudio[ext=m4a] --embed-thumbnail --add-metadata https:// | ||
| + | </ | ||
| + | </ | ||
| + | <WRAP prewrap 100% #result> | ||
| + | < | ||
| + | [youtube] mzGo1Ar-f1w: | ||
| + | [youtube] mzGo1Ar-f1w: | ||
| + | [youtube] mzGo1Ar-f1w: | ||
| + | [download] ぜんぶ君のせいだ。「無題合唱」アニメーションMusicVideo-mzGo1Ar-f1w.m4a has already been downloaded | ||
| + | [download] 100% of 3.90MiB | ||
| + | [ffmpeg] Correcting container in " | ||
| + | [ffmpeg] Adding metadata to ' | ||
| + | [ffmpeg] Converting thumbnail " | ||
| + | [atomicparsley] Adding thumbnail to " | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | エクスプローラで m4a のサムネイルをプレビューした様子。\\ | ||
| + | {{python: | ||
| + | |||
| + | ==== 手動で形式を指定する場合 ==== | ||
| + | ダウンロード可能なフォーマットコードを調べる。\\ | ||
| + | **youtube-dl -F < | ||
| + | < | ||
| + | $ youtube-dl -F https:// | ||
| + | </ | ||
| + | <WRAP prewrap 100% #result> | ||
| + | < | ||
| + | [youtube] PQhWrgVWHXU: | ||
| + | [info] Available formats for PQhWrgVWHXU: | ||
| + | format code extension | ||
| + | 249 webm audio only tiny 54k , opus @ 50k (48000Hz), 1.79MiB | ||
| + | 250 webm audio only tiny 72k , opus @ 70k (48000Hz), 2.37MiB | ||
| + | 140 m4a audio only tiny 130k , m4a_dash container, mp4a.40.2@128k (44100Hz), 4.72MiB | ||
| + | 251 webm audio only tiny 140k , opus @160k (48000Hz), 4.65MiB | ||
| + | 394 mp4 256x144 | ||
| + | 278 webm | ||
| + | 160 mp4 256x144 | ||
| + | 395 mp4 426x240 | ||
| + | 242 webm | ||
| + | 133 mp4 426x240 | ||
| + | 396 mp4 640x360 | ||
| + | 243 webm | ||
| + | 134 mp4 640x360 | ||
| + | 397 mp4 854x480 | ||
| + | 244 webm | ||
| + | 135 mp4 854x480 | ||
| + | 398 mp4 1280x720 | ||
| + | 247 webm | ||
| + | 136 mp4 1280x720 | ||
| + | 248 webm | ||
| + | 399 mp4 1920x1080 | ||
| + | 137 mp4 1920x1080 | ||
| + | 18 | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | フォーマットコードで形式を指定してダウンロードする。\\ | ||
| + | **youtube-dl -f <format code> < | ||
| + | < | ||
| + | $ youtube-dl -f 137 https:// | ||
| + | </ | ||
| + | <WRAP prewrap 100% #result> | ||
| + | < | ||
| + | [youtube] PQhWrgVWHXU: | ||
| + | [download] Destination: | ||
| + | [download] 100% of 101.66MiB in 00:23 | ||
| + | </ | ||
| + | </ | ||
| ===== トラブルシューティング ===== | ===== トラブルシューティング ===== | ||
| + | |||
| + | ==== ダウンロードが遅い... ようつべさんが激怒💢❓😅 ==== | ||
| + | 2021/6/17 頃から、サーバー側でスロットル制限が行なわれてランダムにダウンロード速度が低下している報告があがってましたが、2021/ | ||
| + | [[git> | ||
| + | [[git> | ||
| + | |||
| + | VLC の本家でも議論されていますが、何点か回避方法が示されています🤤\\ | ||
| + | [[https:// | ||
| + | |||
| + | ==== ERROR: AtomicParsley was not found. Please install. が発生する場合 ==== | ||
| + | <WRAP prewrap 100%> | ||
| + | < | ||
| + | $ youtube-dl -f bestaudio[ext=m4a] --embed-thumbnail --add-metadata https:// | ||
| + | </ | ||
| + | </ | ||
| + | <WRAP prewrap 100% #result> | ||
| + | < | ||
| + | [youtube] mzGo1Ar-f1w: | ||
| + | [youtube] mzGo1Ar-f1w: | ||
| + | [youtube] mzGo1Ar-f1w: | ||
| + | [download] Destination: | ||
| + | [download] 100% of 3.85MiB in 00:06 | ||
| + | [ffmpeg] Correcting container in " | ||
| + | [ffmpeg] Adding metadata to ' | ||
| + | [ffmpeg] Converting thumbnail " | ||
| + | ERROR: AtomicParsley was not found. Please install. | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | Windows の場合は [[windows: | ||
| + | <WRAP prewrap 100%> | ||
| + | < | ||
| + | $ scoop install atomicparsley | ||
| + | </ | ||
| + | </ | ||
| + | <WRAP prewrap 100% #result> | ||
| + | < | ||
| + | Installing ' | ||
| + | AtomicParsley-win32-0.9.0.zip (438.9 KB) [================================================] 100% | ||
| + | Checking hash of AtomicParsley-win32-0.9.0.zip ... ok. | ||
| + | Extracting AtomicParsley-win32-0.9.0.zip ... done. | ||
| + | Linking ~\scoop\apps\atomicparsley\current => ~\scoop\apps\atomicparsley\0.9.0 | ||
| + | Creating shim for ' | ||
| + | ' | ||
| + | </ | ||
| + | </ | ||
| ==== HTTP Error 403: Forbidden が発生する場合 ==== | ==== HTTP Error 403: Forbidden が発生する場合 ==== | ||
| + | <WRAP prewrap 100%> | ||
| < | < | ||
| $ youtube-dl https:// | $ youtube-dl https:// | ||
| </ | </ | ||
| + | </ | ||
| <WRAP prewrap 100% #result> | <WRAP prewrap 100% #result> | ||
| < | < | ||
| 行 82: | 行 235: | ||
| ===== 参考文献 ===== | ===== 参考文献 ===== | ||
| [[https:// | [[https:// | ||
| + | [[https:// | ||
| + | [[https:// | ||