ffmpeg threads_FFmpeg限制CPU的使用率,使用“-threads 2”

通过在FFmpeg命令中添加'-threads 2'参数,可以将CPU使用率控制在大约50%,从而实现更有效的资源管理。这种方法在处理多媒体文件时能避免过度消耗系统资源。
摘要由CSDN通过智能技术生成

–threads 2 参数

使用–threads 2 可以将CPU的使用率控制在50%左右。

FFmpeg -i IN  –threads 2   OUT

源文链接:https://stackoverflow.com/questions/11357713/how-to-limit-ffmpeg-cpu-usage

The solution as outlined here

is to limit the number of threads that FFMpeg uses to less than the number of available cores on the computer.

Following up on your comment, you can supply an Argument via StartInfo

Processffmpeg =newProcess();ffmpeg.StartInfo.UseShellExecute=false;ffmpeg.StartInfo.FileName="..\ffmpeg.exe";ffmpeg.StartInfo.Arguments="-threads 2";// <=== Add this lineffmpeg.StartInfo.CreateNoWindow=true;ffmpeg.Start();

测试一 -threads

-threads 2 以两个线程进行运行, 加快处理的速度。

转换视频:7752c7dd-36aa-47eb-95a5-2193c9726541.wmv

目标视频:7752c7dd-36aa-47eb-95a5-2193c9726541.mp4

转换命令:FFmpeg -i IN -map 0 -r 25 -threads 4 -y Out

本机测试机环境:win7旗舰版+Intel(R) Core(TM)i5-2400 CPU @3.10GHz  3.10GHz+4.00GB+64bit

序号

开启的线程数

占用CPU数

CPU使用率(%)

转换时间(min)

其他

1

1

1

25

7

2

2

4

40-55

3

2个CPU〉50%,1个=50%,1个CPU=40%

3

4

4

60-70

3

4个CPU比较平均

4

4

4

70-80

2

4个CPU使用平均

5

-

4

80-85

2

4个CPU使用较平均

为了达到更快的转换速度,CPU使用率在可允许范围内,选择-threads 2。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值