Skip to content

This is a command line interface to make datamoshing easy and accesible to everyone!

Notifications You must be signed in to change notification settings

NickAnastasoff/Data-Mosha

Repository files navigation

Easy datamoshing with Python!

This is a command line interface to make datamoshing easy and accesible to everyone!

This repo is built off of tiberiuiancu/datamoshing and itsKaspar/tomato, so thanks for the awesome code!

Command Line Interface

Quick start!

Make sure you have downloaded all the requirements!

Run pip install -r requirements.txt

mosh.py requires ffmpeg to be installed.

vector_motion.py and style_transfer.py depend on ffedit and ffgac, which can be downloaded from ffglitch.org

Don't forget to add those 3 files to your path!

If you are using vscode and the file won't play, try playing it outside of vscode!

Effects you can achieve

i-frame removal

This type of glitch creates the transition effect. Example:

Original Moshed
original_hand moshed_hand

p-frame duplication

Repeats a series of p-frames (aka delta frames), which can give a 'melting' effect

Original Moshed
original_dog moshed_dog

Vector motion

While the previous effects copy and delete whole frames, this one changes the actual frame data. As explained in this article on ffglitch.org, you need to write a custom JavaScript file that can change the frame data. vector_motion.py is just a wrapper for ffedit and ffgac and makes moshing possible through only one command. Example:

WARNING No matter what name the output file has, it will always be of type mpg (and because we glitched it, video players will probably have trouble reading its length). To convert it to mp4, you can use ffmpeg:

$ ffmpeg -i input.mpg output.mp4

It will complain about corrupt p-frame data, but the result should look the same as in the mpg.

Vector motion with Python

If you prefer to use python to glitch the frames, you can specify a python script for the -s argument (see previous section for usage). The script must contain a function called mosh_frames that takes as argument an array of frames (warning: some of the frames might be empty), where each non-empty frame represents a 3D array of shape (height, width, 2). The function should return an array of the same shape, representing the modified vectors. For reference, I have included two examples:

horizontal_motion_example.py contains the equivalent python code of the js script from this ffglitch tutorial.

average_motion_example.py is the equivalent of ffglitch average motion tutorial using numpy. Neat!

Style transfer

This means combining the motion vectors of two videos, by simply adding them together (see example below). Note that if the videos do not have the same resolution (and framerate), the results might not look as desired.

extracts vector data from clouds.mp4, transfers it to trees.mp4.

Extract style from Transfer style to Result
clouds trees ct

About

This is a command line interface to make datamoshing easy and accesible to everyone!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages