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
- Install
ttyrec
via Homebrew.ttyrec
is a terminal recorder that records all terminal output.
brew install ttyrec
- Start recording your terminal session using
ttyrec
.
ttyrec myrecording
- When you're done with the session that you want to record, press
Ctrl + D
to stop the recording. This will create a file calledmyrecording
in your current directory.
Convert Terminal recording to MP4
- Install
ttygif
via Homebrew.ttygif
converts a ttyrec file into gif files.
brew install ttygif
- Convert the
ttyrec
file to agif
file.
ttygif myrecording
-
This will create a
gif
file namedtty.gif
. To convert thisgif
file tomp4
, we will useffmpeg
. -
Install
ffmpeg
via Homebrew.
brew install ffmpeg
- Convert the
gif
tomp4
.
ffmpeg -i tty.gif output.mp4
Upload MP4 to YouTube
-
Download the
youtubeuploader
binary from its GitHub repository. You can download it from https://github.com/porjo/youtubeuploader. -
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/
-
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 aboutyoutubeuploader
. -
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. -
Move
client_secrets.json
to the directory mentioned in the error message, for example:
mv client_secrets.json "/Users/username/Library/Application Support/youtubeuploader/"
- 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.
- 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:
-
Ensure that you have the
youtubeuploader
binary installed and set up as mentioned in the previous sections. -
Ensure your video file is in the
mp4
format. If it isn't, useffmpeg
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.
- 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.
- 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.