将动画序列从Flash导出为JPEG

时间:2022-10-25 21:16:12

I'm wondering if it's possible at all to sort of record/capture the state of an swf movie over a period of time and save it all down as jpgs to the server?

我想知道是否有可能在一段时间内记录/捕获swf电影的状态并将其全部保存为jpgs到服务器?

AS3 has the new com.adobe.images.JPGEncoder class that seems to do the job, but can I capture a sequence? The hope would be that I could put it back together as a video or animation.

AS3有新的com.adobe.images.JPGEncoder类似乎可以完成这项工作,但是我可以捕获一个序列吗?希望是我可以把它作为视频或动画重新组合在一起。

Is there other ways to encode swf to video programmatically?

还有其他方法可以编程方式将swf编码为视频吗?

1 个解决方案

#1


I have done a "screen capture" before using the JPGEncoder, so I think you should be able to capture the screen on the ENTER_FRAME event. This may not work as JPG encoding isn't super fast.

我在使用JPGEncoder之前做了一个“屏幕截图”,所以我认为你应该能够在ENTER_FRAME事件上捕获屏幕。这可能不起作用,因为JPG编码不是非常快。

That is how I would go about doing it. For your reference, here's some code that does this(for a single screenshot):

这就是我要去做的方式。供您参考,这里有一些代码可以执行此操作(对于单个屏幕截图):

var fileReference:FileReference = new FileReference();

// Capture the BitmapData of the stage for example
var captureMovieClip:DisplayObjectContainer = stage;

var stage_snapshot:BitmapData = new BitmapData(captureMovieClip.width, captureMovieClip.height);
stage_snapshot.draw(captureMovieClip);

// Setup the JPGEncoder, run the algorithm on the BitmapData, and retrieve the ByteArray
var encoded_jpg:JPGEncoder = new JPGEncoder(100); 
var jpg_binary:ByteArray = encoded_jpg.encode(stage_snapshot);

// save
fileReference.save(jpg_binary, "screenshot.jpg");

You can probably extend this to be called in your ENTER_FRAME event handler, and then save the file to different filenames. Also instead of the stage, you can use a different display object.

您可以扩展它以在ENTER_FRAME事件处理程序中调用,然后将文件保存到不同的文件名。也可以使用不同的显示对象代替舞台。

I don't know how fast this will run, you may need to lower the frame rate so the ENTER_FRAME isn't called so much, but you'll lose some quality in your JPG renderings.

我不知道它的运行速度有多快,你可能需要降低帧速率,这样就不会调用ENTER_FRAME这么多,但是你的JPG渲染会失去一些质量。

Also turning down the quality in the line: new JPGEncoder(100) from 100 to a lower value may help with file sizes of the jpegs(but may or may not incur more overhead with compression).

同时调低行中的质量:新的JPGEncoder(100)从100到较低的值可能有助于jpeg的文件大小(但可能会或可能不会产生更多的压缩开销)。

#1


I have done a "screen capture" before using the JPGEncoder, so I think you should be able to capture the screen on the ENTER_FRAME event. This may not work as JPG encoding isn't super fast.

我在使用JPGEncoder之前做了一个“屏幕截图”,所以我认为你应该能够在ENTER_FRAME事件上捕获屏幕。这可能不起作用,因为JPG编码不是非常快。

That is how I would go about doing it. For your reference, here's some code that does this(for a single screenshot):

这就是我要去做的方式。供您参考,这里有一些代码可以执行此操作(对于单个屏幕截图):

var fileReference:FileReference = new FileReference();

// Capture the BitmapData of the stage for example
var captureMovieClip:DisplayObjectContainer = stage;

var stage_snapshot:BitmapData = new BitmapData(captureMovieClip.width, captureMovieClip.height);
stage_snapshot.draw(captureMovieClip);

// Setup the JPGEncoder, run the algorithm on the BitmapData, and retrieve the ByteArray
var encoded_jpg:JPGEncoder = new JPGEncoder(100); 
var jpg_binary:ByteArray = encoded_jpg.encode(stage_snapshot);

// save
fileReference.save(jpg_binary, "screenshot.jpg");

You can probably extend this to be called in your ENTER_FRAME event handler, and then save the file to different filenames. Also instead of the stage, you can use a different display object.

您可以扩展它以在ENTER_FRAME事件处理程序中调用,然后将文件保存到不同的文件名。也可以使用不同的显示对象代替舞台。

I don't know how fast this will run, you may need to lower the frame rate so the ENTER_FRAME isn't called so much, but you'll lose some quality in your JPG renderings.

我不知道它的运行速度有多快,你可能需要降低帧速率,这样就不会调用ENTER_FRAME这么多,但是你的JPG渲染会失去一些质量。

Also turning down the quality in the line: new JPGEncoder(100) from 100 to a lower value may help with file sizes of the jpegs(but may or may not incur more overhead with compression).

同时调低行中的质量:新的JPGEncoder(100)从100到较低的值可能有助于jpeg的文件大小(但可能会或可能不会产生更多的压缩开销)。