Skip to content

Generates preview videos and GIFs from videos using FFmpeg CLI in batch

License

Notifications You must be signed in to change notification settings

Tetrax-10/batch-preview-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Batch Preview Generator

Generates preview videos and GIFs from videos using FFmpeg CLI in batch.

Installation

Download and install the Latest version from the releases page. Done 🎉.

If you dont have FFmpeg installed then download the FFmpeg included version or download FFmpeg from here.

Demo

PSY - GANGNAM STYLE music video to this 15 seconds preview 👇

demo preview


Run preview in terminal without any arguments (flags) to initiate interactive prompts.

demo preview Note: This Screenshot reflects initial release and new changes may not be represented.


CLI docs

You can use this as a CLI by just giving a valid argument(s).

The above Gangnam Style gif can be created with this command.

preview -p "Gangnam Style.mp4" -s 15 -sk 7.0 -sp -g

Arguments

args Full args Description Default Type
-p --path Path of the video or folder for batch processing CWD string
-o --out Output folder for generated previews CWD string
-r --resolution Preview video resolution 360 int
-s --segments No. of segments in a preview video 10 (check code) int
-sd --sduration Duration of a segment 1.0 (0.1 - n.n) float
-sk --skip Skips the first n seconds of a video, mainly used to skip intros and filler. For movies, set this value higher according to the intro duration 20 float
-sp --samepath When passing this argument, the output folder is set to the input folder. when using this the --out path should be relative present or not
-a --audio Previews will be generated with audio present or not
-g --gif Previews will be generated in the GIF format (takes more time & space) present or not
-f --fps Preview video FPS mp4:24/gif:10 int
-q --quality Preview video quality (low, normal, high) normal string
-c --compression Preview video compression modes:
fast but low quality output and bigger file size.
slow gives good quality and reasonable size but little slower.
veryslow gives best quality and least file size but its very slow.
slow string
-cli --cli Run as a CLI without changing default arguments. If no arguments are provided, the program will act in prompt mode. To prevent that, you can use this flag present or not
-cuda --cuda Uses cuda cores for fast processing (Nvidia GPUs only) present or not
-v --version Prints version info present or not
-h --help Lists all commands with its description present or not

If you want to run this as a CLI without providing or changing default arguments then just run

preview -cli

FAQ

1. What are segments -s, --segments?

Segments are small videos extracted from the input video with a duration specified by --sduration. For example, if you set --segments to 10 and --sduration to 2, each segment will be 2 seconds long. Therefore, the total duration of the preview will be 20 seconds, as 10 segments each contribute 2 seconds.

2. From which part of the video are the segments extracted?

Let's say you set --segments to 3 and --sduration to 5. In this scenario, the input video is evenly split into 3 parts, and the first 5 seconds from each part are extracted for previews. Subsequently, these segments are concatenated and converted into a single video or gif. Thus the resulting preview will be of 5x3 = 15 seconds.

The red parts are extracted for previews

segments


Development

Environment setup
git clone https://github.com/Tetrax-10/batch-preview-generator.git
cd batch-preview-generator
pip install -r requirements.txt
Run
python preview.py <args>
Build executable
pyinstaller preview.spec

Make sure to add your "dist" folder to the PATH so that when you run preview, it refers to your "dist" executable. Additionally, also ensure that the path of the installed "preview.exe" is removed during development.

The installer is compiled with the Inno Setup Compiler, and there's no need to perform this step during the development of Batch Preview Generator, as it is only used for distribution


Known bugs

  1. When this program is installed and uninstalled it leaves this string ";;" in PATH environmental variable, it's not an issue as it doesn't affect the env vars but its a bloat, So please help me fix this as I'm not good with Inno Setup Compiler

Assist required

  1. Help me implement H/W acceleration for Radeon graphics as I don't have an AMD gpu.
  2. Help me to build/test executable for linux and mac os.
  3. Help me fix the known bugs.

Support

Like This Tool? Gimme Some ❤️ by Liking this Repository.