“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 * 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. [[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]] [[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 * installation, configuration, operation, etc
install (mac)... install (macOS)…
#+BEGIN_SRC text #+BEGIN_SRC text
brew install ffmpeg drracket brew install ffmpeg drracket
git clone https://github.com/zzkt/slitscan.git git clone https://github.com/zzkt/slitscan.git
#+END_SRC #+END_SRC
install (debian/ubuntu)... install (debian/ubuntu)
#+BEGIN_SRC text #+BEGIN_SRC text
sudo apt install ffmpeg racket sudo apt install ffmpeg racket
git clone https://github.com/zzkt/slitscan.git git clone https://github.com/zzkt/slitscan.git
#+END_SRC #+END_SRC
simple transform... simple transform
#+BEGIN_SRC text #+BEGIN_SRC text
racket slitscan.rkt -v -i <input.mp4> racket slitscan.rkt -v input.mp4
#+END_SRC #+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 #+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 #+END_SRC
options... options
#+BEGIN_SRC text #+BEGIN_SRC text
slitscan [ <option> ... ] slitscan [ <option> ... ] <video-file>
where <option> is one of where <option> is one of
-v, --verbose : various verbose messages -v, --verbose : various verbose messages
-l <level>, --loglevel <level> : loglevel for ffmpeg e.g. quiet, error, warning, info, debug -l <level>, --loglevel <level> : loglevel for ffmpeg e.g. quiet, error, warning, info, debug
-c, --cleanup : Clean up temporary/working files -c, --cleanup : Clean up temporary/working files
-n, --noresize : do not resize the input file
--horizontal : output a horizontal video only (default: both) --horizontal : output a horizontal video only (default: both)
--vertical : output a vertical video only (default: both) --vertical : output a vertical video only (default: both)
--width <pixels> : width of output output video --width <pixels> : width of transform video
--height <pixels> : height of output output video --height <pixels> : height of tansform video
-i <video>, --input <video> : input file -f <folder>, --in-folder <folder> : input folder
-f <folder>, --folder <folder> : input folder -o <folder>, --out-folder <folder> : output folder
--help, -h : Show this help --help, -h : Show this help
#+END_SRC #+END_SRC

View file

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