Files
docs/音视频处理/视频处理.md
2026-01-14 11:27:47 +08:00

21 lines
738 B
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 视频压缩
```sh
# 以h264编码
ffmpeg -i "input.mp4" -c:v libx264 -tag:v avc1 -movflags faststart -crf 30 -preset superfast "output.mp4"
# 以h265编码
ffmpeg -i input.mp4 -c:v hevc_nvenc -cq 23 -preset slow -c:a copy output.mp4
```
## 视频转码
```sh
ffmpeg -hwaccel nvdec -i test.mp4 -c:v h264_nvenc -preset slow -crf 23 -c:a aac test2.mp4
# -hwaccel nvdec使用硬件解码器nvdec(gpu解码)
# -i test.mp4 输入文件
# -c:v h264_nvenc 使用硬件编码器h264_nvenc或hevc_nvenc
# -preset slow`设置编码速度与压缩率的平衡(可选值:`slow`, `medium`, `fast`等)。
# -crf 23 控制视频质量范围0-51值越小质量越高
# -c:a aac 使用AAC音频编码器
# test2.mp4输出文件
```