Welcome to mkpreview documentation!¶
mkpreview¶
mkpreview builds a grid of images from a movie file. - Support for all video file types in FFMPEG. - It will create a SQLite3 database with all of the video meta dataparameters and create an MD5 hash of the file - It provides very basic support for creating video part numbers
Get Started!¶
Here’s how to set up mkpreview for local environment.
1- Clone the mkpreview locally:
$ git clone git@github.com:/mkpreview.git
2- Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up the package for local development:
$ sudo make boostrap
$ mkvirtualenv mkpreview
$ pip install -r requirements/dev.txt
3- How to enable/disable virtualenv
$ workon mkpreview
$ ...
$ deactivate
Credits¶
This package was generated using Yeoman and Cookiecutter projects.
Installation¶
Stable release¶
To install mkpreview, run this command in your terminal:
$ pip install mkpreview
This is the preferred method to install mkpreview, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources¶
The sources for mkpreview can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git@github.com:Studio-51/mkpreview.git
Once you have a copy of the source, you can install it with:
$ python setup.py install
Or you can use the follow command:
$ sudo make install # to install
$ sudo make uninstall # to uninstall
Dev Notes¶
How to use python virtualenv¶
$ workon <virtualenv_name>
$ [<virtualenv_name>] ...
$ deactivate
How to run unit test¶
$ make utest
How to run sytem test¶
$ sudo make install
$ make stest
$ sudo make uninstall
How to run unit test coverage¶
$ make coverage
How to run flake8 and pylint¶
$ make flake
$ make pylint
How to build a docker image¶
$ make docker-image
CLI Usage¶
Command Line Usage¶
- usage: mkpreview.py [-h] [–version] [-v] [-dr] [-d] [-q] [-w TILE_WIDTH]
- [-r TILE_ROWS] [-c TILE_COLS] [-b TILE_BK_COLOR] [-p TILE_FG_COLOR] [-i IN_FILE] [-o OUT_DIR] [-m] [-s DBFILE] [-create-new-db] [-override OVERRIDE] [-colors] [-studio-id STUDIO_ID] [-part-id PART_ID] [-hwaccel {cuda,videotoolbox}]
This program will create a video preview file of a given video
- optional arguments:
-h, --help show this help message and exit --version show program’s version number and exit -v, --verbose Turn on verbose output -dr, --dryrun Dryrun enabled no changes will occur -d, --debug Turn on Debugging Mode -q, --quiet No output is produced -w TILE_WIDTH, --tile-width TILE_WIDTH Tile width - Tiles are sqaure -r TILE_ROWS, --tile-rows TILE_ROWS Number of rows for a preview -c TILE_COLS, --tile-cols TILE_COLS Number of columns for a preview -b TILE_BK_COLOR, --tile-backgrond TILE_BK_COLOR Tile Background Color -p TILE_FG_COLOR, --tile-foreground TILE_FG_COLOR Tile Pen Color - -fs FONT_SIZE, –font-size FONT_SIZE
- Font size for text default is 24pt
-i IN_FILE, --input IN_FILE Video input, can by a file or directory. If directory, it will not be recursive -o OUT_DIR, --output-dir OUT_DIR Where to put the finished files -m, --md5 Add the MD5 of the file to the filename -s DBFILE, --store-db-file DBFILE Store the video information in SQLI3te file -create-new-db Create a new database file - -override OVERRIDE save image with this filename override all other
- possible choices
-colors Display List of Available Colors - -studio-id STUDIO_ID Replace the this id, first part of filename for a
- part-id use in conjunction with -part-id
-part-id PART_ID Change first alpha part of filename for the part-id -hwaccel {cuda,videotoolbox}
Enable Hardware acceleration for videotoolbox or cuda
The filename of the output will be the part_id-md5-originalBaseName.png. If the part_id and md5 are unset the filename will be the original base name.png
Example 1: sample¶
./mkpreview.py -i /Users/colinbitterfield/Downloads/WhatCarCanYouGetForAGrand.mp4 \
--output-dir /tmp/ --md5 --tile-width 320 --tile-rows 7 \
--tile-cols 7 --tile-background yellow \
--tile-foreground blue --font-size 60 \
--store-db-file /tmp/myDatabase.db \
-create-new-db -override previewcard
Results:

mkpreview¶
mkpreview package¶
Submodules¶
mkpreview.config module¶
Created on Jan 9, 2020
@author: colin bitterfield
A list of common definitions
mkpreview.database module¶
A database class to help with managing SQLite databases
-
class
mkpreview.database.
Database
(database, **kwargs)[source]¶ Bases:
object
Database class provides a higher level connector to SQLite3 It provides methods for:
Usage: myDB = Database(‘/tmp/filename.db’)
Methods: create() : Creates a Database or tests existence of database
: Allows the database to be backed up if it exists.name() : Returns the current database filename. Flag is true if the database exist connect() : Connects this class to the initialized database close() : Commits and Closes the current connection createTable() : Creates a table from a dictionary and adds primary indexes
: Allows overwrite (drop the data in the table)- insertORupdate(): Allows for an insert if not there and an update if there.
- : Uses a dictionary. Checks dictionary against columns to avoid errors
isTable() : Returns True if the tables exists backupTable() : Makes a copy of the table and renames it with a current timestamp dropTable() : Remove all of the data from the table sqlExecute() : Executes an arbitrary SQL Script against the open database. deleteData() : removes database based on table and where.
Variables: global DEBUG : Used for output global QUIET : User for output local message : Return Message for all methods local data(dict): A dictionary for method use. local flag : True / False for results of method self.database : database name for all methods self.method : calling method name self.class : name of the class being called self.db_connect : name of the connection
Returns: All methods return a [True | False] and a message If bad values are passed, it will fast fail and return a message. No further evaluations are made.
-
create
(**kwargs)[source]¶ overwrite = [True | False] backup = [True | False]
If database exists, with overwrite FALSE and backup FALSE, method exists with False If database does not exist it is created If database exists and overwrite without backup, it is deleted If database exists and backup is set, database will be backed up; regardless of overwrite.
FLAG = True if a database is created, False if a database is not created. MESSAGE = database name + actions taken
-
create_table
(**kwargs)[source]¶ create a table, optional drop if exists (default) If overwrite set to false, table will error if it exists
-
data
= {}¶
-
flag
= False¶
-
insert_update
(**kwargs)[source]¶ Insert a row or update the row with the field names in a dictionary parameters: ———– table = Table Name key_field = Field for initial update and where value key_value = Where Value data = Data to update
-
message
= ''¶
mkpreview.mkpreview module¶
mkpreview.version module¶
version string
Module contents¶
__init__ for mkpreview.
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at git@github.com:Studio-51/mkpreview.git/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
Python Boilerplate could always use more documentation, whether as part of the official Python Boilerplate docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at github repo.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up python_boilerplate for local development.
Fork the python_boilerplate repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/python_boilerplate.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv python_boilerplate $ cd python_boilerplate/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 python_boilerplate tests $ python setup.py test or py.test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check https://travis-ci.org/fgriberi/python_boilerplate/pull_requests and make sure that the tests pass for all supported Python versions.
Deploying¶
A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in HISTORY.rst). Then run:
$ bumpversion patch # possible: major / minor / patch
$ git push
$ git push --tags
Travis will then deploy to PyPI if tests pass.
Credits¶
Development Lead¶
- Colin Bitterfield <colin@bitterfield.com>
Contributors¶
None yet. Why not be the first?
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unrelease]
### Added
- added configuration information
- fixed production requirements
[Unrelease] TBD-link