4. 编码
4.1. 输入源YUV文件
使用示例
编码hevc
ffmpeg -r 50 -s 1280x720 -pix_fmt yuv420p -i input.yuv -c:v hevc_mxenc -b:v 30000000 -r 50 output.hevc
4.2. 输入源带封装文件(转码)
目前硬解硬编有2种模式可以选择,分别为host和device。
-device模式:解码后的图像数据一直保存在device内存上,供编码器或filters使用。
-host模式:解码器解码后yuv图像拷贝到系统内存上,供其他模块使用。性能低于device模式。
使用示例
device模式
ffmpeg -hwaccel metax -hwaccel_output_format metax -c:v hevc_mxvid -i input.ts -c:v hevc_mxenc -c:a copy -y output.mp4
ffmpeg -hwaccel metax -hwaccel_output_format metax -c:v hevc_mxvid -r 25 -b:v 3M -i input.ts -c:v hevc_mxenc -c:a copy -y output.mp4
host模式
ffmpeg -c:v hevc_mxvid -i input.ts -c:v hevc_mxenc -c:a copy -y output.mp4
ffmpeg -c:v hevc_mxvid -i input.ts -c:v hevc_mxenc -c:a copy -r 25 -b:v 3M -y output.mp4
4.3. 支持卡选择
可通过-init_hw_device选择设备,如:
-init_hw_device metax:0 //0代表第一张卡
使用示例
ffmpeg -init_hw_device metax:0 -hwaccel metax -hwaccel_output_format metax -c:v hevc_mxvid -i input.ts -c:v hevc_mxenc -c:a copy -y output.mp4