Display two videos together then output as a merged video on a single screen

前端 未结 3 765
北恋
北恋 2021-02-14 01:35

This question may sound a little bit complex or ambiguous, but I\'ll try to make it as clear as I can. I have done lots of Googling and spent lots of time but didn\'t find anyth

相关标签:
3条回答
  • 2021-02-14 01:43

    I would start with JavaCV. It's quite good and flexible. It should allow you to grab frames, composite them and write them back to a file. Use FFmpegFrameGrabber and Recorder classes. The composition can be done manually.

    The rest of the answer depends on few things:

    • do you want to read from a file/mem/url?
    • do you want to save to a file/mem/url?
    • do you need realtime processing?
    • do you need something more than simple picture-in-picture?
    0 讨论(0)
  • 2021-02-14 01:44

    You could use OpenGL to do the trick. Please note however that you will need to have to render steps, one rendering the first video in a FBO and then the second rendering the second video, using the FBO as TEXTURE0 and the second as EXTERNAL_TEXTURE.

    Blending, and all the stuff you want would be done by OpengL.

    You can check the source codes here: Using SurfaceTexture in Android and some important information here: Android OpenGL combination of SurfaceTexture (external image) and ordinary texture

    The only thing I'm not sure is what happens when two instances of mediaplayer are running in Parallel. I guess it should not be a problem.

    0 讨论(0)
  • 2021-02-14 01:55

    ffmpeg is a very active project, lot's of changes and releases all the time.

    You should look at the Xuggler project, this provides a Java API for what you want to do, and they have tight integration with ffmpeg.

    http://www.xuggle.com/xuggler/

    Should you choose to go down the Runtime.exec() path, this Red5 thread should be useful:

    http://www.nabble.com/java-call-ffmpeg-ts15886850.html

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