简体   繁体   English

使用Java将一系列图像转换为视频?

[英]Converting a series of images to a video in Java?

Currently, the functioning prototype has everything it needs to work: A semi-transparent window for easy resizing on the place you want to record, multiple threads to manage screen shot taking, etc., but one last task I need it to do has eluded me for months. 当前,可以正常运行的原型具有工作所需的一切:一个半透明的窗口,可以轻松地调整要记录的位置的大小,有多个线程来管理屏幕截图等,但是我需要做的最后一项任务是我好几个月了。 I need to convert all of the images I dumped in a folder I made called temp (that I delete after everything is done) into a movie. 我需要将我转储到名为temp的文件夹中的所有图像(在完成所有操作后删除)转换为电影。

I already have found this, but it is a standalone sort of thing you use in a shell. 我已经找到了,但这是您在shell中使用的一种独立的东西。 I need to just tweak it so that it just converts all the images ( screencapture1.jpg , screencapture2.jpg , etc.) into a single movie. 我需要对其进行调整,以便将所有图像( screencapture1.jpgscreencapture2.jpg等)转换为单个电影。

Why can't I do this myself? 我为什么不能自己做这个? Because I suck at understanding the work of other people, programming language-wise. 因为我精于理解他人的工作,所以要明智地进行语言编程。 I don't know why, but unless it's the simplest thing, I can never seem to understand it. 我不知道为什么,但是除非这是最简单的事情,否则我似乎永远无法理解。

I'd suggest just learning how to call external programs from your java program. 我建议只是学习如何从Java程序调用外部程序。 Then you can just run that example program you linked to. 然后,您可以只运行链接到的示例程序。 Or if you want even more capability, use ffmpeg which will do this automatically from the command line as well: 或者,如果您想要更多的功能,请使用ffmpeg ,它也会从命令行自动执行此操作:

ffmpeg -i screencapture%d.jpg -vcodec mpeg4 outfile.avi

ffmpeg allows you to customize a lot of things about the output video. ffmpeg允许您自定义有关输出视频的许多内容。 Just check out the documentation for all the options. 只需查看所有选项的文档即可。

The Java command Runtime.getRuntime().exec(...) will let you run whatever command line you pass it. Java命令Runtime.getRuntime().exec(...)将允许您运行传递的任何命令行。 There are many examples of how to do this if you Google it. 如果您使用Google进行搜索,有许多示例。

I suggest to use Xuggler for this. 我建议为此使用Xuggler Here's an introduction . 这是介绍

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

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