---
# System prepended metadata

title: FFMPEG

---

# FFMPEG

* Using FFMPEG in Unity
https://github.com/shinn716/Unity-FFmpeg-ScreenRecorder
or
```
https://github.com/shinn716/Unity-FFmpeg-ScreenRecorder.git#upm
```

* FFMPEG binary files
https://ffbinaries.com/downloads

---

## List devices
```
ffmpeg -list_devices true -f dshow -i dummy
```

## Capture audio
```
ffmpeg -f dshow -i audio="Device name" path-to-file\file-name.mp3
``` 
Sample: 
```
ffmpeg -f dshow -i audio="Microphone (Realtek(R) Audio)" d:\123.mp3
```
```
ffmpeg -f dshow -i audio="Microphone (Realtek(R) Audio)" -acodec libmp3lame "d:\out.mp3"
```

## Capture screen
```
ffmpeg -y -rtbufsize 100M -f gdigrab -t 00:00:30 -framerate 30 -probesize 10M -draw_mouse 1 -i desktop -c:v libx264 -r 30 -preset ultrafast -tune zerolatency -crf 25 -pix_fmt yuv420p d:/video_comapre2.mp4
```

### FHD, 以 30 fps 捕獲整個螢幕
```
ffmpeg -f x11grab -framerate 30 -video_size 1920x1080 -i :1+0,0 -c:v huffyuv -an desktop.avi
```

## Capture screen and audio
```
ffmpeg -rtbufsize 1500M -f dshow -i audio="Microphone (Realtek(R) Audio)" -f -y -rtbufsize 100M -f gdigrab -t 00:00:30 -framerate 30 -probesize 10M -draw_mouse 1 -i desktop -c:v libx264 -r 30 -preset ultrafast -tune zerolatency -crf 25 -pix_fmt yuv420p "d:\ffmpeg_testing.mp4"
```

Hide mouse, Resolution 1920x1080
```
ffmpeg -rtbufsize 1500M -f dshow -i audio="Microphone (Realtek(R) Audio)" -f -y -rtbufsize 100M -f gdigrab -t 00:00:30 -video_size 1920x1080 -framerate 30 -probesize 10M -draw_mouse 0 -i desktop -c:v libx264 -r 30 -preset ultrafast -tune zerolatency -crf 25 -pix_fmt yuv420p "d:\ffmpeg_testing.mp4"
```

## Compress Video 
```
ffmpeg -i [Input.mp4] -vcodec libx264 -b:v 3000k -r 25 -vf "transpose=1" -threads 0 -acodec copy -y [Output.mp4]
```

```
ffmpeg -i video.mp4 -vcodec h264 -acodec aac output.mp4
```

## Corp Video
```
ffmpeg -i d:\video.avi -ss 00:05:00.00 -t 00:01:00.00 d:\output.avi
```

```
ffmpeg -ss 00:00:04 -to 00:02:20  -i output.mp4 -c copy cut.mp4
```

## Convert video to H.264
```
ffmpeg -i video.avi output.mp4
```

## 轉換為 30 FPS、64 種顏色和 500 像素寬的 gif
```
ffmpeg -y -i source.mp4 -filter_complex "[0:v] fps=30,scale=500:-1,split [a][b];[a] palettegen=max_colors=64 [p];[b][p] paletteuse=dither=floyd_steinberg" out.gif
```