AviSynth内存不足错误

AviSynth内存不足错误

本文介绍了AviSynth内存不足错误(100幅图像叠加)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不同的时间在视频上叠加多张图像.我将用户功能定义为

I want to overlay multiple images on my video at different times. I have user function defined as

function myFunction(clip c, int coordinateX, int from, int to) {
    c = c.trim(0, from-1) + c.trim(from, to).Overlay(myImage, x=coordinateX, y=667, mask=myImageMask, opacity=1) + c.trim(to+1, 0)
    return c
}

本质上是获取myImage图像并将其放置在剪辑的特定部分上.

which essentially takes myImage image and place it on specific part of the clip.

我将函数称为

video = video.myFunction(320, 1, 187)

我有很多这样的东西(我正在尝试制作具有多个图像的某种动画)

and I have bunch of those like this (I'm trying to make some sort of animation with multiple images)

video = video.myFunction(320, 1, 187)
video = video.myFunction(480, 1, 187)
video = video.myFunction(640, 1, 187)
video = video.myFunction(320, 187, 374)
video = video.myFunction(480, 187, 374)
video = video.myFunction(640, 187, 374)
video = video.myFunction(319, 374, 561)

,如果这些呼叫少于约400个,则一切正常.如果超过该限制,则会发生内存不足"(我正在使用VirtualDub).

and everything works fine if there is less than ~400 of those calls. If I exceed that limit, "Out of Memory" occurs (I'm using VirtualDub).

我认为这是因为AviSynth必须处理所有调用才能确定输出(尽管在这100个调用中只有 3个特定的单个帧相关).但是,如果我在行首删除video =,则可能有10000个,并且没有内存不足"错误,但是我当然没有视频输出.

I suppose it's because AviSynth must process all the calls to figure out the output (although only ~3 of those 100s of calls are related to specific single frame). If I however remove video = at the beginning of the line, I could have 10000 of those and there is no "Out of Memory" error but of course I don't have video out.

有没有解决的办法?在视频剪辑的不同时间有成百上千的图像叠加?

Is there a fix to this? Hundreds/thousands of image overlays at different times on the video clip?

推荐答案

在覆盖"ConvertToYUY2()"之前,尝试将视频和所有图像转换为YUY2色彩空间,这可能会减少每个调用的重新转换量,如下所述此处- http://avisynth.nl/index.php/Overlay#Repeated_overlays_on_RGB_base_clip 假设您的视频和图像为RGB.您可能还可以尝试使用YV12色彩空间,也许它将节省更多的内存.请注意,由于彩色通道使用YV24以外的格式降低了分辨率,并且还会存在转换错误,因此这会导致质量稍有下降.

Try to convert the video and all images to YUY2 colorspace before overlaying with "ConvertToYUY2()", this might probably decrease the amount of reconversions on every call as explained here - http://avisynth.nl/index.php/Overlay#Repeated_overlays_on_RGB_base_clipThat's assuming your video and images are in RGB. You can probably try to use also YV12 colorspace, maybe it will save even more memory. Note that it will cause slight quality decrease since color channels have reduced resolution in formats other than YV24 plus there are conversion errors too.

这篇关于AviSynth内存不足错误(100幅图像叠加)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 01:32