Skip to content

Instantly share code, notes, and snippets.

@dbreunig
Created February 24, 2025 20:09
Show Gist options
  • Select an option

  • Save dbreunig/834c625a1aaac6b3c4cf2bb388dae542 to your computer and use it in GitHub Desktop.

Select an option

Save dbreunig/834c625a1aaac6b3c4cf2bb388dae542 to your computer and use it in GitHub Desktop.
A script for executing FFmpeg commands generated by llm, using natural language as an input.
#!/usr/bin/env zsh
# Check for if the user wants to execute the command
flag_x=false
for arg in "$@"; do
if [[ "$arg" == "-x" ]]; then
flag_x=true
break
fi
done
# Hit the model and get the ffmpeg command
output=$(llm "$1" \
--system "You are an expert at writing commands for ffmpeg. You will be given prompts describing what the user wants to do with ffmpeg. to the best of your abilities, translate these plain language descriptions into a single one-liner that calls ffmpeg, with all the appropriate flags and input/output specifications. Do not use the variable 'total_frames' in any select statement. Ensure the command is wrapped as a code block." \
--extract)
# Print or execute the command
if [[ "$flag_x" == true ]]; then
echo "$output"
eval "$output"
else
echo "$output"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment