3am: Broadcasting to the World: How to Upload a YouTube Video from the Terminal

We are in the early hours of the morning, we're bringing you a new adventure: uploading videos to YouTube right from your terminal! In the age of interactive content, YouTube has become a global platform for sharing knowledge, insights, and experiences. While the typical approach to YouTube involves a Graphical User Interface (GUI) for uploading content, we're going to show you how to bypass the traditional route. In this guide, you'll learn to record terminal sessions, convert them into MP4 format, and upload them directly to YouTube, all using simple terminal commands. Let's dive in and start broadening our command line horizons!

What does this article replace?

This article provides a terminal-based solution for recording, converting, and uploading videos directly to YouTube, replacing the standard YouTube web or app-based upload process.

How long will it take to set up?

The setup process should take approximately 1-2 hours. This includes the installation of various packages and uploading the video.

3 out of 5 stars

Difficulty Rating:

Taking control of your video upload process from the terminal is moderately challenging, with a difficulty level of 3 out of 5. It requires familiarity with command-line tools and APIs for interacting with popular web platforms. By mastering this process, you can efficiently upload videos, customize settings, and automate the upload workflow directly from your command line, enhancing your productivity and control over the video upload process.

Record the Terminal session

  1. Install ttyrec via Homebrew. ttyrec is a terminal recorder that records all terminal output.
brew install ttyrec
  1. Start recording your terminal session using ttyrec.
ttyrec myrecording
  1. When you're done with the session that you want to record, press Ctrl + D to stop the recording. This will create a file called myrecording in your current directory.

Convert Terminal recording to MP4

  1. Install ttygif via Homebrew. ttygif converts a ttyrec file into gif files.
brew install ttygif
  1. Convert the ttyrec file to a gif file.
ttygif myrecording
  1. This will create a gif file named tty.gif. To convert this gif file to mp4, we will use ffmpeg.

  2. Install ffmpeg via Homebrew.

brew install ffmpeg
  1. Convert the gif to mp4.
ffmpeg -i tty.gif output.mp4

Upload MP4 to YouTube

  1. Download the youtubeuploader binary from its GitHub repository. You can download it from https://github.com/porjo/youtubeuploader.

  2. Extract the downloaded archive and move the youtubeuploader binary to a directory in your $PATH, like /usr/local/bin.

tar xvfz youtubeuploader*.tgz
mv youtubeuploader /usr/local/bin/
  1. If you see an error message saying youtubeuploader cannot be opened because the developer cannot be verified, open System Preferences > Security & Privacy > General, and click on "Open Anyway" next to the message about youtubeuploader.

  2. Get OAuth 2.0 credentials from the Google Cloud Console and download the client_secrets.json file. See the Google Cloud Console documentation for more information on this.

  3. Move client_secrets.json to the directory mentioned in the error message, for example:

mv client_secrets.json "/Users/username/Library/Application Support/youtubeuploader/"
  1. Run youtubeuploader and follow the instructions to authenticate. This will open a new tab in your web browser where you can log in to your Google account.
youtubeuploader -filename output.mp4 -title "My Video Title"

If you're doing this on a server or somewhere where you can't open a web browser, you might need to copy the generated token file to the server.

  1. The video will now be uploaded to YouTube with the title "My Video Title". You can provide additional parameters such as -description, -tags, and -privacyStatus to further customize your video upload.

That's it! You've recorded a terminal session, converted it to an MP4 file, and uploaded it to YouTube—all directly from the terminal.


Extra: Uploading Any MP4 Video to YouTube

If you have an existing MP4 video that you'd like to upload to YouTube, you can skip the terminal recording and converting steps and jump directly to the uploading process.

Remember, the video must be in MP4 format. If it isn't, you can use ffmpeg to convert it. Here are the steps:

  1. Ensure that you have the youtubeuploader binary installed and set up as mentioned in the previous sections.

  2. Ensure your video file is in the mp4 format. If it isn't, use ffmpeg to convert it:

ffmpeg -i input.avi output.mp4

Replace input.avi with the name of your input video file, and output.mp4 with the desired name for the converted video file.

  1. Run the youtubeuploader command with your mp4 file:
youtubeuploader -filename myvideo.mp4 -title "My Brilliant Video"

Replace myvideo.mp4 with the name of your video file, and "My Brilliant Video" with your desired video title.

  1. Follow the on-screen instructions to authenticate and upload your video.

Now you're not limited to uploading terminal recordings—you can upload any video content you wish, all from the convenience of your terminal!


With the ability to record, convert, and upload videos to YouTube, we're taking control of the web one command at a time. Stay tuned for more terminal wizardry as we continue to delve deeper into the night.