Linux 将 swf 渲染为 png 或其他图像格式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9641550/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Render swf to png or other image format
提问by James T
How can I, on linux, render a swf to a image file? I need to be able to load other swfs into that swf and run actionscript code.
我如何在 linux 上将 swf 渲染到图像文件?我需要能够将其他 swf 加载到该 swf 中并运行 actionscript 代码。
Is it even possible on linux? I need to do it from PHP, it's fine if I have to use command-line tools.
在linux上甚至可能吗?我需要用 PHP 来做,如果我必须使用命令行工具也没关系。
采纳答案by Appleman1234
swfrender
from swftoolsworks for basic SWF files.
swfrender
来自swftools适用于基本 SWF 文件。
swfdec-thumbnailer
from swfdec-gnomeworks though it only gets the first frame of the swf.
swfdec-thumbnailer
来自swfdec-gnome 的工作虽然它只获取 swf 的第一帧。
To get any frame from swf using swfdec see the C code snippet in the following mailing list post.
要使用 swfdec 从 swf 获取任何框架,请参阅以下邮件列表帖子中的 C 代码片段。
gnash
from gnashalso works gnash -s<scale-image-factor> --screenshot last --screenshot-file output.png -1 -r1 input.swf
, last image of the swf.
gnash
来自gnash也有效gnash -s<scale-image-factor> --screenshot last --screenshot-file output.png -1 -r1 input.swf
,swf 的最后一张图片。
ffmpeg
from ffmpegalso works for some swf formats ffmpeg -i movie.swf -f image2 -vcodec png movie%d.png
ffmpeg
来自ffmpeg也适用于某些 swf 格式ffmpeg -i movie.swf -f image2 -vcodec png movie%d.png
Also see the following guidefor a commandline pipeline.
另请参阅以下命令行管道指南。
In order to call external programs from php you use the exec
command documented here.
为了从 php 调用外部程序,请使用此处exec
记录的命令。
Note that for security reasons it is important to escape arguments passed to exec
with another command like escapeshellcmd
or escapeshellarg
for security reasons.
请注意,出于安全原因,重要的是转义传递给exec
另一个命令的参数,例如escapeshellcmd
或escapeshellarg
出于安全原因。
Once you have converted to an image format whether for single frame or all frame, you can't run action script. Other non GNU / Linux tools support the export of the action script from from SWF.
无论是单帧还是全帧转换为图像格式后,您都无法运行动作脚本。其他非 GNU/Linux 工具支持从 SWF 导出动作脚本。
If the SWF that you are exporting to PNG is too complicated for the other tools than you can use the Flash Plugin or Gnash
and Xvfb
along with screen capture software to capture either image frames of the SWF or a video format like avi. Then you can extract the images from the video format.
如果要导出到PNG的SWF太复杂了其他工具比你可以使用Flash插件或Gnash
并Xvfb
用屏幕捕捉软件一起拍摄的AVI视频格式的SWF的任何图像帧或。然后您可以从视频格式中提取图像。
This virtual framebuffer method will support complicated SWF files, though it requires a lot of work as you need to use either Gnash and Xvfb and Screen Capture, or a browser , Xvfb and Selenium, if you want to capture a certain set of mouse / keyboard interactions with the SWF.
这种虚拟帧缓冲方法将支持复杂的 SWF 文件,但它需要大量工作,因为您需要使用 Gnash 和 Xvfb 和屏幕捕获,或者浏览器、Xvfb 和 Selenium,如果您想捕获一组特定的鼠标/键盘与 SWF 的互动。
Gnash with and without the Virtual FrameBuffer should load the ActionScript before exporting, but may have issues with complicated ActionScript. Flash Plugin with Virtual Framebuffer will load the ActionScript before exporting.
使用和不使用 Virtual FrameBuffer 的 Gnash 应该在导出之前加载 ActionScript,但可能会遇到复杂的 ActionScript 问题。Flash Plugin with Virtual Framebuffer 将在导出之前加载 ActionScript。
Also see the following StackOverFlow questions, which you question is a duplicate of
另请参阅以下 StackOverFlow 问题,您提出的问题与
回答by James T
This is the solution I ended up using.
这是我最终使用的解决方案。
You can use a tool like Xvfb(X11 server) and run the standalone flash player projector inside it (you may need to install a bunch of 32-bit libraries), then use a screen capture utility like importto capture the screen and crop it to size.
您可以使用像Xvfb(X11 服务器)这样的工具并在其中运行独立的 Flash Player 投影仪(您可能需要安装一堆 32 位库),然后使用像import这样的屏幕捕获实用程序来捕获屏幕并裁剪它到大小。
I found this pageon rendering swf screenshots in linux helpful. It also says that you can use gnash to do this, however gnash won't work for flash player 9+.
我发现这个关于在 linux 中渲染 swf 屏幕截图的页面很有帮助。它还说您可以使用 gnash 来执行此操作,但是 gnash 不适用于 Flash Player 9+。
回答by Joe Yang
Try this air application http://swfrenderer.kurst.co.uk
试试这个空气应用http://swfrenderer.kurst.co.uk
It render swf frame by frame
它逐帧渲染 swf