Java: How do I create a movie from an array of images?

前端 未结 4 806
野趣味
野趣味 2020-11-27 17:11

I basically have an matrix of bytes. Each row (meaning byte[]) represents an image. How do I create a movie out of that (any format - avi, mpeg, whatever), and save it as a

4条回答
  •  一向
    一向 (楼主)
    2020-11-27 17:51

    I wrote an MJPEG reader and writer for playing videos inside of Java applets. MJPEG is not the most advanced video format but it is very easy to manipulate. The code is part of my computer vision library BoofCV, but you could just rip out this one class for your own purposes.

    1. Download this file: CreateMJpeg.java
    2. Look at main function. Where it reads in jpeg images put your byte[] data, but you will need to convert it to jpeg's first.
      • You can convert it into a jpeg using the standard java library
    3. Run modified code and enjoy your movie

    Sorry its not in a more user friendly format, but at least you don't need to mess with JNI like some other solutions.

提交回复
热议问题