;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; MOVIE PLAYS BACK AND FORTH
;;
;; This example plays a movie forwards and backwards
;; at the same time. frames from the head and tail of the
;; movie are composited on each other using gfx:image2image
;; with a 50% transperency and then displayed.
;;
;; NOTE That you will get very poor performance trying
;; to playback movies with framerates other than 1
;; in particular this relates to movies in h264 format etc.
;;
;; For best performance playback in reverse use formats such
;; as Motion JPEG, or Apple Intermediate.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define canvas (gfx:make-canvas))
(define movie (gfx:load-movie "/tmp/myfilm.mov"))
(define mlgth (- (gfx:get-movie-duration movie) 1.0))
(define frame-length (* *second* 0.1))
(define loop
(lambda (time mtime)
(let ((pic1 (gfx:convert-image (gfx:get-movie-frame movie mtime)))
(pic2 (gfx:convert-image (gfx:get-movie-frame movie (- mlgth mtime)))))
; composit pic2 on pict1 with a 50% transparency
(gfx:image2image pic2 pic1 0.5)
(gfx:draw-image time canvas pic1 1.0)
(set! time (+ time frame-length))
(if (< mtime mlgth)
(callback (- time 1000) 'loop time (+ mtime 0.1))))))
(loop (now) 0.0)