2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

youtube-dl で 動画アーカイブをダウンロードして ffmpeg でタイムラプスを作成する

Last updated at Posted at 2020-12-18

はじめに

イベント配信後の作業を楽に(時間を短縮)するためのTIPSです。

最近はオンラインイベント一色から徐々にオフラインイベントも再開されつつあります。
オンラインとオフラインのハイブリッド配信も多くなり、配信に係る作業量も多く(倍とまでは言いませんが、1.5倍程度に)なりました。
オフラインイベントは移動や会場毎の配信準備が省略できませんので、少しでも作業時間を減らしたいというニーズがあります。

配信時は時間を掛けてデータをアップロードするのでネットワーク帯域は数Mbps程度あれば十分ですが、動画アーカイブのダウンロード時は自宅や外出先(オフラインイベント会場など)でネットワーク環境が良くない場合、数GBのデータをダウンロードするのに時間が掛かる場合があります。

before

そこで、クラウド環境で動画アーカイブのダウンロードとタイムラプスの作成を行う方法を考えました。

after

インストール

さくらのクラウドサーバーでの使用例です。
Ubuntu 18.04.5 LTS (Bionic Beaver)

# youtube-dl のインストール
$ sudo apt install -y python
$ sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
$ sudo chmod a+rx /usr/local/bin/youtube-dl

# ffmpeg のインストール
$ sudo apt install -y ffmpeg

手順

# 動画アーカイブのフォーマットコードの一覧表示
$ youtube-dl -F <YouTube動画のURL>
$ youtube-dl -F https://youtu.be/iYySh5PkAHE
[youtube] iYySh5PkAHE: Downloading webpage
[info] Available formats for iYySh5PkAHE:
format code  extension  resolution note
249          webm       audio only tiny   62k , opus @ 50k (48000Hz), 53.26MiB
250          webm       audio only tiny   79k , opus @ 70k (48000Hz), 64.02MiB
140          m4a        audio only tiny  138k , m4a_dash container, mp4a.40.2@128k (44100Hz), 138.11MiB
251          webm       audio only tiny  147k , opus @160k (48000Hz), 115.31MiB
278          webm       256x144    144p   95k , webm container, vp9, 30fps, video only, 41.23MiB
160          mp4        256x144    144p  129k , avc1.4d400c, 30fps, video only, 37.92MiB
242          webm       426x240    240p  199k , vp9, 30fps, video only, 59.61MiB
133          mp4        426x240    240p  291k , avc1.4d4015, 30fps, video only, 74.82MiB
243          webm       640x360    360p  354k , vp9, 30fps, video only, 100.83MiB
244          webm       854x480    480p  587k , vp9, 30fps, video only, 151.26MiB
134          mp4        640x360    360p  636k , avc1.4d401e, 30fps, video only, 133.05MiB
247          webm       1280x720   720p 1025k , vp9, 30fps, video only, 313.22MiB
135          mp4        854x480    480p 1186k , avc1.4d401f, 30fps, video only, 218.19MiB
248          webm       1920x1080  1080p 1731k , vp9, 30fps, video only, 502.10MiB
136          mp4        1280x720   720p 2362k , avc1.64001f, 30fps, video only, 414.96MiB
137          mp4        1920x1080  1080p 4391k , avc1.640028, 30fps, video only, 825.61MiB
18           mp4        640x360    360p  224k , avc1.42001E, 30fps, mp4a.40.2@ 96k (44100Hz), 239.40MiB
22           mp4        1280x720   720p 1012k , avc1.64001F, 30fps, mp4a.40.2@192k (44100Hz) (best)
# 動画アーカイブのダウンロード (フォーマットコード: 22の場合)
$ youtube-dl -f 22 <YouTube動画のURL>

# タイムラプスの作成
$ ffmpeg -i <オリジナル動画> -filter:v "setpts=PTS/240" -r 15 -an <タイムラプス動画>

最後に作成されたタイムラプスをローカルPCにダウンロードすれば完了です。

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?