Python application that can be used to generate video thumbnail for mp4 and mkv file types.

Overview

Thumbnail Generator 🎬

github actions Codacy Badge made-with-python PyPI version

What is This


This is a Python application that can be used to generate video thumbnail for mp4 and mkv file types.

Imgur

Installation

You can use pip:

~$ pip3 install thumb-gen

Configurations

  • The number of screen images that should be included in the final thumbnail image
  • Thumbnail image quality
  • Font type in the video info panel. You can add a file path of a font file (.ttf) to this
  • Font size in the video info panel
  • Custom text in the video info panel
  • Background color of the thumbnail (Hex codes are also supported)
  • Font colour of the thumbnail (Hex codes are also supported)

Download font files : FontSquirrel

~$ thumb-gen -c

or

~$ thumb-gen --config

By program default:

IMAGES = 12
IMAGE_QUALITY = 80
FONT = 
FONT_SIZE = 20
CUSTOM_TEXT = 
BG_COLOUR = white
FONT_COLOUR = black

Usage

Usage options

Usage: thumb-gen file file
usage: thumb-gen dir dir

Options:
  -h, --help     show this help message and exit
  -c, --config   configurations (images, image quality, font, font size,
                 custom text, bg color, font color)
  -v, --version  show thumb-gen version and exit

Console

~$ thumb-gen -h
~$ thumb-gen --help

~$ thumb-gen -c
~$ thumb-gen --config

~$ thumb-gen -v
~$ thumb-gen --version

~$ thumb-gen input.mp4
~$ thumb-gen input.mp4 input2.mp4
~$ thumb-gen "d:/videos/input.mp4"

~$ thumb-gen "/videos"
~$ thumb-gen "/videos" "/videos2"
~$ thumb-gen "d:/videos"

Python

  • If you don't set an output folder, thumbnail images will be saved in the video folder (video_path).
  • If you don't need a custom text and custom font file (including font size) and you have already set these for the configuration file (using console or defaults), it will be added automatically. To avoid this set the custom_text value to False and add a custom font file location.

Example 1

from thumb_gen import Generator

#video_path, output_path='', custom_text=True, font_dir='', font_size=0, bg_colour='', font_colour=''
app = Generator("C:/input/video.mp4", "C:/output/", "www.example.com", "C:/Windows/Fonts/Arial.ttf", 30)
app.run()

Example 2

import os
from thumb_gen import Generator

folder = 'C:/input'
for video in os.listdir(folder):
    if video.endswith('.mp4') or video.endswith('.mkv'):
        app = Generator(os.path.join(folder, video), custom_text=False, font_dir="C:/Project/font.ttf", font_size=25, bg_colour='blue', font_colour='red')
        app.run()
You might also like...
This plugin generates json files used by deovr allowing you to play 2d and 3d video's using the player

deovr-plugin This plugin generates json files used by deovr allowing you to play 2d and 3d video's using the player. Deovr looks for an index file /de

A pure python media player that can be used in AI media API development.

A pure python media player that can be used in AI media API development.

Text2Video's purpose is to help people create videos quickly and easily by simply typing out the video’s script and a description of images to include in the video.
Text2Video's purpose is to help people create videos quickly and easily by simply typing out the video’s script and a description of images to include in the video.

Text2Video Text2Video's purpose is to help people create videos quickly and easily by simply typing out the video’s script and a description of images

Takes a video as an input and creates a video which is suitable to upload on Youtube Shorts and Tik Tok (1080x1920 resolution).

Shorts-Tik-Tok-Creator Takes a video as an input and creates a video which is suitable to upload on Youtube Shorts and Tik Tok (1080x1920 resolution).

Repository to create Ascii art in CMD based on video file.
Repository to create Ascii art in CMD based on video file.

Made to take any file format, and transform it into ascii art, displayed as a video in the cmd. If the cmd formatting is wrong, try zooming a little and remember to make cmd fullscreen. I made my cmd fullscreen, and zoomed out one tic. Written in Python 3.9

 Extracting frames from video and create video using frames
Extracting frames from video and create video using frames

Extracting frames from video and create video using frames This program uses opencv library to extract the frames from video and create video from ext

This application makes a webrtc video call with jitsi meet signaling

gstreamer-jitsi-meet This application makes a webrtc video call with jitsi meet signaling. Other end can be any jitsi meet app or web app. It doesn't

Streamlink is a CLI utility which pipes video streams from various services into a video player

Streamlink is a CLI utility which pipes video streams from various services into a video player

Filtering user-generated video content(SberZvukTechDays)Filtering user-generated video content(SberZvukTechDays)
Filtering user-generated video content(SberZvukTechDays)Filtering user-generated video content(SberZvukTechDays)

Filtering user-generated video content(SberZvukTechDays) Table of contents General info Team members Technologies Setup Result General info This is a

Comments
  • Sending more variables with the

    Sending more variables with the "Generator"

    import os
    from thumb_gen import Generator
    
    folder = 'C:/input'
    for video in os.listdir(folder):
        if video.endswith('.mp4') or video.endswith('.mkv'):
            app = Generator(os.path.join(folder, video), custom_text=False, font_dir="C:/Project/font.ttf", font_size=25, bg_colour='blue', font_colour='red')
            app.run()
    

    This code is very useful, but I want to send more veriables, eg: row size of images, or columns size of images.

    Another issue is with custom text. Custom text is under images when it's too long.

    opened by metin02oktay 2
  • [Feature] Adding more formats as compatible.

    [Feature] Adding more formats as compatible.

    Hi there, thanks for this nice script. I've modified it to work with more formats, the only problem I've found where the 4 digit extensions of "webm", it seems the script used self.output_path = self.video_path[:-4] which removed 4 last characters to add a new extension ("." included). The webm extension has 4 letters + 1 ".", meaning that output thumb files where named "file..jpg" if they where made from a .webm source (this is because self.output_path = self.video_path[:-4] would not remove the "." character)

    Here are the small modifications I've made in case you want to modify the script:

    worker.py:

    
            if output_path == '':
                if video_path.endswith('webm'):
                    self.output_path = self.video_path[:-5]
                    self.output_folder = listToString(re.split(pattern = r"[/\\]", string = self.video_path)[:-1], "sys")
                else:
                    self.output_path = self.video_path[:-4]
                    self.output_folder = listToString(re.split(pattern = r"[/\\]", string = self.video_path)[:-1], "sys")
    
            else:
                if video_path.endswith('webm'):
                    self.filename = re.split(pattern = r"[/\\]", string = self.video_path)[-1]
                    self.output_path = os.path.join(output_path, self.filename[:-5])
                    self.output_folder = self.output_path
                else:
                    self.filename = re.split(pattern = r"[/\\]", string = self.video_path)[-1]
                    self.output_path = os.path.join(output_path, self.filename[:-4])
                    self.output_folder = self.output_path
    
    

    main.py:

    def check_files(paths_or_files):
        videos = []
        current_directory = os.getcwd()
    
        for path_or_file in paths_or_files:
            if not os.path.exists(path_or_file):
                if not os.path.exists(os.path.join(current_directory, path_or_file)):
                    sys.exit("{}: no such file or directory".format(path_or_file))
                else:
                    real_path = os.path.join(current_directory, path_or_file)
            else:
                if os.path.isfile(path_or_file):
                    real_path = path_or_file
                else:
                    real_path = os.path.join(current_directory, path_or_file)
    
            if os.path.isfile(real_path):
                if real_path.endswith(('mp4', 'mkv', 'm4v', 'webm', 'avi', 'wmv')):
                    videos.append(real_path)
                else:
                    sys.exit("{}: file not supported".format(real_path))
            elif os.path.isdir(real_path):
                for file in os.listdir(real_path):
                    if file.endswith(('mp4', 'mkv', 'm4v', 'webm', 'avi', 'wmv')):
                        videos.append(os.path.join(real_path, file))
                if videos == []:
                    sys.exit("{}: all of files in the directory are not supported".format(real_path))
    
        return videos
    
    opened by masterofobzene 0
Releases(v4.0.1)
Owner
Tharindu N.
¯\_(ツ)_/¯
Tharindu N.
Converts Betaflight blackbox gyro to MP4 GoPro Meta data so it can be used with ReelSteady GO

Here are a bunch of scripts that I created some time ago as a proof of concept that Betaflight blackbox gyro data can be converted to GoPro Metadata F

null 108 Oct 5, 2022
Python retagging utility for mkv files using mkvmerge.

pyretag A python script to retag mkv files. Setting Up pip install pyfiglet pip install rich Move the mkv files to input folder.

null 25 Dec 4, 2022
A youtube video link or id to video thumbnail python package.

Youtube-Video-Thumbnail A youtube video link or id to video thumbnail python package. Made with Python3

Fayas Noushad 10 Oct 21, 2022
Video-to-GIF-Converter - A small code snippet that can be used to convert any video to a gif

Video to GIF Converter Project Description: This is a small code snippet that ca

Hassan Shahzad 3 Jun 22, 2022
OpenShot Video Editor is an award-winning free and open-source video editor for Linux, Mac, and Windows, and is dedicated to delivering high quality video editing and animation solutions to the world.

OpenShot Video Editor is an award-winning free and open-source video editor for Linux, Mac, and Windows, and is dedicated to delivering high quality v

OpenShot Studios, LLC 3.1k Jan 1, 2023
MoviePy is a Python library for video editing, can read and write all the most common audio and video formats

MoviePy is a Python library for video editing: cutting, concatenations, title insertions, video compositing (a.k.a. non-linear editing), video processing, and creation of custom effects. See the gallery for some examples of use.

null 10k Jan 8, 2023
video streaming userbot (vsu) based on pytgcalls for streaming video trought the telegram video chat group.

VIDEO STREAM USERBOT ✨ an another telegram userbot for streaming video trought the telegram video chat. Environmental Variables ?? API_ID : Get this v

levina 6 Oct 17, 2021
Terminal-Video-Player - A program that can display video in the terminal using ascii characters

Terminal-Video-Player - A program that can display video in the terminal using ascii characters

null 15 Nov 10, 2022
Techie Sneh 17 Nov 23, 2021
This is a simple script to generate a .opml file from a list of youtube channels.

Youtube to rss Don't spend more time than you need to on youtube.com This is a simple script to generate a .opml file from a list of youtube channels.

Kostas 1 Oct 4, 2022