Description

I am fond of experimenting with the Raspberry Pi camera options (such as image effects and duration) while recording demonstration videos for my electronics projects, and especially when birdwatching in my balcony :) When I take a video with my Raspberry Pi for the mentioned reasons, I usually upload the video to my YouTube channel, as a private video, due to the storage limit on Pi. However, the process of recording and uploading through Raspberry Pi had miscellaneous and intricate steps to follow all over again: adjusting video settings manually, opening my YouTube channel, defining video parameters, etc.

Thus, I contemplated a GUI by which I could adjust the video recording settings and define the parameters to upload videos to YouTube without signing to my YouTube channel on the browser every time. After some research, I decided to use the Google APIs Client Library for Python to communicate with my YouTube channel through the YouTube Data API. In the end, I developed a GUI (YouTube Video Recorder and Uploader) in Python, including two interfaces - Record menu and Upload menu.

In the Record menu:

You can define filename (timestamp included automatically), annotation text (if required), the video duration, and select an image effect (predefined by the GUI, for instance, negative).

In the Upload menu:

You can upload the selected video to YouTube via the YouTube Data API without any further steps by merely entering the required parameters by YouTube - Title, Description, Keywords, Category, and Privacy Status.

You can find detailed information about the features of the GUI (YouTube Video Recorder and Uploader) in the Features.

After completing coding, to add mobility and night vision to my project - helpful while birdwatching or recording outside at night :) - I used a 7'' HDMI Display with Capacitive Touchscreen and a 5MP Night Vision Camera, kindly sponsored by DFRobot.

Sponsored Products by DFRobot:

  • 7'' HDMI Display with Capacitive Touchscreen | Inspect
  • 5MP Night Vision Camera for Raspberry Pi | Inspect

Preview: What You Will Learn

  • How to register your application with Google so that it can use the OAuth 2.0 protocol to authorize access to user data
  • How to install the Google APIs Client Library for Python on Raspberry Pi
  • How to set up the night vision camera to record videos with the given settings
  • How to program a GUI with the guizero module
  • How to create a class in Python
  • How to convert the H264 format to the MP4 format using MP4Box in Python
  • How to upload videos to your YouTube channel using the YouTube Data API

Step 1: Registering an application with Google to use the OAuth 2.0 protocol to authorize access

You need to create an application on the Google API Console to run the Google APIs Client Library for Python properly, and your application must have authorization credentials to be able to use the YouTube Data API.

If you are a novice to the Google API Console, do not worry it is a simple process, apply the following steps only :)

  • Enter the project name - YouTubeUploader - and create the project.

  • Open the API Library.

  • Enable the YouTube Data API v3.

  • Select 'Credentials' under the YouTube Data API v3 and click the 'CREATE CREDENTIALS' button.

  • Select the application type as 'Other' and enter the application name as 'Client'.

  • Copy the Client ID and the Client Secret. You will need them later when authorizing your Raspberry Pi with the Google APIs Client Library for Python as a user.

Step 2: Installing the Google APIs Client Library for Python on Raspberry Pi 

Open the terminal and enter the command below (it will take some time to install all packages): 

 $ sudo pip install --upgrade google-api-python-client

Step 3: Authorizing Raspberry Pi to upload videos via the YouTube Data API

First of all, create a new folder at this path:

/home/pi/YouTube-Recorder-and-Uploader/

Then, download...

Read more »