How-to: Progressive chroma glitching with MPlayer

These are some notes on the procedure to create and record the video glitching effects documented previously:

Software used ------

POSIX o/s (GNU/Linux)
Avidemux (2.5.4)
MPlayer (1.1-4.8)
yuv2lav (mjpegtools)
ffmpeg (2.5.4)

Create video segment ------

1.   Open video file in Avidemux
2.   Disallow all attempts Avidemux makes to improve video editing (regarding frame accuracy).
      - This functionality has been "fixed" in later versions of Avidemux.
3.   Locate section of interest in video, and find nearest key-frame.
4.   Place start point one or more frames past this key-frame.
5.   Select endpoint, making sure the range contains no key-frames.
6.   Save video, with video output codec is set to "copy".
7.   Open video in MPlayer to test it, and include loop forever argument
      - $: mplayer saved_file.mp4 -loop 0
      - audio can be muted by including: -ao null

Capture MPlayer output -----

8.   Create a fifo named "stream.yuv"
      - $: mkfifo stream.yuv
9.   Pipe raw fifo stream to yuv2lav, which converts it to usable mjpeg
      - $: cat stream.yuv | yuv2lav -o glitched_video.avi &
10. Initialise MPlayer with finite amount of loops, and use yuv4mpeg as video output.
      - $: mplayer -nosound -noframedrop -vo yuv4mpeg saved_file.mp4 -loop 100
11. Both processes will end when MPlayer loop finishes.
12. Review outputted video, and delete fifo when done
      - $: rm stream.yuv

Decimate framerate ------

To reduce the run-time of video, allowing a quicker overview of the chromatic changes, the frame-rate of the video can be decimated with ffmpeg. In the example code below, the input video is played at 100fps and captured at 25fps as raw yuv video. Any choice of variables and codec can be used here (except copy).
     - $: ffmpeg -r:v "100/1" -i glitched_video.avi -an -vf fps="25/1" -vcodec huffyuv output.avi

* Steps 8 to 10 do not need to be run concurrently, doing so however, keeps disk space usage to a minimum.
** yuv2lav requires video dimensions to be a multiple of 16 (1280x720, 640x480 etc.). This can be overcome with MPlayer scaling arguments: -vf scale -zoom -x 768 -y 432
*** ffmpeg can be used to convert raw yuv video, however yuv2mpeg produces video in I420p colour space, which is not currently supported by ffmpeg. An ffmpeg solution for everything above would be desirable.

full length (100 loops) glitched video:
original source video: