I wanna reverse a video which loaded from gallery and Camera. video converts into image frames and frames convert into reverse video using ffmpeg commands.
- 
                    are you able to convert into image-frames? – Pushpendra Dec 28 '16 at 05:33
 - 
                    You would use the reverse filter if you are using a command line ffmpeg or just decode all the frames and reverse. This will use tons of memory though and the ffmpeg documentation warns against this. – Steve M Dec 28 '16 at 05:34
 - 
                    yes, i got all frames – Kalpesh Kumawat Dec 28 '16 at 08:14
 - 
                    can you write command for get reverse video from all image frames – Kalpesh Kumawat Dec 28 '16 at 08:15
 
3 Answers
From https://stackoverflow.com/a/8137637/2930834
The latter of which follows:
Dump all video frames
$ ffmpeg -i input.mkv -an -qscale 1 %06d.jpg
Dump audio
$ ffmpeg -i input.mkv -vn -ac 2 audio.wav
Reverse audio
$ sox -V audio.wav backwards.wav reverse
Cat video frames in reverse order to FFmpeg as input
$ cat $(ls -t *jpg) | ffmpeg -f image2pipe -vcodec mjpeg -r 25 -i - -i backwards.wav -vcodec libx264 -vpre slow -crf 20 -threads 0 -acodec flac output.mkv
Use mencoder to deinterlace PAL dv and double the frame rate from 25 to 50, then pipe to FFmpeg.
$ mencoder input.dv -of rawvideo -ofps 50 -ovc raw -vf yadif=3,format=i420 -nosound -really-quiet -o - | ffmpeg -vsync 0 -f rawvideo -s 720x576 -r 50 -pix_fmt yuv420p -i - -vcodec libx264 -vpre slow -crf 20 -threads 0 video.mkv
Also worth checking,
I haven't tried it. Hope this helps
- 
                    I haven't tried it. I will, When I'm free. What is the error you are facing ? – Nakul Dec 28 '16 at 09:19
 - 
                    
 - 
                    and my command is [-y, -i, -start_number, 100, -i, /storage/emulated/0/Frame Folder/img%03d.png, /storage/emulated/0/Kalpesh Folder/VID_reverse.mp4] – Kalpesh Kumawat Dec 29 '16 at 07:35
 - 
                    Are you absolutely sure path is correct if so, try adding %20 instead of space in Frame Folder. Command should look like [-y, -i, -start_number, 100, -i, /storage/emulated/0/Frame%20Folder/img%03d.png, /storage/emulated/0/Kalpesh Folder/VID_reverse.mp4] or rename Frame Folder to Frame_Folder etc ..... – Nakul Dec 30 '16 at 09:52
 - 
                    
 
1.Divide video into segments with duration of 10 seconds or less(below command has 6 seconds)
String[] complexCommand = {"-i", inputFileAbsolutePath, "-c:v", "libx264", "-crf", "22", "-map", "0", "-segment_time", "6", "-g", "9", "-sc_threshold", "0", "-force_key_frames", "expr:gte(t,n_forced*6)", "-f", "segment", outputFileAbsolutePath};
2.Reverse the segmented videos
With Audio
String command[] = {"-i", inputFileAbsolutePath, "-vf", "reverse", "-af", "areverse", outputFileAbsolutePath};
Without Audio
String command[] = {"-i",inputFileAbsolutePath, "-vf", "reverse", outputFileAbsolutePath};
3.Concatenate reversed segmented videos in reverse order
With Audio
String command[] = {"-i",inputFile1AbsolutePath,"-i",inputFile2AbsolutePath .....,"-i",inputFileNAbsolutePath,"-filter_complex","[0:v0] [0:a0] [1:v1] [1:a1]...[N:vN] concat=n=N:v=1:a=1 [v] [a],"-map","[v]","-map","[a]", outputFileAbsolutePath};
Without Audio
String command[] = {"-i",inputFile1AbsolutePath,"-i",inputFile2AbsolutePath .....,"-i",inputFileNAbsolutePath,"-filter_complex","[0:0] [1:0] [2:0]...[N:0] concat=n=N:v=1:a=0",outputFileAbsolutePath};
For detailed explanation check out this and sample code here
- 9,157
 - 18
 - 82
 - 139
 
This sample code is only video reverse not included audio.
build.gradle
compile 'com.writingminds:FFmpegAndroid:0.3.2'
Before command execute, you need to load binary first
FFmpeg ffmpeg = FFmpeg.getInstance(this);
try {
        ffmpeg.loadBinary(new FFmpegLoadBinaryResponseHandler() {
        @Override
        public void onFailure() {
        }
        @Override
        public void onSuccess() {
        }
        @Override
        public void onStart() {
        }
        @Override
        public void onFinish() {
        }
        });
        } catch (FFmpegNotSupportedException e) {
             e.printStackTrace();
       }
After load binary, you can execute your command.
String strInputVideoPath = dir.getAbsolutePath()  + "/" + "1543999518815.mp4";
String strRevOutputVideoPath = dir.getAbsolutePath() + "/" + "reverse.mp4";    
String[] cmdRevVid = {"-i",  strInputVideoPath,"-vf","reverse", strRevOutputVideoPath};
            try {
                ffmpeg.execute(cmdRevVid, new ExecuteBinaryResponseHandler(){
                    @Override
                    public void onStart() {
                    }
                    @Override
                    public void onProgress(String message) {
                    }
                    @Override
                    public void onFailure(String message) {
                    }
                    @Override
                    public void onSuccess(String message) {
                        try{
                        }catch (Exception ex){
                        }
                    }
                    @Override
                    public void onFinish() {
                    }
                });
            } catch (FFmpegCommandAlreadyRunningException e) {
                // Handle if FFmpeg is not supported by device
            }
In my case, I have to do reverse video and concat video itself. Reference Post
String[] cmdFinal = {"-i",  dir.getAbsolutePath()  + "/" + "inputVideo.mp4",
                "-filter_complex", "[0:v]reverse,fifo[r];[0:v][r] concat=n=2:v=1 [v]",
                "-map", "[v]",
                dir.getAbsolutePath() + "/" + "final.mp4"};
- 1,863
 - 1
 - 25
 - 40