Automating Video Uploads to TikTok Using Raspberry Pi

The Raspberry Pi, a versatile and affordable single-board computer, has gained immense popularity among hobbyists, makers, and tech enthusiasts. While it's often used for educational and DIY projects, its capabilities can extend to more complex tasks, such as automating video uploads to popular social media platforms like TikTok. In this article, we will explore how a Raspberry Pi can be used to automatically upload recorded videos to TikTok, simplifying your content creation process.


Before diving into the process of automating video uploads to Tiktok (or other video apps, provided they have their own API) using a Raspberry Pi, make sure you have the following:

  1. Raspberry Pi (any model with Wi-Fi capabilities)
  2. A Raspberry Pi camera module or USB webcam for recording videos
  3. A TikTok account
  4. Python knowledge

Setting Up the Raspberry Pi

  1. Raspberry Pi Setup: Begin by setting up your Raspberry Pi with an operating system (e.g., Raspberry Pi OS). Ensure that it is connected to the internet, either via Wi-Fi or Ethernet.
  2. Camera Module/USB Webcam: If you're using a camera module, make sure it's correctly connected to the Raspberry Pi's camera interface. If you're using a USB webcam, plug it into one of the available USB ports.

    If your USB webcam is from Logitech, you can check if it is properly connected using the ff. bash script:

lsusb | grep "Logitech"

  The response to the above command would be:

Bus 001 Device 004: ID 046d:0825 Logitech, Inc. Webcam C270

   If using a Raspberry Pi camera, the command is:

vcgencmd get_camera 

  The response should be:

supported=1 detected=1

3. Python Libraries: You'll need to install Python libraries such as tiktokapi, selenium, and pyautogui. These libraries play crucial roles in automating the TikTok video upload process.

tiktokapi: This library allows you to interact programmatically with TikTok's services, enabling actions such as logging in and uploading videos.

selenium: Selenium is a powerful web automation tool that helps you control web browsers programmatically. It's used to navigate the TikTok website, interact with its elements, and automate the login and video upload processes.

pyautogui: PyAutoGUI is a library for automating keyboard and mouse input. It's useful for simulating user interactions, such as selecting files to upload during the video upload process.

You can install these libraries using the following commands:

pip install tiktokapi
pip install selenium
pip install pyautogui

Recording Videos Using Raspberry Pi Camera

To record videos using the Raspberry Pi camera module and Python, you can use the picamera library. Here's a simple code snippet to get you started:

import picamera
import time

# Initialize the camera
with picamera.PiCamera() as camera:
camera.resolution = (1920, 1080) # Set the resolution
camera.start_recording('my_video.h264') # Start recording
camera.wait_recording(10) # Record for 10 seconds
camera.stop_recording() # Stop recording

Automating TikTok Login with Selenium

Below is an example of how to automate the TikTok login process using Selenium in Python:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

# Initialize the Chrome web driver (you may need to install the driver separately)
driver = webdriver.Chrome()

# Navigate to TikTok login page

# Fill in login credentials
username = driver.find_element_by_name("email")
password = driver.find_element_by_name("password")


# Submit the login form

# Wait for the login to complete (you may need to adjust the sleep duration)

# Close the browser when done

Automating Video Uploads to TikTok with Selenium

Here's an example of how to automate video uploads to TikTok using Selenium in Python:

# Continue from the previous code
# ... (login code)

# Navigate to the upload page

# Select the video file to upload
video_input = driver.find_element_by_css_selector("input[type='file']")
video_input.send_keys("/path/to/your/video.mp4") # Replace with the actual video file path

# Add captions, hashtags, and other video details (you may need to adjust the selectors)
caption = driver.find_element_by_css_selector(".caption-textarea textarea")
caption.send_keys("Check out my video!")

hashtags = driver.find_element_by_css_selector(".input.hashtag-input input")
hashtags.send_keys("#tiktokautomation #raspberrypi")

# Submit the video for uploading
submit_button = driver.find_element_by_css_selector(".upload-ui-bottombar .upload-btn")

# Wait for the upload to complete (you may need to adjust the sleep duration)

# Close the browser when done

Note on the code above, you may replace the URL to other video app provided it supports API-based uploading of videos.

Scheduling Script Execution with Cron

To schedule your Python script to run every day at midnight, you can use the cron scheduler. Open the cron configuration with the following command:

crontab -e

Then, add the following line to schedule your script:

0 0 * * * /usr/bin/python3 /path/to/your/python/

Replace /path/to/your/python/ with the actual path to your Python script. This cron job will run your script every day at midnight.


With a Raspberry Pi, Python scripting, and the essential libraries such as selenium and pyautogui, you can automate the process of recording videos, logging into TikTok, and uploading videos. These libraries play a pivotal role in streamlining the automation process, allowing for consistent and scheduled video uploads.

Automating video uploads with a Raspberry Pi showcases the creative ways you can leverage technology for content creation. It's just one example of the many possibilities this versatile single-board computer offers to enthusiasts and tinkerers. Remember to abide by TikTok's terms of service and guidelines when automating uploads and ensure that your content aligns with their policies.