Showing posts with label 日本. Show all posts
Showing posts with label 日本. Show all posts

FFmpeg: Colour animation from macroblock motion-vectors



The animation is created from styling the macroblock motion vectors, as displayed by FFmpeg, rather than by manipulating the actual video content. The blocks of colour are created by stacking 'dilation' filters on the motion-vector layer. Before being dilated, the colouring of the arrows is extracted from the original video by 'colorkey' overlay. Based on an earlier filtergraph experiments.¹

#!/bin/bash 
# Generate stylised animation from video macroblock motion vectors, 
# and present in a side-by-side comparison with original video. 
# version: 2018.03.28.21.08.16 
# source: https://oioiiooixiii.blogspot.com 

cropSize="640:ih:480:0" # Adjust area and dimensions of interest

ffplay \
   -flags2 +export_mvs \
   -i "$1" \
   -vf \
      "
         split [original][vectors];
         [vectors] codecview=mv=pf+bf+bb,
                   crop=$cropSize [vectors];
         [original] crop=$cropSize,
                    split=3 [original][original1][original2];
         [vectors][original2] blend=all_mode=difference128,
                              eq=contrast=7:brightness=-0.3,
                              split [vectors][vectors1];
         [vectors1] colorkey=0xFFFFFF:0.9:0.2 [vectors1];
         [original1][vectors1] overlay,
                               smartblur,
                               dilation,dilation,dilation,dilation,dilation,
                               eq=contrast=1.4:brightness=-0.09 [pixels];
         [vectors][original][pixels] hstack=inputs=3
      "



¹ see also: https://oioiiooixiii.blogspot.com/2016/09/ffmpeg-create-video-composite-of.html
source video: りりあ (LILIA)https://www.youtube.com/watch?v=U1DFzSlNkV8 (used without permission) m(_ _)m

【足太ぺんた】 (Asibuto Penta): Painting 2017 (preliminary work)

A screen-capture of showing an early stage of the background being painted in GIMP.















The last lineup of layouts to choose between for the final version.

context: Final Painting https://oioiiooixiii.blogspot.com/2018/01/asibuto-penta-painting-2017.html

【中森明菜】:『少女A』(Akina Nakamori: "Girl A") - 1982, November 25th


source video: https://www.youtube.com/watch?v=kO2meEexNsE

How-to: Progressive chroma glitching with MPlayer


These are some notes on the procedure to create and record the video glitching effects documented previously: http://oioiiooixiii.blogspot.com/2014/09/mplayer-loop-entropy.html

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: https://youtu.be/TpIM5Vp00c4
original source video: https://youtu.be/nr_-mARA--8?t=2m18s