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?

pythonでYouTube動画をダウンロード【高画質、無料、ロゴなし、回数制限なし、複数可能】

Posted at

ffmpegのインストールと環境パス設定が予め必要です。

urlにYouTubeのリンク、outtmplには出力動画のパスを載せてください。

時間指定で一部だけの保存もできます。ライブ配信などに便利です。

import os
from yt_dlp import YoutubeDL

#オプションを指定(最高画質の 動画と最高音質の音声を取り出し結合するためのオプション)
option = {
    'outtmpl' : '',
    'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]',
    'merge_output_format': 'mp4',
    # 'postprocessor_args': [
    #     '-ss', '1:04:39',  # 開始時間を指定
    #     '-to', '1:06:27'   # 終了時間を指定
    # ],
}

#インスタンスの生成
ydl = YoutubeDL(option)

#ダウンロードの実行
result = ydl.download(["url"])
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?