LennyPenny / h264_glitcher

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Prepare Videos

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

Run glitcher

cargo run --release -- -i videos/* |  mpv --no-correct-pts --fps=1000 --no-cache -

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

OSC messages

  • /fps <float> Set frames per second.
  • /record_loop <bool> Loop recording start when true is sent and stops when false is sent. After recording the loop immediately starts playing.
  • /play_loop <bool> Play previously recorded loop.
  • /pass_iframes <bool> Lets I-frames through, disabling the glitch effect.
  • /video_num <int> Loads the n-th video in the list of videos given to --input.

Ideas

  • Fluid speed control, turntable style
  • Video selection UI with thumbnails, groups of videos
  • Recurse directories as input

Todos

  • Find out why video sometimes stutters when switching

About


Languages

Language:Rust 97.4%Language:Python 1.6%Language:Shell 1.0%