Record the Terminal session
- Install
ttyrecvia Homebrew.ttyrecis 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 + Dto stop the recording. This will create a file calledmyrecordingin your current directory.
Convert Terminal recording to MP4
- Install
ttygifvia Homebrew.ttygifconverts a ttyrec file into gif files.
$ brew install ttygif- Convert the
ttyrecfile to agiffile.
$ ttygif myrecording- This will create a
giffile namedtty.gif. To convert thisgiffile tomp4, we will useffmpeg.
- Install
ffmpegvia Homebrew.
$ brew install ffmpeg- Convert the
giftomp4.
$ ffmpeg -i tty.gif output.mp4Upload MP4 to YouTube
- Download the
youtubeuploaderbinary from its GitHub repository. You can download it from https://github.com/porjo/youtubeuploader.
- Extract the downloaded archive and move the
youtubeuploaderbinary 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.jsonfile. See the Google Cloud Console documentation for more information on this.
- Move
client_secrets.jsonto the directory mentioned in the error message, for example:
$ mv client_secrets.json "/Users/username/Library/Application Support/youtubeuploader/"- Run
youtubeuploaderand 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-privacyStatusto 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
youtubeuploaderbinary installed and set up as mentioned in the previous sections.
- Ensure your video file is in the
mp4format. If it isn't, useffmpegto convert it:
$ ffmpeg -i input.avi output.mp4Replace 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.