python:youtube-dl

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
python:youtube-dl [2020/08/21 11:24] – [トラブルシューティング] ともやんpython:youtube-dl [2022/05/08 08:02] (現在) – [youtube-dl - YouTube や他の動画サイトから動画をダウンロード] ともやん
行 1: 行 1:
-<html> +~~CLOSETOC~~
-  <style> +
-    #result pre, #mincode pre { +
-      overflow: scroll; +
-      overflow-x: hidden; +
-      font-size: 10px; +
-    } +
-    #result_long pre { +
-      height: 400px; +
-      overflow: scroll; +
-      overflow-x: hidden; +
-      font-size: 10px; +
-    } +
-    #logo { +
-      background-color: #222; +
-      width: fit-content; +
-      padding: 2px 10px; +
-    } +
-    #logo p { +
-      margin: 0; +
-    } +
-  </style> +
-</html>+
 ====== youtube-dl - YouTube や他の動画サイトから動画をダウンロード ====== ====== youtube-dl - YouTube や他の動画サイトから動画をダウンロード ======
 +{{python:python_youtube-dl_mp4.png?470|Python youtube-dl format mp4}}\\
 youtube-dl は、YouTube などの動画共有サービスから動画のダウンロードや音声の抽出を行うコマンドラインプログラムである。\\ youtube-dl は、YouTube などの動画共有サービスから動画のダウンロードや音声の抽出を行うコマンドラインプログラムである。\\
 Python で書かれているのでクロスプラットフォームである。Unlicense の下で配布されている。\\ Python で書かれているのでクロスプラットフォームである。Unlicense の下で配布されている。\\
 [[wpjp>Youtube-dl|youtube-dl - Wikipedia]] より\\ [[wpjp>Youtube-dl|youtube-dl - Wikipedia]] より\\
 +
 +[[:python:yt-dlp|yt-dlp]] を推奨。\\
  
 ===== pip によるインストール ===== ===== pip によるインストール =====
 **youtube-dl** CUI\\  **youtube-dl** CUI\\ 
 <code> <code>
-$ pip install youtybe-dl+$ pip install youtube-dl
 </code> </code>
  
行 50: 行 31:
  
 ===== ダウンロード形式の指定 ===== ===== ダウンロード形式の指定 =====
 +**mp4** コンテナに最高画質/最高音質で保存する。\\
 +<html><code>$ youtube-dl --format "bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best" --merge-output-format mp4 &lt;url&gt;</code></html>\\
 +<WRAP prewrap 100%>
 +<code>
 +$ youtube-dl --format "bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best" --merge-output-format mp4 https://www.youtube.com/watch?v=PQhWrgVWHXU
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +[youtube] PQhWrgVWHXU: Downloading webpage
 +[download] Destination: 吉幾三「百年桜」MV(2020年4月29日発売)-PQhWrgVWHXU.f137.mp4
 +[download] 100% of 101.66MiB in 00:18
 +[download] Destination: 吉幾三「百年桜」MV(2020年4月29日発売)-PQhWrgVWHXU.f140.m4a
 +[download] 100% of 4.72MiB in 00:01
 +[ffmpeg] Merging formats into "吉幾三「百年桜」MV(2020年4月29日発売)-PQhWrgVWHXU.mp4"
 +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)
 +</code>
 +</WRAP>
 +
 +**m4a** コンテナに最高音質で音声のみ保存する。\\
 +youtube-dl が **AtomicParsley** を使用して m4a にサムネイル画像を埋め込むので、予め [[windows:scoop|scoop]] などでインストールしておく。\\
 +Windows の場合は [[windows:scoop|scoop]] コマンドで AtomicParsley をインストールしてから youtube-dl でダウンロードする。\\
 +<WRAP prewrap 100%>
 +<code>
 +$ scoop install atomicparsley
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +Installing 'atomicparsley' (0.9.0) [64bit]
 +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 'AtomicParsley'.
 +'atomicparsley' (0.9.0) was installed successfully!
 +</code>
 +</WRAP>
 +<html><code>$ youtube-dl -f bestaudio[ext=m4a] --embed-thumbnail --add-metadata &lt;url&gt;</code></html>\\
 +<WRAP prewrap 100%>
 +<code>
 +$ youtube-dl -f bestaudio[ext=m4a] --embed-thumbnail --add-metadata https://youtu.be/mzGo1Ar-f1w
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +[youtube] mzGo1Ar-f1w: Downloading webpage
 +[youtube] mzGo1Ar-f1w: Downloading thumbnail ...
 +[youtube] mzGo1Ar-f1w: Writing thumbnail to: ぜんぶ君のせいだ。「無題合唱」アニメーションMusicVideo-mzGo1Ar-f1w.webp
 +[download] ぜんぶ君のせいだ。「無題合唱」アニメーションMusicVideo-mzGo1Ar-f1w.m4a has already been downloaded
 +[download] 100% of 3.90MiB
 +[ffmpeg] Correcting container in "ぜんぶ君のせいだ。「無題合唱」アニメーションMusicVideo-mzGo1Ar-f1w.m4a"
 +[ffmpeg] Adding metadata to 'ぜんぶ君のせいだ。「無題合唱」アニメーションMusicVideo-mzGo1Ar-f1w.m4a'
 +[ffmpeg] Converting thumbnail "ぜんぶ君のせいだ。「無題合唱」アニメーションMusicVideo-mzGo1Ar-f1w.webp" to JPEG
 +[atomicparsley] Adding thumbnail to "ぜんぶ君のせいだ。「無題合唱」アニメーションMusicVideo-mzGo1Ar-f1w.m4a"
 +</code>
 +</WRAP>
 +
 +エクスプローラで m4a のサムネイルをプレビューした様子。\\
 +{{python:youtube-dl_m4a_atomicparsley_thumbnail_001.png?640|エクスプローラ m4a サムネイル 001}}\\
 +
 +==== 手動で形式を指定する場合 ====
 ダウンロード可能なフォーマットコードを調べる。\\ ダウンロード可能なフォーマットコードを調べる。\\
 **youtube-dl -F <url>**\\ **youtube-dl -F <url>**\\
行 100: 行 144:
  
 ===== トラブルシューティング ===== ===== トラブルシューティング =====
 +
 +==== ダウンロードが遅い... ようつべさんが激怒💢❓😅 ====
 +2021/6/17 頃から、サーバー側でスロットル制限が行なわれてランダムにダウンロード速度が低下している報告があがってましたが、2021/10/21 現在はすべてのダウンロード速度に規制がかかっている模様です🤔以下の文献などでも回避方法が議論されています😅💦\\
 +[[git>ytdl-org/youtube-dl/issues/29326|[YouTube] Randomly slow youtube download speed  · Issue #29326 · ytdl-org/youtube-dl]]\\
 +[[git>fent/node-ytdl-core/issues/964|Randomly slow youtube download speed  · Issue #964 · fent/node-ytdl-core]]\\
 +
 +VLC の本家でも議論されていますが、何点か回避方法が示されています🤤\\
 +[[https://code.videolan.org/videolan/vlc/-/issues/26174#note_286229|YouTube Lua Video Lockup (#26174) · Issues · VideoLAN / VLC]]\\
 +
 +==== ERROR: AtomicParsley was not found. Please install. が発生する場合 ====
 +<WRAP prewrap 100%>
 +<code>
 +$ youtube-dl -f bestaudio[ext=m4a] --embed-thumbnail --add-metadata https://youtu.be/mzGo1Ar-f1w
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +[youtube] mzGo1Ar-f1w: Downloading webpage
 +[youtube] mzGo1Ar-f1w: Downloading thumbnail ...
 +[youtube] mzGo1Ar-f1w: Writing thumbnail to: ぜんぶ君のせいだ。「無題合唱」アニメーションMusicVideo-mzGo1Ar-f1w.webp
 +[download] Destination: ぜんぶ君のせいだ。「無題合唱」アニメーションMusicVideo-mzGo1Ar-f1w.m4a
 +[download] 100% of 3.85MiB in 00:06
 +[ffmpeg] Correcting container in "ぜんぶ君のせいだ。「無題合唱」アニメーションMusicVideo-mzGo1Ar-f1w.m4a"
 +[ffmpeg] Adding metadata to 'ぜんぶ君のせいだ。「無題合唱」アニメーションMusicVideo-mzGo1Ar-f1w.m4a'
 +[ffmpeg] Converting thumbnail "ぜんぶ君のせいだ。「無題合唱」アニメーションMusicVideo-mzGo1Ar-f1w.webp" to JPEG
 +ERROR: AtomicParsley was not found. Please install.
 +</code>
 +</WRAP>
 +
 +Windows の場合は [[windows:scoop|scoop]] コマンドで AtomicParsley をインストールしてから youtube-dl でダウンロードする。\\
 +<WRAP prewrap 100%>
 +<code>
 +$ scoop install atomicparsley
 +</code>
 +</WRAP>
 +<WRAP prewrap 100% #result>
 +<code>
 +Installing 'atomicparsley' (0.9.0) [64bit]
 +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 'AtomicParsley'.
 +'atomicparsley' (0.9.0) was installed successfully!
 +</code>
 +</WRAP>
  
 ==== HTTP Error 403: Forbidden が発生する場合 ==== ==== HTTP Error 403: Forbidden が発生する場合 ====
 +<WRAP prewrap 100%>
 <code> <code>
 $ youtube-dl https://www.youtube.com/watch?v=Hs-h6xmzaaU $ youtube-dl https://www.youtube.com/watch?v=Hs-h6xmzaaU
 </code> </code>
 +</WRAP>
 <WRAP prewrap 100% #result> <WRAP prewrap 100% #result>
 <code> <code>
行 143: 行 235:
 ===== 参考文献 ===== ===== 参考文献 =====
 [[https://aprico-media.com/posts/1374|youtube-dlgの使い方解説!日本語化/ダウンロードできない/評判まとめ! | Aprico]]\\ [[https://aprico-media.com/posts/1374|youtube-dlgの使い方解説!日本語化/ダウンロードできない/評判まとめ! | Aprico]]\\
 +[[https://qastack.jp/unix/272868/download-only-format-mp4-on-youtube-dl|youtube-dlで形式mp4のみをダウンロードする]]\\
 +[[https://askubuntu.com/questions/634584/how-to-download-youtube-videos-as-a-best-quality-audio-mp3-using-youtube-dl|sound - How to download youtube videos as a best quality audio mp3 using youtube-dl - Ask Ubuntu]]\\
  
  • python/youtube-dl.1597976670.txt.gz
  • 最終更新: 2020/08/21 11:24
  • by ともやん