Datamoshing-with-Avidemux

How to datamosh videos

Datamoshing is the process of intentionally damaging media files with the goal of creating interesting distortion effects during playback. In some cases the term datamoshing is used to describe this process applied to any type of media file — I like to think it applies solely to video since it results in moving images being moshed together. Regardless of the application of the term, datamoshing videos can be done quite easily with free, cross-platform tools.

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 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 a very popular video datamoshing technique and what this tutorial will focus on.

Another video datamoshing technique involves selecting one or more P-frames and duplicating them multiple times consecutively. This results in the same P-frame data being applied to one picture over and over again, accentuating the movement and creating what’s known as a Bloom effect.

For this tutorial we’ll be using Avidemux, a free, cross platform video editing application. Generally the effects of datamoshing are viewed as errors, or undesirable and thus applications like Avidemux try their best to correct these errors and eliminate glitching distortion. For this reason the latest version of Avidemux isn’t very good for datamoshing, but some older versions, such as 2.5.6, available here, work just fine.

After downloading and installing Avidemux 2.5.6 Open the video you want to mosh.

avidemux-open

Avidemux may show warnings depending on the type of file you’re using, select No and continue.

avidemux-h.264-detected

Once the video is loaded we’ll be making a small change to allow us to remove I-frames and still have a playable video. Under Video on the left side of the interface use the dropdown to change the selection from Copy to MPEG-4 ASP (Xvid).

Avidemux-Video

Next click the Configure button below the Video dropdown on the left. Select the Frame tab and then change the Maximum I-frame Interval from 300 to 99999999 then click OK. By changing this setting we’re allowing the video file to be played back even if it has unusually few I-frames, one every 99999999 frames.

Maximum-I-Frame-Interval

With this setting changed the video must be saved and then reloaded for it to take effect. Save the video with a new name to indicate that the Maximum I-frame Interval has been adjusted.

Avidemux-Save

Open the new video, select No if Avidemux displays any warnings. Once opened, change the Video dropdown on the left side of the interface back to Copy. We won’t be changing the encoding or any settings of the video at this point, we’re just going to remove I-frames and then Save it.

Avidemux-copy

To remove I-frames we use the slider at the bottom of the interface, it displays the current frame type below the video navigation buttons, you’ll mostly see Frame Type: I (00) and Frame Type: P (00). The first frame will most likely be an I-frame and should be left in so that the video can start properly. To locate other I-frames click on the slider tab/grip to focus the slider then press the Up Arrow on your keyboard to jump to the next I-frame, the Down Arrow will jump to the previous I-frame.

In order to remove an I-frame we must select it, this is done by marking an in point and an out point, these points are referred to as A and B in Avidemux and the frames of video between these two points are considered selected. Once you have found an I-frame click on the mark A button under the slider. You should see a blue border identify the new selection, starting at the slider grip and encompassing the remaining frames in the video.

Avidemux-A

Pressing delete now would delete the current I-frame and all subsequent frames so we have to reduce the selection to only the I-frame. This is done be pressing the Right Arrow key to move to the next frame and then clicking the mark B button below the slider. The blue selection border should update to show only the I-frame selected as illustrated below.

Avidemux-B

Now that only a single I-frame is selected press the Delete key on your keyboard to remove it. To remove all the I-frames use the Up Arrow to move to the next one and repeat the removal process. Try to avoid moving backwards through the video once you’ve removed I-frames as this can cause Avidemux to crash, stick to moving forward through the I-frames and removing them.

After you’ve removed one or more I-frames, Save the video and again select No if Avidemux prompts or warns you about something, smart copy for instance.

Avidemux-Enable-Smartcopy

Once the video is saved open it up in your favorite player and evaluate the havoc you’ve wrought upon it.

The video included in this post was datamoshed using this technique, however the audio was slowed down using traditional video editing.#corruptabsolutely

Windows

OSX

8 thoughts on “How to datamosh videos”

  1. hi, no idea why but i don’t hve the mpg-4 asp (xvid) in my version (Avidemux 2.5.6). Mac os x el capitan 10.11.6. searched for a codec pack but can’t find anything for mac. any help?

  2. Hey, so I get to the step where I switch it to (xvid) and then I save the new file. I re-open that file, but there are no I-Frames any longer. I can’t use the blue arrow to navigate around them, so I used the incremental blue arrows and it’s just a bunch of b’s and p’s.

    Am I doing something wrong? I switched the max to 99999999 and saved it as a new file and then run into this roadblock.

    1. Not sure what’s going on for you. Perhaps post in the forums with more detail. There are I-frames before saving as Xvid and absolutely non after?

  3. Hi,
    Nice tutorial, but I’m not able to proceed further…
    My Avidemux doesn’t have vid. output – MPEG 4 ASP (xvid).

    It only has MPEG4 ASP (xvid4) and that is completely different.
    šŸ™

    It makes datamoshing so hard.

Leave a Reply

Your email address will not be published. Required fields are marked *