English 中文(简体)
林丹
原标题:Linux: Screen desktop video capture over network, and VNC framerate

- 交通部:

  • What is the framerate of VNC connection (in frames/sec) - or rather, who determines it: client or server?
  • Any other suggestions for desktop screen capture - but "correctly timecoded"/ with unjittered framerate (with a stable period); and with possibility to obtain it as uncompressed (or lossless) image sequence?

Briefly - I have a typical problem that I am faced with: I sometimes develop hardware, and want to record a video that shows both commands entered on the PC ( desktop capture ), and responses of the hardware ( live video ). A chunk of an intro follows, before I get to the specific detail(s).  
 

Intro/Context

现在,我的战略是使用视频摄像机记录硬件测试过程(作为直播录像),同时进行桌面记录。 录像摄影机制作了29.97(30)FPS MPEG-2 .AVI录像;我希望将桌面录制作为全国国民党的图像序列,其速度与录像相同。 那么,设想是:如果两个视频的基数率相同;那么我只能简单地讲几句。

  • align the time of start of the desktop capture, with the matching point in the live video
  • Set up a picture-in-picture, where a scaled down version of the desktop capture is put - as overlay - on top of the live video
    • (where a portion of the screen on the live video, serves as a visual sync source with the desktop capture overlay)
  • Export a final combined video, compressed appropriately for the Internet

原则上,我猜测,我们可以为这一进程使用诸如<编码>>ffmpeg等指挥系统工具;然而,我更希望利用全球情报系统寻找两个视频的调和起点。

Eventually, what I also want to achieve, is to preserve maximum quality when exporting the final video: the live video is already compressed when out of the camera, which means additional degradation when it passes through the Theora .ogv codec - which is why I d like to keep the original videos, and use something like a command line to generate a final video anew, if a different compression/resolution is required. This is also why I like to have the desktop capture video as a PNG sequence (although I guess any uncompressed format would do): I take measures to adjust the desktop, so there aren t many gradients, and lossless encoding (i.e. PNG) would be appropriate.  
 

Desktop capture options

Well, there are many troubles in this process under Ubuntu Lucid, which I currently use (and you can read about some of my ordeals in 10.04: Video overlay/composite editing with Theora ogv - Ubuntu Forums). However, one of the crucial problems is the assumption, that the frame rate of the two incoming videos is equal - in reality, usually the desktop capture is of a lower framerate; and even worse, very often frames are out of sync.

因此,这需要在录像编辑前坐视灯,并手工切割和编辑框架级低于秒钟的剪辑——需要小时<<><>m>5分钟>的录像。 另一方面,如果两部录像(直播和录像)did。 同样的框架和概要:原则上,你在录像编辑中发现开端同点需要几分钟以上,而合并的录像处理的其他部分可由单一指挥线处理。 因此,在这个职位上,我要着重谈谈<>desktoplect/strong>部分。

就我所知,只有很少viable。 (与)在北海图采集的替代品(注,我通常使用一台膝上型计算机作为桌面捕获的目标):

  1. Have your target PC (laptop) clone the desktop on its VGA output; use a VGA-to-composite or VGA-to-S-video hardware to obtain a video signal from VGA; use video capture card on a different PC to grab video
  2. Use recordMyDesktop on the target PC
  3. Set up a VNC server (vino on Ubuntu; or vncserver) on the target PC to be captured; use VNC capture software (such as vncrec) on a different PC to grab/record the VNC stream (which can, subsequently, be converted to video).
  4. Use ffmpeg with x11grab option
  5. *(use some tool on the target PC, that would do a DMA transfer of a desktop image frame directly - from the graphics card frame buffer memory, to the network adapter memory)

Please note that the usefulness of the above approaches are limited by my context of use: the target PC that I want to capture, typically runs software (utilizing the tested hardware) that moves around massive ammounts of data; best you could say about describing such a system is "barely stable" :) I d guess this is similar to problems gamers face, when wanting to obtain a video capture of a demanding game. And as soon as I start using something like recordMyDesktop, which also uses quite a bit of resources and wants to capture on the local hard disk - I immediately get severe kernel crashes (often with no vmcore generated).

因此,在我看来,我通常会参与一个second的电脑——以掌握和记录目标PC desktop。 除此以外,我迄今为止可以看到的与上述选择相符合的利弊如下。

(Desktop preparation)

对于下文讨论的所有方法,我倾向于“准备”桌面前言:

  • Remove desktop backgrounds and icons
  • Set the resolution down to 800x600 via System/Preferences/Monitors (gnome-desktop-properties)
  • Change color depth down to 16 bpp (using xdpyinfo | grep "of root" to check)

......以尽量减少台式捕获软件的负荷。 请注意,改变乌班图的色深度需要修改xorg.conf;然而,“

为了保持图形资源使用率低,我通常有<条码>compiz残疾,或者说,我有“None”的系统/参考/设计/早期效果。 然而,在我尝试通过将视觉效应置于“热”之上(更多><>>>>/>影响产生faster<>/em> screen? 由于拥有专利的司机,该卡并不喜欢它(该卡是“<>Intel Corporation N10 Family Integratedgraphicsller/em>,而乌兰巴托在改用compiz时没有专有的驾驶人选择”,尽管所有混杂和效果只能 我的眼睛:]。

Cloning VGA

这也是最有意义的选择(因为它不仅需要额外购买一台,而且还需要购买两部硬件:VGA转换器和录像带卡);而且主要适用于膝上型计算机(既具备屏幕+额外甚高分辨率输出结果),而对于 desktop来说,也可能需要投资于额外的制图卡或甚高分辨率的克隆硬件。

然而,这也是唯一不需要目标PC任何附加软件(因此使用目标CPU的0%处理能力)的备选办法,也是唯一一个用true<>>>><>>/em>提供30 fps的录像(因为由单独的硬件进行,尽管假设单个硬件之间的锁栏域错值微不足道)。

实际上,由于我已经拥有像捕获卡这样的一些东西,我已经投入了VGA转换器,期望它最终能够让我制作最后的“合并”录像,其中只剩下5个点,只剩下一个指挥线;但我尚未看到这一进程是否将按计划进行。 I m还浪费了尽可能将 desktop作为不压缩的录像带——800x600,30 fps。

recordMyDesktop

如果你在没有任何论点的情况下操作recordMyDesktop,则首先掌握(例如)原始图像数据,如/tmp/rMD-session-7247;在你要求Ctrl-C打断之后,将这种原始图像数据编码为正文。 显然,在像我的测试软件一样的硬磁盘上收集大量图像数据(这也导致大量数据),通常是造成一种不稳定的因素:

因此,我尝试的是:,在网络上分享动力;然后在目标PC上,I d 链接到这一驱动力——并指示代码上使用这一网络驱动力(通过

recordmydesktop --workdir /home/user/.gvfs/test on 192.168.1.100/capture/ --no-sound --quick-subsampling --fps 30 --overwrite -o capture.ogv 

请注意,虽然这一指挥系统将使用网络地点处理临时档案(并因此有可能使用<代码>recordMyDesktop,与我的软件平行运行),但一旦Ctrl-C点击,该指挥部将开始直接编码和保存<代码>capture.ogv(但当时我并未真正注意:)

我的纳格斯中首先有<代码>recordMyDesktop,即你不能指示它保存临时档案,避免最终编码:你可以使用Ctrl++。 pa胎加胎——或者在头胎后你能够很快打到Ctrl-C,导致它坠毁;然后将离开临时档案(,如果你很快不打Ctrl-C,则该方案将“ up顶......>。 可以说:

recordmydesktop --rescue /home/user/.gvfs/test on 192.168.1.100/capture/rMD-session-7247/

......以便转换原始临时数据。 然而,通常情况下,recordMyDesktop本身在履行这一“rescue”的过程中会发生过失。 虽然,我想要保存时间档案的原因,是了解情况时的mont。 请注意,“-on-the-encoding”将完全避免使用时间文档,即使用更多的邮联处理权(对我来说,这再次造成坠毁)。

然后是制定基准——显然,你可以采用<代码>-fps N备选办法设定requestedframerate;然而,这并不能保证你会实际获得该基准;例如,我获得:

recordmydesktop --fps 25
...
Saved 2983 frames in a total of 6023 requests
...

......用我的测试软件进行捕获;这意味着实际达到<>。 比率更像25*2983/6032=12.3632 fps!

很显然,这些框架被放弃,大多数都显示为 。 然而,如果我把所要求的假肢降低到12个,那么根据所节约的报告/总的报告,我就达到了11个假点;在这种情况下,录像回击率高。 我仍然 t着把这种捕捉与实在在的录像相匹配的拖车,因此,如果实际挽救了这些框架,我就没有想法,也没有准确的时间。

VNC capture

对我来说,国家民事警察局的捕获包括:在目标PC上运行一个国家民事警察局服务器,并在常设计算机记录器上运行<代码>vncrec(前版)。 作为VNC服务器,我使用vino,即“系统/参考/重新设计桌面(参考)”。 显然,即使vinoture可能不是管理的最容易的事情,vino作为服务器似乎对目标PC不征税;因为与我的测试软件平行运行时,我有没有经历过坠毁。

另一方面,当<代码>vncrec在记录器PC上捕获时,该编码还引出一个窗口,显示在实时上看到的目标台;当目标上出现大量更新(即整个窗户移动)时,可以明显看到记录器上更新/更新率的问题。 但是,仅作少量更新(即仅仅是一个 cur子在静态背景下移动),情况似乎就是如此。

这使我很想知道我与这一职位有关的主要问题之一——这是什么——在武革委的联系中确定框架?

我没有找到对此的明确答案,但从胎面和胎面(以下的参考文献)来看,我发现:

  • The VNC server simply sends changes (screen changes + clicks etc) as fast as it can, when it receives them ; limited by the max network bandwidth that is available to the server
  • The VNC client receives those change events delayed and jittered by the network connection, and attempts to reconstruct the desktop "video" stream, again as fast as it can

......这意味着,不能以稳定、定期的费率(如录像)来说明。

就用户而言,截至<代码>vncrec,我通常被宣布为10 fps,尽管框架可能相当分散/倾斜(这就要求录像编辑进行切割)。 注:vncrec-twibright/README 影片的样本率是全国公民和部落居民协会拖欠或压倒的10 MOVIE FRAMERATE 环境变数,如未具体说明,则10:;然而,该页还称“VNCREC_MOVIE_FRAMERATE-Specifies framework rate of theproduct 电影. 只具有驱散方式的效力。 Default to 10. Try 24, 摘自10。 如果看到“vncrec/sockets.c来源,则可以看出:

void print_movie_frames_up_to_time(struct timeval tv)
{
  static double framerate;
  ....
  memcpy(out, bufoutptr, buffered);
  if (appData.record)
    {
      writeLogHeader (); /* Writes the timestamp */
      fwrite (bufoutptr, 1, buffered, vncLog);
    }

... which shows that some timestamps are written - but whether those timestamps originate from the "original" target PC, or the recorder one, I cannot tell. EDIT: thanks to the answer by @kanaka, I checked through vncrec/sockets.c again, and can see that it is the writeLogHeader function itself calling gettimeofday; so the timestamps it writes are local - that is, they originate from the recorder PC (and hence, these timestamps do not accurately describe when the frames originated on the target PC).

不管怎样,在我看来,服务器发送——和vncrec,作为客户接收——,每当;而且只是在随后从原始捕获中输入一个视频文件的过程中,才确定/推断某种形式的基准率。

我还愿指出,在我的专用膝上型计算机上,;因此,无线电话是我的唯一选择,可以进入路由器和当地网络,速度远低于100MB/s,路由线人操作。 然而,如果被捕获的圈子由于装上目标PC而造成错误的时间点,那么我不认为良好的网络带宽会太大。

最后,就VNC而言,还可以尝试其他办法,例如:VNCast 服务器(<>promising,但需要一定时间从源中进行建设,并且正在“早期实验版本”上”;或

ffmpeg with x11grab

曾有过这么多的事情,但我曾尝试过有关netcat。

#  target 
ffmpeg -f x11grab -b 8000k -r 30 -s 800x600 -i :0.0 -f rawvideo - | nc 192.168.1.100 5678
#  recorder 
nc -l 0.0.0.0 5678 > raw.video  #

......的确包含一个档案,但ffplay 不能正确阅读所收集的档案;而:

#  target 
ffmpeg -f x11grab -b 500k -r 30 -s 800x600 -i :0.0 -f yuv4mpegpipe -pix_fmt yuv444p - | nc 192.168.1.100 5678
#  recorder 
nc -l 0.0.0.0 5678 | ffmpeg -i - /path/to/samplimg%03d.png

does produce .png images - but with compression artifacts (result of the compression involved with yuv4mpegpipe, I guess).

因此,I m不 liking ffmpeg+ 目前太多——但也许我不知道如何满足我的需求。

*( graphics card -> DMA -> network )

诚然,我并不肯定存在这样的情况——事实上,我要说的是: 我这里没有专家,但我猜想:

如果能够从图形卡(或保持现有桌面轨道图的缓冲)中开始传承(source)和网络改编器(destination)——原则上应当能够以正确的(和体面的)框架获得未经压缩的台式捕获。 当然,使用排雷部的转让,是为了免除处理人将桌面图像复制到网络界面的任务(,从而减少捕获软件对目标PC——特别是那些涉及RAM或硬盘的流程的影响)。

与此类似的建议当然认为:网络带宽(for 800x600, 30 fps 至少800*600*30 = 43200000 bps = 42 MiB/s,这应是当地100个甲基溴/秒网的OK);其他PC大量硬磁盘,记录和随后能够读到该原始数据的软件,并产生基于该软件的图像序列或录像:)

带宽和硬磁盘要求我能够生活——只要能够保证有稳定的框架数据和无压缩数据;这就是为什么我热心听已经存在的情况。

--————

确实,我猜测是这样——正如我可以这样说: 任何关于工具或过程的建议,都可能导致桌面捕获

  • in uncompressed format (ultimately convertible to uncompressed/lossless PNG image sequence), and
  • with a "correctly timecoded", stable framerate

......这最终将便于进行单一指挥线处理,以制作图像-图像传输视频——将受到极大赞赏!

Thanks in advance for any comments,
Cheers!


References

  1. Experiences Producing a Screencast on Linux for CryptoTE - idlebox.net
  2. The VideoLAN Forums • View topic - VNC Client input support (like screen://)
  3. VNCServer throttles user inpt for slow client - Kyprianou, Mark - com.realvnc.vnc-list - MarkMail
  4. Linux FAQ - X Windows: How do I Display and Control a Remote Desktop using VNC
  5. How much bandwidth does VNC require? RealVNC - Frequently asked questions
  6. x11vnc: a VNC server for real X displays
  7. HowtoRecordVNC (an X11 session) - Debian Wiki
  8. Alternative To gtk-RecordMyDesktop in Ubuntu
  9. (Ffmpeg-user) How do I use pipes in ffmpeg
  10. (ffmpeg-devel) (PATCH) Fix segfault in x11grab when drawing Cursor on Xservers that don t support the XFixes extension
最佳回答

你们应该为如此漫长而充满问题而 bad。

In answer to your primary question, VNC uses the RFB protocol which is a remote frame buffer protocol (thus the acronym) not a streaming video protocol. The VNC client sends a FrameBufferUpdateRequest message to the server which contains a viewport region that the client is interested in and an incremental flag. If the incremental flag is not set then the server will respond with a FrameBufferUpdate message that contains the content of the region requested. If the incremental flag is set then the server may respond with a FrameBufferUpdate message that contains whatever parts of the region requested that have changed since the last time the client was sent that region.

如何界定要求和更新互动的定义并不明确。 如果情况没有改变,服务器就不得不对每一项请求做出回应。 如果服务器有客户提出的多重要求,也允许发出一次更新。 此外,客户确实需要能够回应服务器(而不是根据要求)的超常更新信息,否则客户就会脱离集团(因为RFB不是一个框架议定书)。

客户往往被简单地加以执行,以便定期发送整个框架缓冲港的最新递增要求,并在到达时处理任何服务器更新信息(即没有试图将请求和最新情况联系起来)。

Here is a description of FrameBufferUpdateRequest messages.

问题回答

暂无回答




相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签