ffmpeg 命令行录屏和停止录屏
  hXqfRqhGg9it 2023年11月02日 316 0


//开始录制
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


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  b1UHV4WKBb2S   2023年11月13日   40   0   0 ide抗锯齿
  b1UHV4WKBb2S   2023年11月13日   37   0   0 裁剪ideflutter
  zSWNgACtCQuP   2023年11月13日   32   0   0 ide
hXqfRqhGg9it