Skip to content

ffd8/cli-for-artists-and-designers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLI for Artists + Designers

Command-Line Interface (CLI) is an amazing way to perform common tasks involving digital media (converting, cropping, downloading, merging, ...) without a graphical user interface (GUI). These tools are open-source (free) and written to perform single tasks really well. Once you install the following tools, you'll be surprised how rarely you need some big software programs.

Table of Contents

Basics

Workflow

Once setting the working directory (aka folder) to use, you write single line commands. These start with the name of the command to use, followed by arguments commonly using a flag to signify options ie. -i may set the input file, additional options and output destination. All commands are followed by the ENTER key to run.

command input options output

Commands are sometimes alone, ls to list files in current directory,
or with one input mkdir blah creates a new directory called 'blah'.
Usually a few arguments are needed following the command.

CLI Program

We enter these commands into the... Command-Line Interface.

  • MacOS, built-in CLI is Terminal, in Utilities directory (iTerm is also nice).
  • Windows, built-in CLI is Command Prompt, some suggest msys2 + conemu.
  • Linux, yeah yeah...

Essentials

  • cd (change directory), used to set working dir for accessing files.
  • pwd (print working dir), check which directory you're in.
  • ls (list), lists all files within working directory.
  • mkdir (make directory), creates a new directory with name of passed.
  • ../ (parent directory), used as part of path to navigate/save one directory up.
  • open . (open working directory), view in Finder.
  • man (manual), place before command, to read about its options.
  • say hello world (MacOS text-to-speech), never gets old...

Shortcuts

  • TAB (autocomplete), completes command or directory/filename.
  • UP ARROW (history), toggle through recent commands.
  • CTRL + R (reverse search), search through previous commands.
  • CTRL + A (start of line), move cursor to start of line.
  • CTRL + E (end of line), move cursor to end of line.
  • CMD + K (clear), clears window of previous commands.
  • CTRL + C (cancel), stop any task mid process.

Set active directory

You usually set the directory you're working in to simplify typing filename's by relative path for processing or saving items to that specific location.

cd path/to/directory

The easiest way to do this is just type cd + spacebar, then drag and drop the folder into the CLI window. Hit Enter and you're now working in that directory. Test you're there with pwd to print the path or ls to list all items within it.

Careful

Use caution when snippets include the following commands

  • rm/rmdir (remove / remove directory), permanently removes files!
  • sudo (root), sometimes needed for system changes, but gives admin privledges.

Additional Links

Package Manager

A package manager keeps track of open source tools and makes installation easy. It takes a while to setup, but is worth it to quickly access these tools as you dive deeper.

MacOS

Homebrew is a great package manager with a HUGE updated list of formulae.

To install, just copy + paste into the following into Terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

It will confirm you want to install XCode dev tools (a few Gb), press ENTER to continue, then enter your computer's password (only time it should be needed).
FYI: you won't see your password while typing, just press ENTER when done.

Since 10.12+, once the install is complete, you need to copy the 2 suggested lines, paste and press ENTER. Starts with (echo...

Once done ($ or % reappear), then to install packages
(this is generic code.. scroll down for actual packages):

brew install package_name

Windows

There is a manager called 'pacman' that comes with above CLI (msys2 + conemu), but it hasn't been tested and may not be necessary. Instead, you should use imagemagick's binary installer (which includes FFMPEG as an option!?)

Imagemagick - Windows Binary

FFMPEG install

- Press WIN+R  
- Type : Winget install ffmpeg  
- Wait 10 seconds.
- Done  

youtube-dlp - Windows Binary

Imagemagick

Imagemagick deals with images.
Convert image into ANY format, quickly assemble gifs, and especially batch process a directory of images.

Install

brew install imagemagick

(Windows, see Package Manager for tip on installing)

Usage

Once installed, you call it with convert (Windows use magick),
then pass any number of input and output arguments. mogrify is for batch processing.

Convert

You don't need to set an active directory, you can simply type convert (spacebar) then drag + drop original file, drag + drop again, replacing the suffix with a new filetype:

convert INPUT_FILE.xxx OUTPUT_FILE.yyy

  • convert launches Imagemagick
  • INPUT_FILE.png, drag + drop desired image to change
  • OUTPUT_FILE, drag + drop again, adjusting extension to desired format

But, you'll find the command super long with the absolute filepath, which then might be frustrating to edit options within, it's ideal to cd *path* into working directory withfiles and access by relative filename path only.

GIF from directory

Navigate to a directory of images, as described above in Set active directory.
Grab all *.png or *.jpg and output GIF:

convert *.png -loop 0 test.gif

  • convert launches Imagemagick
  • *.png searches for PNGs
  • -loop 0 sets # (0 = infinite) loops (ignored in MacOS preview!)
  • test.gif name of output file (customize).

Resize in batch

Navigate to a directory of images, as described above in Set active directory.
Create a directory for your output using mkdir:

mkdir thumbs

Batch process using mogrify:

mogrify -resize 128x128 -quality 100 -format jpg -path ./thumbs *.jpg

  • mogrify launch batch tool of Imagemagick,
  • -resize #x# resizes (can also use percentages)
  • -quality 100 sets compression
  • -format jpg optional suffix to convert formats
  • -path ./thumbs specifies where to put outputs
  • *.jpg searches for JPGs in active dir

Additional Links

FFmpeg

FFmpeg deals with audio/video.
It's the underlying tech beneath most online/offline media converters.

Install

brew install ffmpeg

(Windows, see Package Manager for tip on installing)

Usage

Once installed, call with ffmpeg, pass -i INPUTFILE.xxx, options, output file:

ffmpeg -i myfile.mov myfile.mp4

Convert

It's really as easy as above! You don't even need to set an active directory, you can simply type ffmpeg -i then drag + drop original file, drag + drop again, replacing the suffix with a new filetype:

ffmpeg -i input.xxx output.yyy

Get the loooong list of formats + codecs:

ffmpeg -formats
ffmpeg -codecs

Then apply them while converting:

ffmpeg -i myfile.mp4 -vcodec libx265 myfile_265.mp4

Movie to GIF

Similar to above, but with an added parameter:

ffmpeg -i input.mp4 -pix_fmt rgb24 output.gif

Trim

Extract segment from movie without re-encoding

ffmpeg -ss 10 -i input.mp4 -c copy -t 15 output.mp4

  • ffmpeg launches FFmpeg
  • -ss ## start from __ in sec
  • -i input.mp4 input file
  • -c copy use existing codec (instant, no re-encoding)
  • -t ## duration for new clip in sec (use -to ## for time in clip)
  • output.mp4 name/path for new output file

Extract frames

Navigate to directory of video, as described above in Set active directory.
Create directory for output using mkdir:

mkdir frames

Set input file, frames per second for output, file path/type:

ffmpeg -i input.mp4 -vf fps=1 frames/out_%04d.png

  • -vf fps=1 exports # frames per second
  • %04d use 4 padded digits (0000, 0001, ...)

Extract Audio

Navigate to directory of video, as described above in Set active directory.
Extract audio and convert to mp3 (or other format):

ffmpeg -i in.mp4 -vn -ac 2 out.mp3

Merge Audio + Video

Navigate to directory of video, as described above in Set active directory.
We can merge an audio + video, using the shortest one as the file length:

ffmpeg -i input.mov -i input.mp3 -c:v copy -map 0:v:0 -map 1:a:0 -shortest output.mov

Video from directory

Navigate to directory of images, as described above in Set active directory.

ffmpeg -framerate 30 -pattern_type glob -i '*.png'
-c:v libx264 -pix_fmt yuv420p out.mp4

  • -framerate 30 sets number of frames per second
  • *.png searches for PNGs (or use *.jpg)

Speed

Useful to speed up long screen-recordings:

ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" output.mp4

  • -filter:v "setpts=0.5*PTS" 0.5 = faster, 1.0 = normal, 1.5 = slower

Playback

FFmpeg ships with a minimal audio/video player ffplay.
Basic usage:

ffplay input.mp4

Useful shortcuts:

  • q/ESC (quit)
  • f (toggle fullscreen)
  • p / SPACEBAR (toggle pause)
  • m (toggle mute)
  • left/right (seek backward/forward 10 seconds)
  • up/down (seek backward/forward 1 minute)

Loop endless at fullscreen:

ffplay -fs -loop 0 input.mp4

View audio waveform:

ffplay -showmode 1 input.mp4

View audio frequency (FFT) spectrogram:

ffplay -showmode 2 input.mp4

View debug Motion Vectors:

ffplay -flags2 +export_mvs -vf codecview=mv=pf+bf+bb input.mp4

Export Motion Vectors only:

ffmpeg -flags2 +export_mvs -i input.mp4 -vf "split[src],codecview=mv=pf+bf+bb[vex],[vex][src]blend=all_mode=difference128,eq=contrast=7:brightness=-1:gamma=1.5" -c:v libx264 output.mp4

Additional Links

youtube-dlp

youtube-dlp is a great fork from the original youtube-dl project, which is an online media extractor.
The ultimate tool for downloading and archiving media files from almost any website.

Install

brew install yt-dlp

(Windows, see Package Manager for tip on installing, or download binary)

Usage

cd the desired directory for saving to, then as simple as:

yt-dlp VIDEO_URL

Formats

Most hosted videos have multiple files to stream depending on connection speed / quality.

List formats:

yt-dlp VIDEO_URL -F

It will return a long list of available formats, starting with an ID.
Then download the one you prefer:

yt-dlp VIDEO_URL -f ##

Or download the best mp4 or similar format:

yt-dlp -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' VIDEO_URL

Or download the best m4a or audio format:

yt-dlp -f 'bestaudio[ext=m4a]' VIDEO_URL

Then use ffmpeg above to convert to desired format.

Additional Links

And Then...

Read the man (manual) pages to become an expert, ie man say.
Learn more by doing web-search (usually Stack-Overflow discussion) for command + task you'd like to perform.
Enjoy more productivity with less interface!

Missing crucial tools or tips? Make an issue on GitHub.

Updated 2026.04.21
cc teddavis.org 2019 –
additional contributions: Ya-No, Hansi3D

About

Using Command-Line Interface for common media tasks

Resources

License

Stars

7 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors