使用终端进行VLC屏幕捕获 [英] VLC screen capture using terminal
问题描述
我正在尝试将屏幕捕获为视频,并发现VLC可能是最好的解决方案.我要做的是使用终端捕获特定的应用程序,然后也停止捕获.现在,我可以使用终端通过以下命令进行捕获:
I'm attempting to capture my screen as video and found VLC to probably be the best solution. What I have to do is capture a specific application using terminal and then stop the capture as well. Right now, I can capture using terminal with the following command:
/Applications/VLC.app/Contents/MacOS/VLC -I dummy screen:// --screen-fps=25 --quiet --sout "#transcode{vcodec=h264,vb072}:standard{access=file,mux=mp4,dst="Desktop/vlc-output-terminal.mp4"}"
那太好了,它有效.问题是,如何使用终端退出录音?现在,我必须在终端上执行 Control + C 才能将其退出.我已经在网上看到vlc://quit
,但不确定如何使用该命令.
That's great, it works. The question is, how do I quit the recording using terminal? Right now, I'm having to do Control+C on the terminal to quit it. I've seen vlc://quit
online, but I'm not sure how to use that command.
还有,有人知道是否可以使用VLC捕获特定的应用程序,还是整个屏幕是唯一的选择?
Also, does anyone know if it's possible to capture a specific application using VLC or is the whole screen the only option?
推荐答案
录制时如何不退出
信号SIGINT
的Ctrl + C 终止进程(在本例中为VLC).
How to NOT quit when recording
Ctrl+C kill process (in this case VLC) with signal SIGINT
.
vlc://quit
选项在捕获屏幕时将不起作用,因为流是永无止境的源.
vlc://quit
option will not work when you capture screen because stream is never-ending source.
您可以使用TCP socket
或UNIX socket
连接到VLC.
You can connect to your VLC using a TCP socket
or a UNIX socket
.
-
TCP套接字
TCP socket
要能够使用TCP套接字(类似于telnet的连接)远程连接到VLC,请使用-rc-host your_host:port .然后,通过使用给定端口(使用telnet或netcat)连接到主机,您将获得命令外壳.
To be able to remote connect to your VLC using a TCP socket (telnet-like connetion), use --rc-host your_host:port. Then, by connecting (using telnet or netcat) to the host on the given port, you will get the command shell.
UNIX套接字
UNIX socket
要使用UNIX套接字(本地套接字,不适用于Windows),请使用-rc-unix/path/to/socket .然后可以使用此UNIX套接字传递命令.
To use a UNIX socket (local socket, this does not work for Windows), use --rc-unix /path/to/socket. Commands can then be passed using this UNIX socket.
要为VLC启用远程控制界面,您将需要添加选项>
To enable remote control interface for VLC you will need to add options
--extraintf rc --rc-quiet
-
TCP套接字
TCP socket
回声退出| nc your_host端口
echo quit | nc your_host port
UNIX套接字
回声退出| nc -U/path/to/socket
echo quit | nc -U /path/to/socket
-
执行VLC
Execute VLC
vlc \
screen:// --one-instance \
-I dummy --dummy-quiet \
--extraintf rc \
--rc-host localhost:8082 \
--rc-quiet \
--screen-follow-mouse \
--screen-mouse-image="mouse_pointer.png" \
--screen-left=0 --screen-top=0 --screen-width=800 --screen-height=600 \
--no-video :screen-fps=15 :screen-caching=300 \
--sout "#transcode{vcodec=h264,vb=800,fps=5,scale=1,acodec=none}:duplicate{dst=std{access=file,mux=mp4,dst='/Videos/screen.mp4'}}"
正常关闭VLC
Gracefully shutdown VLC
echo quit | nc localhost 8082
如果您没有 nc(netcat),也可以在下面使用Python
代码.在您的计算机上.
You can also use Python
code below if you do not have nc (netcat) on your computer.
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost', 8082))
s.sendall('quit\n')
s.shutdown(socket.SHUT_WR)
您无法选择要记录的应用程序,但可以指定子屏幕的坐标,宽度和高度.
You can't select which application to record but you can specify coordinate, width and height of the subscreen.
-
--screen-top integer
子屏幕的顶部边缘坐标. 默认值:0 -
--screen-left integer
子屏幕的左边缘坐标. 默认值:0 -
--screen-width integer
子屏幕的宽度. 默认值:<全屏宽度> -
--screen-height integer
子屏幕的高度. 默认值:<全屏高度>
--screen-top integer
The top edge coordinate of the subscreen. Default value: 0--screen-left integer
The left edge coordinate of the subscreen. Default value: 0--screen-width integer
The width of the subscreen. Default value: <full screen width>--screen-height integer
The height of the subscreen. Default value: <full screen height>
这篇关于使用终端进行VLC屏幕捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!