ffmpeg 命令行录屏和停止录屏

//开始录制
void frmMain::on_start_clicked()
{
    m_Process.setProcessChannelMode(QProcess::MergedChannels);
    QString cmd = "ffmpeg.exe -f dshow  -i video=\"screen-capture-recorder\"  e:/123.mp4";
   // .\ffmpeg -f dshow -i video="screen-capture-recorder"  -r 20 -t 4 screen-capture.mp4
   // .\ffmpeg -f dshow -i video="screen-capture-recorder" 123.mp4      
    m_Process.start(cmd);
}
//停止录制
void frmMain::on_stop_clicked()
{
    if (m_Process.isOpen()){
        m_Process.write("q");
    }
}

参考雷神代码:
一句话介绍:注册录屏dshow滤镜(例如screen-capture-recorder),然后通过dshow获取录屏图像然后编码处理。

因此,在使用FFmpeg屏幕录像之前,需要先安装dshow滤镜。在这里推荐一个软件:screen capture recorder。安装这个软件之后,就可以通过FFmpeg屏幕录像了。

-f fmt (input/output)
Force input or output file format. The format is normally auto detected for input files and guessed from the file extension for output files, so this option is not needed in most cases.

-i url (input)
input file url
-r rate帧率
-t duration (input/output) 录屏时间

添加文字水印:

ffmpeg -f dshow -i  video="screen-capture-recorder" -vf drawtext="fontsize=100:fontcolor=white:text='test':x=(w-text_w-10):y=(h-text_h-10)" 1.mp4

添加图片水印:

ffmpeg -f dshow -i  video="screen-capture-recorder" -vf "movie=logo.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" 2.mp4

位置:
左上角
x=10:y=10
右上角
x=w-text_w-10:y=10
左下角
x=10:y=h-text_h-10
右下角
x=w-text_w-10 : y=h-text_h-10
中间:
x=(w-text_w)/2:y=(h-text_h)/2

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值