# FFMPEG Commands

# Cropping

**Center Crop for Instagram:**

`ffmpeg -i ParticleSensor.mp4 -vf "scale=(iw*sar)*max(1080/(iw*sar)\,1080/ih):ih*max(1080/(iw*sar)\,1080/ih), crop=1080:1080" ParticleSensor_ig.mp4`

# Web Convert

##### **OGV:**

```bash
in_old = "path_to_vid.mp4"
new = ${in_old%.*}.ogv
ffmpeg -i $in_old -codec:v libtheora -qscale:v 6 -codec:a libvorbis -qscale:a 6 $new
```

##### MP4:  


```bash
ffmpeg -i Web*.mov -an \
  -vf "scale=1920:-2:flags=lanczos,fps=30" \
  -c:v libx264 -preset slow -crf 22 \
  -pix_fmt yuv420p -profile:v high -level 4.1 \
  -g 120 -bf 2 \
  -movflags +faststart \
  frontvideo01.mp4
```

# Convert entire folder

```bash
for i in *.mov;
  do name=`echo "$i" | cut -d'.' -f1`
  echo "$name"
  ffmpeg -i "$i" "${name}.mp4"
done
```

# Hardware encoding

#### **Intel example command:**

ffmpeg -hwaccel vaapi -hwaccel\_output\_format vaapi -vaapi\_device /dev/dri/renderD128 -i "${invid}" -codec:v h264\_vaapi ${invid%.}\_testHW.mp4

# For Website Looping Video

`ffmpeg -ss 10 -i $INPUT -t 5 -<span class="hljs-string">'min(350,ih)':force_original_aspect_ratio=decrease,pad=550:350:(550-iw)/2:(350-ih)/2"</span> -c:v libx264 -an -preset veryfast -crf 28 output.mp4`