Open holyjak opened 1 month ago
This is not currently working for me.
I am first struggling to display any video with kindly and also because VideoTrim returns a slightly different format. I'm working on the first issue first though.
The format (k/video {:src "./resources/video/Baby.mp4"})
works for me rather than file://...
We would also need to somehow specify the default path to Wolfram video operations (~/Documents/Wolfram/Video) or add the folder dynamically.
(defn- kind<-Video
"Takes a Wolfram-like `(video url ...)` expression and returns an appropriate video kind.
NOTE: Take care with the capital letter. This is to distinguish a Wolfram `Video` from other types."
[expr]
(k/video {:src (second expr)}))
(defn maybe-add-kindly-meta [expr]
{:pre [expr]}
(if (instance? IObj expr)
(cond
(= (head expr) 'Video)
(k/fn expr
{:kindly/f kind<-Video}))
expr))
Seems to work for me for a 'normal' (Video ...)
. Not sure why it's not working for the output of VideoTrim
though.
(-> "./resources/video/Baby.mp4"
w/Video
;; (w/VideoTrim [6 7])
wl/eval
);; => works!, i.e. video is displayed nicely in Clay window
(-> "./resources/video/Baby.mp4"
w/Video
(w/VideoTrim [6 7])
wl/eval);; => doesn't work, i.e. "No video with supported format and MIME type found." is seen in an image in Clay (instead of the video).
And, in case you're wondering, the original video is 22 seconds long.
If I manually take the cider output of the above function though and evaluate it through Clay in the usual way then it works. Is it something to do with the video being examined before it's created or anything like that?
Interestingly,
(-> (w/do (-> "./resources/video/Baby.mp4"
w/Video
(w/VideoTrim [6 7])
(->> (w/= 'thing)))
(-> 'thing))
wl/eval) ;; => doesn't work
(-> "./resources/video/Baby.mp4"
w/Video
(w/VideoTrim [6 7])
(->> (w/= 'thing))
wl/eval)
(-> 'thing
wl/eval) ;; => does work!
I bet ☝️works because the latter returns whatever =
returns, which is the RHS, which is the VideoTrim output. But the former could also be simplified to two calls (wl/eval ...)
(wl/eval 'thing)
and then it is perhaps not surprising it only returns 'thing
.
Issue: Wolfram may return
(Video <path to file> ...)
and we want to be able to display it nicely in a Clay or compatible notebook.Fix: Add ns with a fn to try add display metadata to all results, call it from eval.