3
votes

I've developed an Android app that allows user to create boomerang-alike mp4 video. This video consists of 10 still images being played back and forth quite fast. I know that such video (boomerang effect) can be easily looped from single video file while playing it, but I really need to create a mp4 video that would essentially contain already prepared boomerang video. The output video can be downloaded and played by user on any external player (over which obviously I don't have any control).

For that purpose currently I create a video from images in a loop. The loop starts from 1st picture and goes to 10th picture with 0.25 sec delay between frames, then goes back from 10th to 1st including delay. And there is 5 of those loops, which essentialy means creating a single video from 5 * 10 * 2 = 100 images. I know it's kinda ridiculous, so the time that it takes to prepare this video is riduculous as well (around 1:40 min).

What solution could you recommend assuming that the output video really has to consist of 5 loops back-and-forth? I've thought about creating single loop video (20 pictures) and then create final output video by concatenating it 5 times. But could it be any good? I'm trying to find an efficient yet understandable for a beginner Android programmer way.

2
Try using FFMPEG library maybe - ChristopheCVB

2 Answers

6
votes

You can use FFMPEG to Create boomerang like video below is a simple example code :-

ffmpeg -i input_loop.mp4 -filter_complex "[0]reverse[r];[0][r]concat,loop=5:250,setpts=N/55/TB" output_looped_video.mp4

1.5 seconds of video file as input named input_loop.mp4

setpts=N/<VALUE>/TB" you can alter value according to your need

increase value to speed up boomerang effect

decrease value to slow down boomerang effect

0
votes

I was looking for a way to create a boomerang video and found a pretty cool example of how to do it on GitHub. You create the video by using the FFMPEG library org.bytedeco.javacpp-presets to clone the frames.

https://github.com/trantrungduc/boomerang-android

This is the place in code in which you can customize the video loop:

for (int k = 0; k < 3; k++) {
    for (Frame frame1 : loop) {
        frecorder.record(frame1);
    }
    for (int i=loop.size()-1;i>=0;i--){
        frecorder.record(loop.get(i));
    } 
}