Hi!
I am trying to optimise my macro which was previously loaded to the terminal window. But I don't know how to do that correctly. Currently it doesn't work. It doesn't show any FPS as a result.
Get the frame rate.kmmacros (7.5 KB)
Hi!
I am trying to optimise my macro which was previously loaded to the terminal window. But I don't know how to do that correctly. Currently it doesn't work. It doesn't show any FPS as a result.
Get the frame rate.kmmacros (7.5 KB)
Try temporarily changing the shell script to one that echos the value of the variable, and displays the result in a window. This will help you narrow down if the issue is the variable, or something else.
By the way, I believe it's recommended that people no longer use the short reference to a variable, i.e. %LocalFPS
. Instead, use %Variable%LocalFPS%
.
Of course, that won't change your current problem.
As always, start simple. What happens with a macro containing only this action?
Otherwise, your macro works fine here -- assuming your current Finder selection is a folder containing at least one .mov
file.
Then -- and again -- you haven't got the correct paths in KM's ENV_PATH
variable. Use which ffprobe
in Terminal to get the full path, then use that in your "Execute Shell Script" script.
Since there's nothing wrong with the command, it must be the input. For example, you are iterating through all the items in a directory, only processing the files with a .mov
extension. But at the moment you "Break" after the first file -- if that isn't a .mov
you'll get no output.
I think this is not the case as when I activate the disabled now Display %Variable%LocalPath%, it shows the video path. I break from loop only after the mov file gets found. Strange
Is "$KMVAR_LocalPath" correct using of variable?
Like I said, your macro works for me on a random .mov
file. So your command is correct assuming that a) your input is correct, b) the ffprobe
result is n/m
where n
and m
are both numbers, and c) m
is not 0
(I suspect that would give you a "divide by 0
" error).
Try the macro, but without the pipe to awk
. Try the entire command in Terminal, replacing the KM variable with the path you get in the "Display Text" window.
Make sure you have error reporting and aborting on in your Execute Shell Script so you can see what errors you are getting.
Error reporting and aborting is on. The macro aborts on shell script. No errors reported.
If ask to display the path of the video file before the shell script, it shows it correctly.
Try turning aborting off with "Include error" on. That way any shell error will get saved to LocalFPS
and displayed in your "Display Text" window. Because it sounds like Notifications aren't showing -- if they were you'd have seen the ffprobe: command not found
error earlier and known that the path was wrong.
Here is the error:
Blockqoute
/var/folders/sq/23z5fk5s37vbkdn2530qbln00000gn/T/Keyboard-Maestro-Script-99793281-BB11-4920-88BF-F85FB0D1A2B1:1:60: error: cannot find 'v' in scope
/opt/homebrew/bin/ffprobe -v 0 -of csv=p=0 -select_streams v:0 -show_entries stream=r_frame_rate "$KMVAR_LocalPath" | awk -F '/' '{ printf "%.2f\n", $1/$2 }'
Never even looked at ffpropbe
before yesterday, but that looks like it can't find the "stream" you're asking it to process -- whatever that means!
Again -- simplify the command and stop suppressing useful information by taking out the -v 0
option. You can always put it back in when you've got things working.
ffprobe -of csv=p=0 -show_entries stream=r_frame_rate "$KMVAR_LocalPath"
The strange thing that exctly the same command works in the Terminal.
Here is the error:
/var/folders/sq/23z5fk5s37vbkdn2530qbln00000gn/T/Keyboard-Maestro-Script-ACC86660-D2D8-4C03-9346-021747257A41:1:74: warning: string literal is unused
/opt/homebrew/bin/fffprobe -of csv=p=0 -show_entries stream=r_frame_rate "$KMVAR_LocalPath"
Then can you post that, unredacted, command? I'm wondering if there's some funky character in your test file's path that isn't present in mine -- utilities don't always follow the same quoted-path "rules" as the shell.
Sure. Here is the command containing the exct path
ffprobe -v 0 -of csv=p=0 -select_streams v:0 -show_entries stream=r_frame_rate "/Users/malenki/Nuendo Projects/Macro test/Video and Audio/WLFM_R1_v0827_PIX_PR-Proxy-720p[LetterBox].mov" | awk -F '/' '{ printf "%.2f\n", $1/$2 }'| pbcopy
Try as I might, even wiping an Apple Silicon laptop and starting from scratch, I cannot reproduce your problem. There are also inconsistencies in what you're reporting, eg the 3 "f"s in fffprobe
in the error above, that make me wonder if something's getting munged in copy/paste from/to the Forum.
But it looks like this is specific to your setup and very difficult to remotely solve, so something you'll have to troubleshoot yourself.
Take it one step at a time and take it carefully.
brew
at least twice, then run brew doctor
ffprobe
is at the latest version -- 7.1 -- update the whole ffmpeg
suite if it isn't/opt/homebrew/bin/ffprobe -version
to prove it's working.mov
file to your Desktop and rename it test.mov
so you have a easy file path with no problem charactersSooner or later you'll hit problems, and that should help you zone in on the cause. That may be something complicated -- or as simple as a Locale
difference between your Terminal's environment and KM's!
I refuse to give up
If you can't manage to get the "Execute Shell Script" action to work on your machine, and assuming that the problem with Terminal was having to interact with it -- here's a version of your original that will run the command in a new Terminal window with the result going to the Clipboard, then close the window, then append the FPS to your variable. All while keeping Terminal in the background: