Skip to main content

YouTube Download and Transcode in Google Colab

Summary: 

Create a new notebook with 2 simple commands in a code block:

!pip install yt-dlp

!yt-dlp {youtube-link}

The downloaded file will appear in the /content folder on your Google Colab VM.

The 'bestvideo+bestaudio' format will be used by default.

Example yt-dlp commands:

#List formats 

!yt-dlp -F {youtube-link}

#download audio-only mp3

!yt-dlp bestaudio -x --audio-format mp3 {youtube-link}

Notes

yt-dlp project page.

Let's say you want to:

  1. Download a YouTube video, 
  2. In a particular format, e.g. H.264 video with AAC audio or audio-only MP3.

Option 1 - Video Downloader sites

  • Full of spam and ads. Don't install their malware, BTW.
  • Don't always work.

Option 2 - yt-dlp in Windows Subsystem for Linux

  • Works extremely well...
  • ... until it doesn't. YouTube blocks you eventually and starts thowing 403 Forbidden errors.
  • Oh, and transcoding is slow if you have a potato PC like I do.

Option 3 - Use Google Colab.

Use a Google VM to download from Google. 


  • Even the most basic Python environment runs with more compute and bandwidth than your home setup. 
  • You'll note the '!' executes shell commands in what is basically Linux.
  • You don't have to install ffmpeg (or pip, or python) because it's already installed.
  • You can discard the VM after use, making it harder to block.

Comments

Popular posts from this blog

Firefox History Statistics - Extracting from Places.sqlite

If you want to take a look at Firefox surfing activity, the about:me add-on is a good start. However, it presents only one view of data and is thus limited in its ability to present more detailed statistics. We will view that data in a different program. So let's first extract it from the browsing history stored in the Places.sqlite file into a CSV file using a Firefox add-on. Step 1 - Locate and copy Places.sqlite to a working location On Windows machines, Places.sqlite is found in a directory similar to: C:\Users\User1\AppData\Roaming\Mozilla\Firefox\Profiles\ .default\places.sqlite Copy the file to another location. The database will be locked while using Firefox, and the SQLite plugin we will use to open it.

Live Long and Prosper

Australia is becoming richer by getting older. Australian household net worth rose from an average of $764,500 in 2011-2012 to $1,022,000 in 2017-2018 . Those under 35 have barely seen any increase. The old, in particular the over-45s, are getting richer faster than the young. Older households are also a greater proportion of the sample, and of the population.

Scatterbox - build an Android Tor Socks Proxy Server

Cloak your location and create a firewall bypass device with a smartphone. 🕵Uses the Tor network . Does not require root. 1 - from Google Play, download and install: Orbot Orweb browser Socks Server Ultimate (Optional)