Giter VIP home page Giter VIP logo

moshpit's Introduction

moshpit

A command-line tool for surgical I-Frame removal, so-called datamoshing.
Comes with built-in scene cut detection for optimal results.

tutorial original moshed

Table of contents

Installation

Aside from the moshpit binary, which can be downloaded from the releases page, you need a copy of FFmpeg installed on your machine.

Usage

Arguments

moshpit [options] <file>

moshpit takes the video file you want to mosh as the last argument.

Option Description Default
-ffmpeg Specifies the location of the FFmpeg binary. ffmpeg
-log Specifies the target location of the FFmpeg log file. no logging

Commands

After starting moshpit, you can use the following commands to create a datamoshed video:

scenes

scenes <threshold>

Datamoshing via I-Frame removal yields the best results when applied at scene cuts. The scenes command finds scene cuts in the input file, using the threshold parameter to determine the similarity of each frame with the preceding frame.

A threshold of 0.2 usually gives good results.

mosh

mosh <output> <frame> [frame...]

Moshes the input file, writing it to the specified output file.
I-Frame removal is performed at the given frame indices, with scene cuts previously detected using the scenes command being suggested.
Using all as a frame parameter performs I-Frame removal at all previously detected scene cuts.

exit

Exits moshpit.
Moshpit can also be terminated at any time using Ctrl+C (SIGINT).

How it works

The theory behind datamoshing

Source

Modern compressed video files have very complex methods of reducing the amount of storage or bandwidth needed to display the video. To do this most formats, such as the AVI format, don't store the entire image for each frame.

Frames which store an entire picture are called I-frames (Intra-coded), and can be displayed without any additional information.

Frames which don’t contain the entire picture require information from other frames in order to be displayed, either previous or subsequent frames, these frames are called P-frames (Predicted) and B-frames (Bi-predictive). Instead of storing full pictures, these P-frames and B-frames contain data describing only the differences in the picture from the preceding frame, and/or from the next frame, this data is much smaller compared to storing the entire picture — especially in videos where there isn’t much movement.

When a video is encoded, or compressed, a combination of these types of frames are used. In most cases this means many P-frames with I-frames interspersed at regular intervals and where drastic visual changes in the video occur. More information on frame types can be found here.

If an I-frame is corrupted, removed or replaced, the data contained in the following P-frames is applied to the wrong picture. In the above video I-frames have been removed and so instead of scenes changing properly you see the motion from a new scene applied to a picture from a previous frame. This process of corrupting, removing or replacing I-frames is the video datamoshing technique that moshpit uses.

What moshpit does

When running the mosh command, moshpit converts the input file into an AVI file, placing I-Frames only at the frames specified by the user. This is done because single frames can be very easily identified and changed in the AVI format.

Each of the I-Frames in the resulting AVI file is then replaced with the next P-Frame, which means that the moshed video has the same duration as the original video, as opposed to removing the I-Frames, which would cause the moshed video to be shorter.

Finally, the moshed AVI file is "baked", which means it's converted back into an MP4 file, persisting the artifacts in the AVI file into a stable video file.

Building from source

go get github.com/CrushedPixel/moshpit/cmd/moshpit

moshpit's People

Contributors

crushedpixel avatar makew0rld avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.