Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quoting around complex noweb template use is unclear #15

Open
gvoysey opened this issue Nov 8, 2023 · 2 comments
Open

quoting around complex noweb template use is unclear #15

gvoysey opened this issue Nov 8, 2023 · 2 comments

Comments

@gvoysey
Copy link

gvoysey commented Nov 8, 2023

Consider the following defun:

    (defun dwim-shell-command-thumbnail-with-ffmpeg ()
      "Generate a thumbnail with ffmpeg."
      (interactive)
      (dwim-shell-command-on-marked-files
       "Thumbnail with ffmpeg"
       " ffmpeg -i '<<f>>' -vf  \"thumbnail,scale=640:360\" -frames:v 1 '<<td>>/<<fne>>.png'"
       :utils "ffmpeg"
       :silent-success t))

This fails with dwim-shell-command--escaped-quote-around: Couldn’t figure out how to quote for " ffmpeg -i '<<f>>' -vf "thumbnail,scale=640:360" -frames:v 1 '<<td>>/<<fne>>.png'" using / and .

If instead the command is " ffmpeg -i '<<f>>' -vf \"thumbnail,scale=640:360\" -frames:v 1 '<<fne>>.png'", (ie, omitting the temporary directory), this succeeds.

how does <> work? omitting the explicit / path separator doesn't seem to matter, nor does hardcoding a /tmp/ instead of using <<td>>.

(my actual goal here is to generate temporary thumbnails for videos, so what i really want is something like " ffmpeg -i '<<f>>' -vf \"thumbnail,scale=640:360\" -frames:v 1 '<<td>>/<<fne>>.png' && feh <<td>>/<<fne>>.png", but omitting the && ... clause doesn't affect the error here. I'm also a little curious about how to use <>; maybe i can just pipe the png into feh and avoid the file entirely, but i don't know how.)

xenodium pushed a commit that referenced this issue Nov 8, 2023
@xenodium
Copy link
Owner

xenodium commented Nov 8, 2023

This wasn't quite possible. Made some changes.

Adds support for and for #15

This adds <b> (base name) and <bne> (base name no extension), so we can now craft what you're after.

(my actual goal here is to generate temporary thumbnails for videos, so what i really want is something like " ffmpeg -i '<>' -vf "thumbnail,scale=640:360" -frames:v 1 '<>/<>.png' && feh <>/<>.png",

After getting the latest (v0.60), it should be possible with something like:

(defun dwim-shell-commands-video-temporary-thumbnail ()
  "Generate a thumbnail with ffmpeg."
  (interactive)
  (let ((temp-dir (make-temp-file "thumbnails-" t)))
    (dwim-shell-command-on-marked-files
     "Thumbnail with ffmpeg"
     "ffmpeg -i '<<f>>' -vf  \"thumbnail,scale=640:360\" -frames:v 1 '<<td>>/<<bne>>.png' && feh <<td>>/<<bne>>.png"
     :silent-success t
     :utils "ffmpeg")))

Note: I'm on a mac, so I used open instead of feh. Should hopefully work on linux with feh.

ps. Would be nice if there was a way to preserve the video aspect ratio in the thumbnail, if you know?

@xenodium
Copy link
Owner

xenodium commented Nov 9, 2023

ps. Would be nice if there was a way to preserve the video aspect ratio in the thumbnail, if you know?

This worked for me: "ffmpeg -i '<<f>>' -ss 00:00:01.000 -vframes 1 '<<td>>/<<bne>>.jpg' && feh <<td>>/<<bne>>.jpg"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants