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

Transcode to PSP using Handbrake

Source: Handbrake 0.9.9.5530 64-bit edition Target: (Phat) Playstation Portable PSP-1000 , System Software: 6.60 Many internet articles on how to transcode video to PSP using Handbrake have not worked for me. Even the most helpful are incomplete. I hope this post will help fill in the blanks. There is no longer any PSP preset for Handbrake, but from what I can gather, the preset had only limited success as the x264 encoder would change syntax and settings between versions. Other presets that may have worked before, like 'iPod' and 'Apple-Universal' now do not. Here is what worked for me, step by step:

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)

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.