Removes every reference frames from a video, except the first one.
You’ll need a working installation of Python 3, and FFmpeg. Make sure they are in PATH.
Download or clone this repository:
git clone https://github.com/ychalier/datamoshing.git
cd datamoshing/drop-h264-iframes/
Install the requirements:
pip -m install requirements.txt
Simply execute the main script:
python drop_h264_iframes.py full <source-video> <output-video>
Source and output videos can be of any type, as they will be converted to h264, using FFmpeg, during the process.
You can pass different actions strings to perform different things:
Action | Description |
---|---|
preprocess |
Convert the source video to h264 and analyse its NAL units |
rebuild |
Rebuild a video from the h264 source and the NAL units analysis |
full |
Pipeline doing preprocess and rebuild |
split |
Analyse the NAL units of a h264 video |
probe |
Use FFprobe to analyse frames of a video |
You can pass FFmpeg compression arguments that will be applied during conversion to h264. They will impact the result of the datamoshing.
Argument | Default | Description |
---|---|---|
--sc-threshold |
40 |
Scenecut detection threshold |
--g |
250 |
Maximum frames between two I-Frames |
--keyint-min |
25 |
Minimum frames between two I-Frames |
--bf |
0 |
Maximum frames between two B-Frames |
--profile |
main |
Encoding profile |
--level |
4.0 |
Quality level |
--crf |
23 |
Balance between quality and compression |
For a good effect, you may want to concatenate videos clips together. This can be done using FFmpeg.
file 'first.mp4'
file 'second.mp4'
file 'third.mp4'
ffmpeg -f concat -safe 0 -i .\list.txt -c copy output.mp4
There’s more information on FFmpeg’s documentation.
I wrote some details on my blog.
The resulting video may stutter if too many frames are dropped. It it less noticeable with high FPS videos. Unless I get to time travel, I will probably not address it.