简体   繁体   English

Linux:通过网络屏幕桌面视频捕获,以及VNC帧率

[英]Linux: Screen desktop video capture over network, and VNC framerate

Sorry for the wall of text - TL;DR: 对不起,文字墙 - TL; DR:

  • What is the framerate of VNC connection (in frames/sec) - or rather, who determines it: client or server? 什么是VNC连接的帧速率(以帧/秒为单位) - 或者更确切地说,谁决定它:客户端还是服务器?
  • 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'). 简而言之 - 我遇到了一个我遇到的典型问题:我有时会开发硬件,并希望录制一个视频,显示在PC上输入的两个命令(“桌面捕获”) 硬件响应(“实时视频”) 。 A chunk of an intro follows, before I get to the specific detail(s). 在我了解具体细节之前,介绍了一大块介绍。

Intro/Context 前奏/上下文

My strategy, for now, is to use a video camera to record the process of hardware testing ( as 'live' video ) - and do a desktop capture at the same time. 我现在的策略是使用摄像机记录硬件测试过程( 作为“实时”视频 ) - 并同时进行桌面捕获。 The video camera produces a 29.97 (30) FPS MPEG-2 .AVI video; 摄像机产生29.97(30)FPS MPEG-2 .AVI视频; and I want to get the desktop capture as an image sequence of PNGs at the same frame rate as the video. 我希望以与视频相同的帧速率将桌面捕获作为PNG的图像序列。 The idea, then, would be: if the frame rate of the two videos is the same; 那么,这个想法是:如果两个视频的帧速率是相同的; then I could simply 然后我可以简单地说

  • 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 导出一个“最终”组合视频,适合互联网压缩

In principle, I guess one could use a command line tool like ffmpeg for this process; 原则上,我想可以使用像ffmpeg这样的命令行工具进行此过程; however I would prefer to use a GUI for finding the alignment start point for the two videos. 但我更愿意使用GUI来查找两个视频的对齐起点。

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. 最终,我还希望实现的目的是在导出“最终”视频时保持最高质量:“实时”视频在离开相机时已经被压缩,这意味着当它通过Theora .ogv编解码器时会出现额外的降级 - 这就是为什么我要保留原始视频,并使用命令行之类的东西重新生成“最终”视频,如果需要不同的压缩/分辨率。 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 (ie PNG) would be appropriate. 这也是我喜欢将'桌面捕捉'视频作为PNG序列的原因(虽然我猜任何未压缩的格式都可以):我采取措施'调整'桌面,因此没有很多渐变和无损编码(即PNG)是合适的。

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 ). 嗯,在Ubuntu Lucid的这个过程中有很多麻烦,我目前正在使用( 你可以阅读我在10.04中的一些考验:使用Theora ogv进行视频叠加/复合编辑 - Ubuntu论坛 )。 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 . 更糟糕的是,帧经常不同步

This, then, requires the hassle of sitting in front of a video editor, and manually cutting and editing less-than-a-second clips on frame level - requiring hours of work for what will be in the end a 5 minute video. 因此,这需要坐在视频编辑器前面的麻烦,并且在帧级别上手动剪切和编辑不到一秒钟的剪辑 - 需要数小时的工作才能完成5 分钟的视频。 On the other hand, if the two videos ('live' and 'capture') did have the same framerate and sync: in principle, you wouldn't need more than a couple of minutes for finding the start sync point in a video editor - and the rest of the 'merged' video processing could be handled by a single command line. 另一方面,如果两个视频(“实时”和“捕获”) 确实具有相同的帧速率和同步:原则上,在视频编辑器中查找起始同步点不需要超过几分钟 - 其余的'合并'视频处理可以由一个命令行处理。 Which is why, in this post, I would like to focus on the desktop capture part. 这就是为什么,在这篇文章中,我想重点关注桌面捕获部分。

As far as I can see, there are only few viable (as opposed to 5 Ways to Screencast Your Linux Desktop ) alternatives for desktop capture in Linux / Ubuntu (note, I typically use a laptop as target for desktop capturing): 据我所知,在Linux / Ubuntu中只有少数可行的 (而不是5种方法来截屏您的Linux桌面 )桌面捕获(请注意,我通常使用笔记本电脑作为桌面捕获的目标):

  1. Have your target PC (laptop) clone the desktop on its VGA output; 让您的目标PC(笔记本电脑)在其VGA输出上克隆桌面; use a VGA-to-composite or VGA-to-S-video hardware to obtain a video signal from VGA; 使用VGA到复合或VGA到S视频硬件从VGA获取视频信号; use video capture card on a different PC to grab video 在另一台PC上使用视频捕获卡来获取视频
  2. Use recordMyDesktop on the target PC 在目标PC上使用recordMyDesktop
  3. Set up a VNC server ( vi no on Ubuntu; or vncserver ) on the target PC to be captured; 在要捕获的目标PC上设置VNC服务器vi no在Ubuntu上;或者vncserver ); use VNC capture software (such as vncrec ) on a different PC to grab/record the VNC stream ( which can, subsequently, be converted to video ). 在另一台PC上使用VNC捕获软件(例如vncrec )来获取/记录VNC流( 随后可以将其转换为视频 )。
  4. Use ffmpeg with x11grab option ffmpegx11grab选项一起使用
  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 ) *( 使用目标PC上的某些工具,可直接对桌面图像帧进行DMA传输 - 从显卡帧缓冲存储器到网络适配器存储器

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; 请注意,上述方法的有用性受到我的使用环境的限制:我想要捕获的目标PC,通常运行软件(利用测试的硬件),这些软件可以移动大量的数据; 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). 一旦我开始使用像recordMyDesktop这样的东西,它也使用相当多的资源并想要在本地硬盘上捕获 - 我立即得到严重的内核崩溃(通常没有生成vmcore)。

So, in my context, I typically do assume involvement of a second computer - to run the capture and recording of the 'target' PC desktop. 因此,在我的上下文中,我通常会假设参与第二台计算机 - 运行“目标”PC桌面的捕获和记录。 Other than that, the pros and cons I can see so far with the above options, are included below. 除此之外,我目前可以看到的上述选项的优缺点如下。

(Desktop preparation) (桌面准备)

For all of the methods discussed below, I tend to "prepare" the desktop beforehand: 对于下面讨论的所有方法,我倾向于事先“准备”桌面:

  • Remove desktop backgrounds and icons 删除桌面背景和图标
  • Set the resolution down to 800x600 via System/Preferences/Monitors ( gnome-desktop-properties ) 通过系统/首选项/监视器( gnome-desktop-properties )将分辨率设置为800x600
  • Change color depth down to 16 bpp (using xdpyinfo | grep "of root" to check) 将颜色深度更改为16 bpp(使用xdpyinfo | grep "of root"来检查)

... in order to minimize the load on desktop capture software. ...为了最大限度地减少桌面捕获软件的负担。 Note that changing color depth on Ubuntu requires changes to xorg.conf; 请注意,在Ubuntu上更改颜色深度需要更改xorg.conf; however, " No xorg.conf (is) found in /etc/X11 (Ubuntu 10.04) " - so you may need to run sudo Xorg -configure first. 但是,“ 在/ etc / X11(Ubuntu 10.04)中找不到xorg.conf(是) ” - 所以你可能需要先运行sudo Xorg -configure

In order to keep graphics resource use low, also I usually had compiz disabled - or rather, I'd have 'System/Preferences/Appearance/Visual Effects' set to "None". 为了保持低图形资源的使用,我通常也禁用了compiz - 或者说,我将'系统/首选项/外观/视觉效果'设置为“无”。 However, after I tried enabling compiz by setting 'Visual Effects' to "Normal" ( which doesn't get saved ), I can notice windows on the LCD screen are redrawn much faster; 但是,在我尝试通过将“视觉效果”设置为“正常”( 没有保存 )来启用compiz后,我可以看到LCD屏幕上的窗口被重绘得更快; so I keep it like this, also for desktop capture. 所以我保持这样,也用于桌面捕获。 I find this a bit strange: how could more effects cause a faster screen refresh? 我发现这有点奇怪:如何更多的效果导致更快的屏幕刷新? It doesn't look like it's due to a proprietary driver (the card is " Intel Corporation N10 Family Integrated Graphics Controller ", and no proprietary driver option is given by Ubuntu upon switch to compiz ) - although, it could be that all the blurring and effects just cheat my eyes :) ). 它看起来不像是由于专有驱动程序(该卡是“ 英特尔公司N10系列集成图形控制器 ”,Ubuntu在切换到compiz时没有提供专有驱动程序选项) - 尽管如此,它可能是所有的模糊和效果只是欺骗我的眼睛:))。

Cloning VGA 克隆VGA

Well, this is the most expencive option (as it requires additional purchase of not just one, but two pieces of hardware: VGA converter, and video capture card); 嗯,这是最昂贵的选择(因为它需要额外购买一个,但两个硬件:VGA转换器和视频捕获卡); and applicable mostly to laptops (which have both a screen + additional VGA output - for desktops one may also have to invest in an additional graphics card, or a VGA cloning hardware). 并且主要适用于笔记本电脑(具有屏幕+额外的VGA输出 - 对于台式机,可能还需要投资额外的图形卡或VGA克隆硬件)。

However, it is also the only option that requires no additional software of the target PC whatsoever (and thus uses 0% processing power of the target CPU) - AND also the only one that will give a video with a true , unjittered framerate of 30 fps (as it is performed by separate hardware - although, with the assumption that clock domains misalignment, present between individual hardware pieces, is negligible). 但是,它也是唯一不需要目标PC的额外软件的选项(因此使用目标CPU的0%处理能力) - 而且也是唯一一个能够为视频提供真实 ,无抖动帧率的视频fps(因为它是由单独的硬件执行 - 尽管假设时钟域未对准,存在于各个硬件之间,可忽略不计)。

Actually, as I already own something like a capture card, I have already invested in a VGA converter - in expectation that it will eventually allow me to produce final "merged" videos with only 5 mins of looking for alignment point, and a single command line; 实际上,由于我已经拥有了像捕获卡这样的东西,我已经投资了一个VGA转换器 - 期望它最终会让我产生最终的“合并”视频,只需要5分钟寻找对齐点,并且只需要一个命令线; but I am yet to see whether this process will work as intended. 但我还没看到这个过程是否会按预期运作。 I'm also wandering how possible it will be to capture desktop as uncompressed video @ 800x600, 30 fps. 我也在徘徊如何将桌面捕获为未压缩的视频@ 800x600,30 fps。

recordMyDesktop recordMyDesktop

Well, if you run recordMyDesktop without any arguments - it starts first with capturing (what looks like) raw image data, in a folder like /tmp/rMD-session-7247 ; 好吧,如果你运行recordMyDesktop而没有任何参数 - 它首先启动捕获(看起来像什么)原始图像数据,在像/tmp/rMD-session-7247这样的文件夹中; and after you press Ctrl-C to interrupt it, it will encode this raw image data into an .ogv. 按Ctrl-C中断后,它会将原始图像数据编码为.ogv。 Obviously, grabbing large image data on the same hard disk as my test software (which also moves large ammounts of data), is usually a cause for an instacrash :) 显然,在我的测试软件(也移动大量数据)的同一硬盘上抓取大图像数据通常是一个instacrash的原因:)

Hence, what I tried doing is to setup Samba to share a drive on the network; 因此,我尝试做的是设置Samba在网络上共享驱动器; then on the target PC, I'd connect to this drive - and instruct recordMyDesktop to use this network drive (via gvfs ) as its temporary files location: 然后在目标PC上,我将连接到此驱动器 - 并指示recordMyDesktop使用此网络驱动器(通过gvfs )作为其临时文件位置:

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

Note that, while this command will use the network location for temporary files (and thus makes it possible for recordMyDesktop to run in parallel with my software) - as soon as you hit Ctrl-C, it will start encoding and saving capture.ogv directly on the local hard drive of the target (though, at that point, I don't really care :) ) 请注意,虽然此命令将使用临时文件的网络位置(因此可以使recordMyDesktop与我的软件并行运行) - 只要按下Ctrl-C,它就会开始编码并直接保存capture.ogv在目标的本地硬盘上(虽然,在那一点上,我真的不在乎:))

First of my nags with recordMyDesktop is that you cannot instruct it to keep the temporary files, and avoid encoding them, on end: you can use Ctrl+Alt+p for pause - or you can hit Ctrl-C quickly after the first one, to cause it to crash; 我首先使用recordMyDesktop指出你不能指示它保留临时文件,并避免对它们进行编码,最后:你可以使用Ctrl + Alt + p暂停 - 或者你可以在第一个之后快速按下Ctrl-C,导致它崩溃; which will then leave the temporary files ( if you don't hit Ctrl-C quickly enough the second time, the program will "Cleanning up cache..." ). 然后将保留临时文件( 如果第二次没有足够快地按Ctrl-C,程序将“清理缓存...” )。 You can then run, say: 然后你可以跑,说:

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

... in order to convert the raw temporary data. ...为了转换原始临时数据。 However, more often than not, recordMyDesktop will itself segfault in the midst of performing this "rescue". 然而,通常, recordMyDesktop本身会在执行此“救援”过程中出现段错误。 Although, the reason why I want to keep the temp files, is to have the uncompressed source for the picture-in-picture montage. 虽然,我想保留临时文件的原因是为了具有画中画蒙太奇的未压缩源。 Note that the " --on-the-fly-encoding " will avoid using temp files altogether - at the expence of using more CPU processing power (which, for me, again is cause for crashes.) 请注意,“ --on-the-fly-encoding ”将完全避免使用临时文件 - 因为使用了更多的CPU处理能力(对我来说,这也是造成崩溃的原因)。

Then, there is the framerate - obviously, you can set requested framerate using the ' --fps N ' option; 然后,有帧率 - 显然,你可以使用' --fps N '选项设置请求的帧率; however, that is no guarantee that you will actually obtain that framerate; 但是,这并不能保证您实际获得该帧速率; for instance, I'd get: 例如,我得到:

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

... for a capture with my test software running; ...用我的测试软件运行捕获; which means that the actually achieved rate is more like 25*2983/6032 = 12.3632 fps! 这意味着实际实现的速率更像是25 * 2983/6032 = 12.3632 fps!

Obviously, frames are dropped - and mostly that shows as video playback is too fast . 显然,帧被丢弃 - 大多数情况表明视频播放速度太快 However, if I lower the requested fps to 12 - then according to saved/total reports, I achieve something like 11 fps; 但是,如果我将请求的fps降低到12 - 那么根据已保存/总报告,我实现了11 fps; and in this case, video playback doesn't look 'sped up'. 在这种情况下,视频播放看起来并没有“加速”。 And I still haven't tried aligning such a capture with a live video - so I have no idea if those frames that actually have been saved, also have an accurate timestamp. 而且我还没有尝试将这样的捕获与实时视频对齐 - 所以我不知道那些实际上已经保存的帧是否也有准确的时间戳。

VNC capture VNC捕获

The VNC capture, for me, consists of running a VNC server on the 'target' PC, and running vncrec (twibright edition) on the 'recorder' PC. 对我来说,VNC捕获包括在'目标'PC上运行VNC服务器,以及在'记录器'PC上运行vncrec (twibright版本)。 As VNC server, I use vino , which is "System/Preferences/Remote Desktop (Preferences)". 作为VNC服务器,我使用vino ,即“系统/首选项/远程桌面(首选项)”。 And apparently, even if vino configuration may not be the easiest thing to manage, vino as a server seems not too taxing to the 'target' PC; 显然,即使vino配置可能不是最容易管理的东西, vino作为服务器似乎也不会对“目标”PC造成太大的负担; as I haven't experienced crashes when it runs in parallel with my test software. 因为当它与我的测试软件并行运行时我没有遇到过崩溃。

On the other hand, when vncrec is capturing on the 'recorder' PC, it also raises a window showing you the 'target' desktop as it is seen in 'realtime'; 另一方面,当vncrec在“录音机”PC上捕捉时,它还会vncrec一个窗口,显示“目标”桌面,就像在“实时”中看到的那样; when there are large updates (ie whole windows moving) on the 'target' - one can, quite visibly, see problems with the update/refresh rate on the 'recorder'. 当'目标'上有大量更新(即整个窗口移动)时 - 可以非常明显地看到'记录器'上的更新/刷新率问题。 But, for only small updates (ie just a cursor moving on a static background), things seem OK. 但是,对于只有小的更新(即只是在静态背景上移动的光标),事情似乎没问题。

This makes me wonder about one of my primary questions with this post - what is it, that sets the framerate in a VNC connection? 这让我想知道这篇文章的一个主要问题 - 它是什么,它在VNC连接中设置帧率?

I haven't found a clear answer to this, but from bits and pieces of info ( see refs below ), I gather that: 我没有找到一个明确的答案,但是从一点一滴的信息( 参见下面的参考资料 ),我收集到:

  • The VNC server simply sends changes (screen changes + clicks etc) as fast as it can, when it receives them ; VNC服务器只是在收到更改时,尽可能快地发送更改(屏幕更改+点击等); 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 VNC客户端接收由网络连接延迟和抖动的那些更改事件,并尝试再次以尽可能快的速度重建桌面“视频”流

... which means, one cannot state anything in terms of a stable, periodic frame rate (as in video). ...这意味着,无法根据稳定的周期性帧率(如视频中)说明任何内容。

As far as vncrec as a client goes, the end videos I get usually are declared as 10 fps, although frames can be rather displaced/jittered (which then requires the cutting in video editors). 就作为客户端的vncrec ,我得到的最终视频通常被声明为10 fps,尽管帧可以相当移位/抖动(然后需要在视频编辑器中剪切)。 Note that the vncrec-twibright/README states: " The sample rate of the movie is 10 by default or overriden by VNCREC_MOVIE_FRAMERATE environment variable, or 10 if not specified. "; 请注意, vncrec-twibright / README表示:“ 默认情况下,电影的采样率为10,或者由VNCREC_MOVIE_FRAMERATE环境变量覆盖,如果未指定,则为10。 ”; however, the manpage also states " VNCREC_MOVIE_FRAMERATE - Specifies frame rate of the output movie. Has an effect only in -movie mode. Defaults to 10. Try 24 when your transcoder vomits from 10. ". 但是,联机帮助页还指出“ VNCREC_MOVIE_FRAMERATE - 指定输出影片的帧速率。仅在-movie模式下有效。默认为10.当您的代码转换器从10呕吐时尝试24 ”。 And if one looks into " vncrec/sockets.c " source, one can see: 如果查看“ 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. ...这表明有些时间戳被写入 - 但是这些时间戳是来自“原始”“目标”PC还是“记录器”,我无法分辨。 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 ; 编辑 :感谢@kanaka的回答,我再次检查了vncrec / sockets.c ,并且可以看到它是writeLogHeader函数本身调用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 ). 所以它写入的时间戳是本地的 - 也就是说,它们来自'记录器'PC( 因此,这些时间戳不能准确地描述帧何时来自'目标'PC )。

In any case, it still seems to me, that the server sends - and vncrec as client receives - whenever ; 在任何情况下,在我看来,服务器发送 - 和vncrec作为客户端接收 - 只要 ; and it is only in the process of encoding a video file from the raw capture afterwards, that some form of a frame rate is set/interpolated. 并且仅在之后从原始捕获编码视频文件的过程中,设置/插入某种形式的帧速率。

I'd also like to state that on my 'target' laptop, the wired network connection is broken ; 我还要说明,在我的“目标”笔记本电脑上, 有线网络连接已断开 ; so the wireless is my only option to get access to the router and the local network - at far lower speed than the 100MB/s that the router could handle from wired connections. 所以无线是我唯一可以访问路由器和本地网络的选择 - 速度远低于路由器可以通过有线连接处理的100MB / s。 However, if the jitter in captured frames is caused by wrong timestamps due to load on the 'target' PC, I don't think good network bandwidth will help too much. 但是,如果捕获帧中的抖动是由于“目标”PC上的负载导致的错误时间戳引起的,那么我认为良好的网络带宽不会有太大帮助。

Finally, as far as VNC goes, there could be other alternatives to try - such as VNCast server ( promising, but requires some time to build from source, and is in "early experimental version" ); 最后,就VNC而言,可能还有其他的尝试选择 - 例如VNCast服务器( 很有希望,但需要一些时间从源代码构建,并处于“早期实验版本” ); or MultiVNC ( although, it just seems like a client/viewer, without options for recording ). MultiVNC虽然,它看起来像一个客户端/查看器,没有录制选项 )。

ffmpeg with x11grab 使用x11grab进行ffmpeg

Haven't played with this much, but, I've tried it in connection with netcat ; 没玩过这么多,但是,我已经尝试过与netcat ; this: 这个:

# '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  #

... does capture a file, but ffplay cannot read the captured file properly; ...确实捕获文件,但ffplay无法正确读取捕获的文件; while: 而:

# '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). 确实产生了.png图像 - 但是有压缩工件( yuv4mpegpipe涉及压缩的结果,我猜)。

Thus, I'm not liking ffmpeg + x11grab too much currently - but maybe I simply don't know how to set it up for my needs. 因此,我现在不太喜欢ffmpeg + x11grab - 但也许我根本不知道如何根据我的需要进行设置。

*( graphics card -> DMA -> network ) *(显卡 - > DMA - >网络)

I am, admittedly, not sure something like this exists - in fact, I would wager it doesn't :) And I'm no expert here, but I speculate: 我承认,我不确定这样的东西是否存在 - 事实上,我会赌不会:)我不是这里的专家,但我推测:

if DMA memory transfer can be initiated from the graphics card (or its buffer that keeps the current desktop bitmap) as source , and the network adapter as destination - then in principle, it should be possible to obtain an uncompressed desktop capture with a correct (and decent) framerate. 如果DMA内存传输可以从显卡(或其保持当前桌面位图的缓冲区)作为源启动 ,并且网络适配器作为目标 - 原则上应该可以获得正确的未压缩桌面捕获(和体面的)帧率。 The point in using DMA transfer would be, of course, to relieve the processor from the task of copying the desktop image to the network interface ( and thus, reduce the influence the capturing software can have on the processes running on the 'target' PC - especially those dealing with RAM or hard-disk ). 当然,使用DMA传输的重点是减轻处理器从将桌面映像复制到网络接口的任务( 从而减少捕获软件对'目标'PC上运行的进程的影响- 特别是那些处理RAM或硬盘的人

A suggestion like this, of course, assumes that: there are massive ammounts of network bandwidth ( for 800x600, 30 fps at least 800*600*3*30 = 43200000 bps = 42 MiB/s, which should be OK for local 100 MB/s networks ); 当然,这样的建议假定:网络带宽有很大的数量( 800x600,30 fps至少800 * 600 * 3 * 30 = 43200000 bps = 42 MiB / s,本地100 MB应该可以/ s networks ); plenty of hard disk on the other PC that does the 'recording' - and finally, software that can afterwards read that raw data, and generate image sequences or videos based on it :) 在其他PC上进行“录制”的大量硬盘 - 最后,软件可以随后读取原始数据,并根据它生成图像序列或视频:)

The bandwidth and hard disk demands I could live with - as long as there is guarantee both for a stable framerate and uncompressed data; 我可以忍受的带宽和硬盘需求 - 只要保证稳定的帧速率和未压缩的数据; which is why I'd love to hear if something like this already exists. 这就是为什么我喜欢听到这样的事情已经存在的原因。

-- -- -- -- -- - - - - -

Well, I guess that was it - as brief as I could put it :) Any suggestions for tools - or process(es), that can result with a desktop capture 嗯,我想就是这样 - 尽可能简短:)任何针对桌面捕获可能产生的工具或进程的建议

  • in uncompressed format (ultimately convertible to uncompressed/lossless PNG image sequence), and 以未压缩格式(最终可转换为未压缩/无损PNG图像序列),和
  • with a "correctly timecoded", stable framerate 具有“正确时间编码”,稳定的帧速率

..., that will ultimately lend itself to 'easy', single command-line processing for generating 'picture-in-picture' overlay videos - will be greatly appreciated! ...,这将最终适合'简单',单一的命令行处理,以生成'画中画'重叠视频 - 将不胜感激!

Thanks in advance for any comments, 提前感谢您的任何意见,
Cheers! 干杯!


References 参考

  1. Experiences Producing a Screencast on Linux for CryptoTE - idlebox.net 体验在Linux上为CryptoTE制作截屏视频 - idlebox.net
  2. The VideoLAN Forums • View topic - VNC Client input support (like screen://) VideoLAN论坛•查看主题 - VNC客户端输入支持(如screen://)
  3. VNCServer throttles user inpt for slow client - Kyprianou, Mark - com.realvnc.vnc-list - MarkMail VNCServer限制用户进入慢客户端 - Kyprianou,Mark - com.realvnc.vnc-list - MarkMail
  4. Linux FAQ - X Windows: How do I Display and Control a Remote Desktop using VNC Linux常见问题解答 - X Windows:如何使用VNC显示和控制远程桌面
  5. How much bandwidth does VNC require? VNC需要多少带宽? RealVNC - Frequently asked questions RealVNC - 常见问题解答
  6. x11vnc: a VNC server for real X displays x11vnc:用于实际X显示的VNC服务器
  7. HowtoRecordVNC (an X11 session) - Debian Wiki HowtoRecordVNC(X11会话) - Debian Wiki
  8. Alternative To gtk-RecordMyDesktop in Ubuntu 替代Ubuntu中的gtk-RecordMyDesktop
  9. (Ffmpeg-user) How do I use pipes in ffmpeg (Ffmpeg-user)如何在ffmpeg中使用管道
  10. (ffmpeg-devel) (PATCH) Fix segfault in x11grab when drawing Cursor on Xservers that don't support the XFixes extension (ffmpeg-devel)(PATCH)在不支持XFixes扩展的Xservers上绘制Cursor时修复x11grab中的segfault

You should get a badge for such a long well though out question. 你应该得到一个很长的问题徽章。 ;-) ;-)

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. 在回答您的主要问题时,VNC使用RFB协议,该协议是远程帧缓冲协议(因此是首字母缩略词)而不是流视频协议。 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. VNC客户端向服务器发送FrameBufferUpdateRequest消息,该消息包含客户端感兴趣的视口区域和增量标志。 If the incremental flag is not set then the server will respond with a FrameBufferUpdate message that contains the content of the region requested. 如果未设置增量标志,则服务器将使用包含所请求区域内容的FrameBufferUpdate消息进行响应。 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. 如果设置了增量标志,则服务器可以使用FrameBufferUpdate消息进行响应,该消息包含自上次向该区域发送客户端以来所请求的区域的任何部分。

The definition of how requests and updates interact is not crisply defined. 请求和更新如何交互的定义没有明确定义。 The server won't necessarily respond to every request with an update if nothing has changed. 如果没有任何更改,服务器不一定会响应每个具有更新的请求。 If the server has multiple requests queued from the client it is also allowed to send a single update in response. 如果服务器有多个从客户端排队的请求,则还允许发送单个更新作为响应。 In addition, the client really needs to be able to respond to an asynchronous update message from the server (not in response to a request) otherwise the client will fall out of sync (because RFB is not a framed protocol). 此外,客户端确实需要能够响应来自服务器的异步更新消息(不响应请求),否则客户端将失去同步(因为RFB不是成帧协议)。

Often clients are simply implemented to send incremental update requests for the entire frame buffer viewport at a periodic interval and handle any server update messages as they arrive (ie no attempt is made to tie requests and updates together). 通常,客户端被实现为以定期间隔发送对整个帧缓冲器视口的增量更新请求,并在它们到达时处理任何服务器更新消息(即,没有尝试将请求和更新联系在一起)。

Here is a description of FrameBufferUpdateRequest messages. 以下是FrameBufferUpdateRequest消息的描述。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM