I'd like to try to do some datamoshing like this tutorial. But I'd like to be able to do it programatically, so instead of vdub and avidemux, I'd like to figure out how to do as many parts of this process as I can with ffmpeg and/or other command-line tools.

The first problem I am having is that when I use the ffdshow codec rev 3556 with VDub it just outputs a broken video. I feel like I got close to getting what I want, which is frame 0 as an I-frame and all the rest as P-frames with the following command

ffmpeg -i input.mp4 -force_key_frames 00:00:00.000 output.avi

There are a couple of problems with this:

  1. I get B-frames too, which don't work with that type of data-moshing

  2. There's still I-frames every 10 or so frames

I feel like the problem is that I need to use a certain codec to encode the video in and also that -force_key_frames probably just enforces the addition of extra keyframe(I-frames) but doesn't prevent other I-frames from being created.


What you want is a very long GOP or I-frame interval. I believe the ffmpeg option -g nnnn will do that, where nnnn is the length of your video in frames. I don't know how to specify "no B-frames", and this will certainly all be codec-dependent. Give it a try.


The first frame of a video from any codec will always be an I frame. There is no previous picture for other frame types to use as a reference.

B frames might still work. The video will start to distort ahead of the cut point, too, if any B frames are trying to reference a future frame that's not there anymore. Actually, with B frames present, display order differs from decode order, and the h.264 stream is always stored in decode order.

Anyway -x264opts bframes=0:keyint_min=250 would force the minimum GOP size to 250 frames, and disallow use of B frames. keyint sets the max GOP size. (By default, x264 does scenecut detection for placing I frames, so if you want I frames at scenecuts, you might do well to leave it as-is.)

Err, is that tutorial using ffmpeg's MPEG4-part2 encoder? (the same format as divx/xvid). In that case, nvm. My instructions were for -c:v libx264.

Look at the output of ffmpeg -h encoder=mpeg4 | less, and search for stuff you want to set. There will be command line options for most everything. e.g. -bf 0 to set no B frames. ffmpeg -codecs for a list of codecs, or even ffmpeg -h full. Also google / check the manual

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.