Search code examples
androidvideoffmpegandroid-ffmpeg

Reverse video and loop 2 times ffmpeg


I need to reverse the input video and concat it then the loop the output video twice. I was able to achieve reversing and concat it with original video using

ffmpeg -i input.mkv -filter_complex "[0:v]reverse,fifo[r];[0:v][r] concat=n=2:v=1 [v]" -map "[v]" output.mkv

But i want to stream_loop it 3 times. And also i like to know, if there's any better ways to do it. The video will be a small one(4 seconds max.) and without audio.


Solution

  • After the first command,

    ffmpeg -i input.mkv -filter_complex "[0:v]reverse,fifo[r];[0:v][r] concat=n=2:v=1 [v]" -map "[v]" output.mkv

    you can run

    ffmpeg -stream_loop 2 -i output.mkv -c copy output3.mkv
    

    To do it in one go,

    ffmpeg -i input.mkv -filter_complex "[0:v]reverse,split=3[r1][r2][r3];[0:v][r1][0:v][r2][0:v][r3] concat=n=6:v=1[v]" -map "[v]" output.mkv

    With recent versions of ffmpeg, you shouldn't need fifo filters.