---
# System prepended metadata

title: ffmpeg指令
tags: [ffmpeg]

---

---
robots: noindex, nofollow
title: ffmpeg指令
tags: ffmpeg
---

# ffmpeg指令

### mac 螢幕錄影轉成 mp4
```bash
ffmpeg -i input.mov output.mp4
```

### mac 螢幕錄影轉成2倍速 mp4
```bash
ffmpeg -i input.mov -filter:v "setpts=0.5*PTS" output.mp4
```

### mac 螢幕錄轉 720p
```bash
ffmpeg -i wrong_direction.mov -vf scale=-1:720 wrong_direction.mp4
```

### mac 螢幕錄影轉 固定高度 600
- 600 可以隨意改
```bash
ffmpeg -i loading.mp4 -vf scale="trunc(oh*a/2)*2:600" loading2.mp4
```

### mac 螢幕錄影轉 固定寬度 1920
```bash
ffmpeg -i input.mp4 -vf scale="1920:trunc(ow/a/2)*2" output.mp4
```

### mac 螢幕錄影 to gif

https://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality

```bash
ffmpeg -t 2 -i input.mov -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
```

### 加上區間轉檔 from to

```bash
ffmpeg -ss 00:00:07 -t 00:00:38 -i g3.mov -vf scale="trunc(oh*a/2)*2:1080,setpts=1*PTS" g3.mp4
```

### 剪輯區間，使用 copy (不轉檔超快)

```bash
ffmpeg -ss 00:00:05 -t 00:00:25 -i input.mp4 -c copy output.mp4
```