How to create a video from an array of images in Android?

后端 未结 9 884
时光说笑
时光说笑 2020-12-04 10:32

I want to call a function and build a video out of list of images, and then save it locally on the device:

public void CreateAndSaveVideoFile(List

        
相关标签:
9条回答
  • 2020-12-04 11:34

    I created a project that should be able to handle this. The code is light and fairly straight forward.

    https://github.com/dburckh/bitmap2video

    0 讨论(0)
  • 2020-12-04 11:36

    If the minimum version of you application Android SDK is greater or equal to 16 (Android 4.1) the best way of video encoding is use Android Media Codec API.

    From Android 4.3 APIs.

    When encoding video, Android 4.1 (SDK 16) required that you provide the media with a ByteBuffer array, but Android 4.3 (SDK 18) now allows you to use a Surface as the input to an encoder. For instance, this allows you to encode input from an existing video file or using frames generated from OpenGL ES.

    Media Muxer added in Android 4.3 (SDK 18) so for convenient way of writing mp4 file with Media Muxer you should have SDK>=18.

    Using Media Codec API way you will get hardware accelerated encoding and you are easily encode up to 60 FPS.

    You can start from 1) How to encode Bitmaps into a video using MediaCodec? or use 2) Google Grafika or 3) Bigflake.

    Starting from Grafika RecordFBOActivity.java. Replace Choreographer event with you own containing bitmap to encode, remove On Screen drawing, load you bitmap as Open GL Texture and draw it on Media Codec Input Surface.

    0 讨论(0)
  • 2020-12-04 11:37

    Abhishek V was right, more information about jcodec SequenceEncoder: see Android make animated video from list of images

    Recently I have built a real-time video system using raspberry pi and Android devices, met the same problem as yours. Instead of saving a list of image files, I used some real-time streaming protocols like RTP/RTCP to transfer data stream to user. If your requirement is something like this, maybe you could change your strategies.

    Another suggestion is that you may explore some C/C++ libraries, using NDK/JNI to break the limitation of Java.

    Hope the suggestions make sense to you :)

    0 讨论(0)
提交回复
热议问题