Use ffmpeg to do media manipulation from the terminal, like slowing down or speeding up a video, converting from MP4 to GIF, JPEG to PNG, etc.
## Versioning
To see the currently installed version:
```bash
ffmpeg -version # Note that it's just one dash
```
## Usage
### Convert Video to Gif
```bash
ffmpeg -i input.mov output.gif
```
Double the speed of the output media:
```bash
ffmpeg -i input.mov -vf "setpts=0.5*PTS" -f output.gif
```
You may need to specify the `fps` to maintain speed in converting to a gif, especially when converting from `.mov` file exported from Photos app.
1. Find fps, or tbr (target bitrate) with `ffprobe filename.mov`
2. Set `fps={number}` in the `vf` option:
```bash
ffmpeg -i input.mov -vf "setpts=0.5PTS,fps=30" output.gif
```
### Remove audio from the output:
```bash
ffmpge -i input.mov -an output.webm
```
### Reduce fps
Assuming fps is greater than 15 in `input.gif`:
```bash
ffmpeg -i input.gif -vf "fps=15" output.gif
```
### Get FPS from Gif
```bash
ffprobe -v error -select_streams v:0 -show_entries stream=r_frame_rate -of default=noprint_wrappers=1:nokey=1 {input.gif}
```
Framerate will look like a fraction - e.g. 30/1 means 30 FPS.
## HEIC
You may experience issues working with HEIC images. You can use different libraries like `heif-convert` if you can't get ffmpeg to work.
Apparently, newer versions of ffmpeg come with HEIC support, though I haven't personally gotten it to work.