Help us understand the problem. What is going on with this article?

pythonとyoutube-dlで簡単にmp4を部分ダウンロードする!

目的

pythonとyoutube-dlで簡単にmp4を部分ダウンロードする!

環境

$python3 --version
Python 3.7.3

mkv,mp4変換のためのffmpegをインストールする

$brew install ffmpeg

DLフォルダ作成

$mkdir mp4-download

Python用仮想環境

$cd mp4-download
$python3 -m venv venv
$source venv/bin/activate

youtube-dlをpipでインストール

$pip install youtube-dl

動画(mkv)を部分ダウンロード

$ ffmpeg $(youtube-dl -g 'https://www.youtube.com/watch?v=Nyg2qysqgpg' | sed "s/.*/-ss 03:55:00 -i &/") -t 00:01:00 -c copy out.mkv

mkvをmp4に変換

$ for f in *.mkv;do ffmpeg -i "$f" -c:v copy -c:a aac -b:a 256k -strict -2 "${f%mkv}mp4";done

ダウンロード結果確認

$ open out.mp4

よかったよかった

skt-tofuya
SKT豆腐屋血盟のIT部門です!
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした