“The odd uneven time.“

This commit is contained in:
nik gaffney 2020-02-27 16:38:00 +11:00
parent 08970dfa47
commit 3e18b28365
2 changed files with 60 additions and 46 deletions

View file

@ -1,51 +1,52 @@
* time, space, stacking, slicing, scanning, etc
"Slitscan imaging techniques are used to create static images of time-based phenomena. In traditional film photography, slit scan images are created by exposing film as it slides past a slit-shaped aperture. In the digital realm, thin slices are extracted from a sequence of video frames, and concatenated into a new image."
Slitscan imaging techniques are used to create static images of time-based phenomena. In traditional film photography, slit scan images are created by exposing film as it slides past a slit-shaped aperture. In the digital realm, thin slices are extracted from a sequence of video frames, and concatenated into a new image.
[[http://www.flong.com/texts/lists/slit_scan/][An Informal Catalogue of Slit-Scan Video Artworks and Research]] Compiled by Golan Levin.
[[slitscope_0.jpeg]]
This particular slitscan provides some slightly configurable scaffolding around ffmpeg (based on a blogpost from [[http://oioiiooixiii.blogspot.com/2017/11/ffmpeg-temporal-slice-stacking-effect.html][oioiiooixiii]]) and is intended for non-realtime rendering at various resolutions. it's neither first, nor last. it's not especially interesting, educational or efficient. just another cloudform in the endless space of possible implementation...
This particular slitscan provides some slightly configurable scaffolding around ffmpeg (based on a blogpost from [[http://oioiiooixiii.blogspot.com/2017/11/ffmpeg-temporal-slice-stacking-effect.html][oioiiooixiii]]) and is intended for non-realtime rendering at various resolutions. it's neither first, nor last. it's not especially interesting, educational or efficient. just another cloudform in the endless space of possible implementation
* installation, configuration, operation, etc
install (mac)...
install (macOS)…
#+BEGIN_SRC text
brew install ffmpeg drracket
git clone https://github.com/zzkt/slitscan.git
#+END_SRC
install (debian/ubuntu)...
install (debian/ubuntu)
#+BEGIN_SRC text
sudo apt install ffmpeg racket
git clone https://github.com/zzkt/slitscan.git
#+END_SRC
simple transform...
simple transform
#+BEGIN_SRC text
racket slitscan.rkt -v -i <input.mp4>
racket slitscan.rkt -v input.mp4
#+END_SRC
transform at 1080p and delete working files, with minimal command line noise...
transform at 1080p and delete working files, with minimal command line noise
#+BEGIN_SRC text
racket slitscan.rkt --width 1920 --height 1080 --loglevel quiet --cleanup -i <input.mp4>
racket slitscan.rkt --width 1920 --height 1080 --loglevel quiet --cleanup input.mp4
#+END_SRC
options...
options
#+BEGIN_SRC text
slitscan [ <option> ... ]
slitscan [ <option> ... ] <video-file>
where <option> is one of
-v, --verbose : various verbose messages
-l <level>, --loglevel <level> : loglevel for ffmpeg e.g. quiet, error, warning, info, debug
-c, --cleanup : Clean up temporary/working files
-n, --noresize : do not resize the input file
--horizontal : output a horizontal video only (default: both)
--vertical : output a vertical video only (default: both)
--width <pixels> : width of output output video
--height <pixels> : height of output output video
-i <video>, --input <video> : input file
-f <folder>, --folder <folder> : input folder
--width <pixels> : width of transform video
--height <pixels> : height of tansform video
-f <folder>, --in-folder <folder> : input folder
-o <folder>, --out-folder <folder> : output folder
--help, -h : Show this help
#+END_SRC

View file

@ -25,7 +25,7 @@
;;;
;;; Requirements
;;;
;;; Racket, ffmpeg and zsh or bash (probably)
;;; Racket, ffmpeg and zsh or bash (and probably works with other shells)
;;;
;;; Commentary
;;;
@ -43,10 +43,12 @@
;; cli options
(define filename (make-parameter ""))
(define verbose? (make-parameter #f))
(define cleanup? (make-parameter #f))
(define filename (make-parameter "untitled"))
(define input-folder (make-parameter ""))
(define noresize? (make-parameter #f))
(define in-folder (make-parameter ""))
(define out-folder (make-parameter ""))
(define loglevel (make-parameter "")) ;; leave unset by default
;; output options horiz/vert/both
@ -61,17 +63,21 @@
(command-line
#:program "slitscan"
#:once-each
(("-v" "--verbose") "various verbose messages" (verbose? #t))
(("-l" "--loglevel") level "loglevel for ffmpeg e.g. quiet, error, warning, info, debug" (loglevel level))
(("-c" "--cleanup") "Clean up temporary/working files" (cleanup? #t))
(("--horizontal") "output a horizontal video only (default: both)" (hout-only? #t))
(("--vertical") "output a vertical video only (default: both)" (vout-only? #t))
(("--width") pixels "width of transform video" (output-width pixels))
(("--height") pixels "height of tansform video" (output-height pixels))
(("-i" "--input") video "input file" (filename video))
(("-f" "--folder") folder "input folder" (input-folder folder))
#:args () ; rest of the args?
(printf "slitscanning: ~a\n" (filename))))
(("-v" "--verbose") "various verbose messages" (verbose? #t))
(("-l" "--loglevel") level "loglevel for ffmpeg e.g. quiet, error, warning, info, debug" (loglevel level))
(("-c" "--cleanup") "Clean up temporary/working files" (cleanup? #t))
(("-n" "--noresize") "do not resize the input file" (noresize? #t))
(("--horizontal") "output a horizontal video only (default: both)" (hout-only? #t))
(("--vertical") "output a vertical video only (default: both)" (vout-only? #t))
(("--width") pixels "width of transform video" (output-width pixels))
(("--height") pixels "height of tansform video" (output-height pixels))
(("-f" "--in-folder") folder "input folder" (in-folder folder))
(("-o" "--out-folder") folder "output folder" (out-folder folder))
#:args (video-file) ; rest of the args?
(filename video-file)
(if (file-exists? (filename))
(printf "slitscanning: ~a\n" (filename))
(raise-user-error 'slitscan "File '~a' does not exist." (filename)))))
;; emulation of $(...) shell syntax
(define-syntax zout
@ -87,11 +93,11 @@
((and (not (verbose?)) (string=? "" (loglevel))) (loglevel "error")))
;; variables/various
(define folder (if (not (string=? "" (input-folder)))
(input-folder)
(define folder (if (not (string=? "" (in-folder)))
(in-folder)
(zout "mktemp -d")))
(vecho "using folder: ~a\n" folder)
(vecho "using folder '~a' for input\n" folder)
;(define fffeature "ffprobe -v quiet -select_streams v -of default=noprint_wrappers=1:nokey=1 -show_entries stream=")
@ -99,10 +105,10 @@
;; assume most/all codecs/formats/streams have a duration
(define duration (let ((f (string->number
(zout (format
"~aduration \"~a\""
fffeature (filename))))))
(if f f 0)))
(zout (format
"~aduration \"~a\""
fffeature (filename))))))
(if f f 0)))
(vecho "duration: ~a seconds\n" duration)
@ -117,10 +123,10 @@
;; number of frames. estimate for codecs/formats/streams without nb_frames
(define frames (let ((f (string->number
(zout (format
"~anb_frames \"~a\""
fffeature (filename))))))
(if f f (ceiling (* duration fps)))))
(zout (format
"~anb_frames \"~a\""
fffeature (filename))))))
(if f f (ceiling (* duration fps)))))
(vecho "frames: ~a\n" frames)
@ -143,10 +149,11 @@
;; rezise video
(define resized-video (string-append folder "/resized.mkv"))
;; resize video, or copy file if 'noresize?' option is set
(define (resize)
(define ffmpeg-r1
(format "ffmpeg -loglevel ~a -i \"~a\" -vf ~a -crf 10 \"~a\" 2>&1 | grep 'frame=' | tr \\n \\r; echo"
(loglevel) (filename) scale resized-video))
(loglevel) (filename) scale resized-video))
(vecho "resizing video: ~a\n" resized-video)
(system ffmpeg-r1))
@ -199,12 +206,12 @@
(define ffmpeg-a1 ;; horizontal frame stack
(format
"ffmpeg -loglevel ~a -r ~a -i ~a/horz_frame%d.png \"~a_horizontal-smear.mkv\""
(loglevel) fps folder (filename)))
(loglevel) fps folder (filename)))
(define ffmpeg-a2 ;; vertical frame stack
(format
"ffmpeg -loglevel ~a -r ~a -i ~a/vert_frame%d.png \"~a_vertical-smear.mkv\""
(loglevel) fps folder (filename)))
(loglevel) fps folder (filename)))
;; assemble
(cond ((hout-only?) (system ffmpeg-a1))
@ -234,10 +241,16 @@
(vecho "leaving working files at ~a\n" folder)))
;; output in 3 (or 4 (or 5)) steps
(define (slitscan)
(when (resize) (printf "resized\n"))
(when (slice) (printf "sliced\n"))
(when (assemble) (printf "assembled\n"))
(when (cleanup) (printf "done\n")))
(when (resize) (printf "resized\n"))
(when (slice) (printf "slicwd\n"))
(when (assemble) (printf "assembled\n"))
(when (cleanup) (printf "done\n"))
;; (printf "The file '~a' does not exist.\n" (filename))
(slitscan)
;;; FIN