Skip to content

antonxy/h264_glitcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Live H264 Glitcher

Creates glitch effects in H.264 encoded videos by removing keyframes, combining videos, looping intermediate frames.

Can be controlled via OSC.

demo.mp4

Using the Glitcher

Prepare Videos

Videos have to be in a folder with the following structure:

videos/
    original/  # Used by the doit script
        video1.mp4
    encoded/
        video1.h264
    thumbnails/
        video1.png

You can copy the the doit script in scripts/dodo.py to your videos folder and use it to encode all videos in the original folder. Doit stores hashes of files it already processed so it will only encode new or changed videos again.

pip install doit
cp scripts/dodo.py videos/
cd videos
doit

Run glitcher

cargo run --release -- --input-dir videos/ |  mpv --no-correct-pts --fps=1000 --no-cache -

We had reports of crashing AMD GPUs when using hardware decoding. If you are experiencing problems add --hwdec=no to your mpv command.

Use the --prefetch option to load all videos into RAM. Takes longer to start, but makes video switching much smoother.

By default the glitcher listens on port 8000 for OSC messages.

Control using OpenStageControl

Install OpenStageControl.

You can load our pre-made OpenStageControl session.

Example network config for a tablet controlling the glitcher running on a laptop:

Technical info

OSC messages

Instead of using our pre-made OpenStageControl session you can also send OSC commands yourself.

We are constantly experimenting with different commands and features ;). Please refer to the State::default struct initialization in src/bin/h264_glitcher.rs as well as the osc_listener function for the list of currently implemeted OSC commands.

Video Encoding

Use ffmpeg to convert the videos to a raw h264 stream

ffmpeg -i video.mp4 video.h264

It can also be helpful encode all input videos the same way, otherwise transitions between videos don't work properly. These settings have an effect on the glitch effects look in general and could probably be optimized still. They also have an effect on how likely mpv is to lock up when switching videos.

ffmpeg -i video.mp4 -c:v libx264 -vf format=yuv420p,scale=1920:1080 -qp 30 -x264-params bframes=0:refs=1:g=9999999 video.h264

libx264 options Potentially interesting parameters:

  • bframes=0 Disable B-frames
  • refs=1 allow max 1 reference frames for p-frames
  • g=9999999 No keyframes inbetween

Maybe also useful: https://encodingwissen.de/codecs/x264/referenz/

potentially interesting x264 options: partitions, tune=zerolatency

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •