FFmpeg Video Editor

FFmpeg is a tool that can be used to edit or convert videos and audios.It includes libavcodec – the audio/video codec library.
Some of the uses of FFmpeg are:

  • Video Compress
  • Audio Compress
  • Video Cut
  • Video Rotate
  • Video Crop
  • Extract Picture from Video
  • Extract Sound from Video
  • Change Video Resolution
  • Adding filters to videos
  • Creating fast and slow motion video
  • Reverse Video
  • Creating video from images
  • Convert video from one format into another
  • Merge an audio and video

For integrating FFmpeg in android we can use precompiled libraries like ffmpeg-android.
ffmpeg-android is a library by WritingMinds that simplifies your task of using ffmpeg in Android project.

Below post covers integration of following features using FFmpeg-

  • Video Compress
  • Video Cut
  • Extract Picture from Video
  • Extract Audio from Video
  • Add Fade In Fade Out effect to Video
  • Creating Fast Motion Video
  • Creating Slow Motion Video
  • Reverse Video

Besides these following features have been discussed in comments section-

  • Merging audio and video
  • Speed up video 3x, 4x times
  • Creating video from images
  • Segmenting video
  • Adding watermark

I have used RangeSeekBar to allow user to select the time range for cutting video from original video.

Complete code for the post is uploaded on github at below link-

https://github.com/bhuvnesh123/FFmpeg-Video-Editor-Android

and the demo app is published on play store-

https://play.google.com/store/apps/details?id=videoeditor.bhuvnesh.com.ffmpegvideoeditor

Integrating FFmpeg library

1.Add FFmpeg dependency in app module gradle file and sync project. 

compile ‘com.writingminds:FFmpegAndroid:0.3.2’

2.Load FFMpeg using below code-

FFmpeg ffmpeg;
private void loadFFMpegBinary() {
try {
if (ffmpeg == null) {
Log.d(TAG, “ffmpeg : null”);
ffmpeg = FFmpeg.getInstance(this);
}
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
@Override
public void onFailure() {
showUnsupportedExceptionDialog();
}

@Override
public void onSuccess() {
Log.d(TAG, “ffmpeg : correct Loaded”);
}
});
} catch (FFmpegNotSupportedException e) {
showUnsupportedExceptionDialog();
} catch (Exception e) {
Log.d(TAG, “EXception not supported : ” + e);
}
}

loadBinary copies the ffmpeg binary to device according to device’s architecture. You just need to put this once in your code, whenever you are starting the application or using FFmpeg for the first time.

3.Create a method which will take ffmpeg command as an argument and pass it to execute method of FFMpeg class.

private void execFFmpegBinary(final String[] command) {
try {
ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {
@Override
public void onFailure(String s) {
Log.d(TAG, “FAILED with output : ” + s);
}

@Override
public void onSuccess(String s) {
Log.d(TAG, “SUCCESS with output : ” + s);
//Perform action on success
}
}

@Override
public void onProgress(String s) {
Log.d(TAG, “progress : ” + s);
}

@Override
public void onStart() {
Log.d(TAG, “Started command : ffmpeg ” + command);
}

@Override
public void onFinish() {
Log.d(TAG, “Finished command : ffmpeg ” + command);

}
});
} catch (FFmpegCommandAlreadyRunningException e) {

}
}

execute() method of FFmpeg class takes command as parameter and executes it.It has a ResponseHandler which return event on start,progress,finish,success and failure.

Now we will go through the various FFmpeg commands that we can use to perform different operations-

Compress a video

To compress a video we can use below command-

String[] command = {"-y", "-i", inputFileAbsolutePath, "-s", "160x120", "-r", "25", "-vcodec", "mpeg4", "-b:v", "150k", "-b:a", "48000", "-ac", "2", "-ar", "22050", outputFileAbsolutePath};

Here,

-y

Overwrite output files without asking.

-i

ffmpeg reads from an arbitrary number of input “files” specified by the -i option

-s

video output size

-r

Set frame rate

-vcodec

Set the video codec.

-b:v

Set the video bitrate

-b:a

Set the audio bitrate
-ac

Set the number of audio channels.

-ar

sets the sampling rate for audio streams if encoded

Cut a video

To cut a video we can use below command-

String[] complexCommand = {"-ss", "" + startMs / 1000, "-y", "-i", inputFileAbsolutePath, "-t", "" + (endMs - startMs) / 1000, "-s", "320x240", "-r", "15", "-vcodec", "mpeg4", "-b:v", "2097152", "-b:a", "48000", "-ac", "2", "-ar", "22050", outputFileAbsolutePath};

Here,

-ss
seeks to position(time from where we want to start cutting video)
-t
limit the duration of data read from the input file(duration from cutting start position time upto which we want to cut video)

Other options already defined in previous command

Remove -s 320×240 if you want to keep the resolution of original video.

Extract images from video

To extract images from a video we can use below command

String[] complexCommand = {"-y", "-i", inputFileAbsolutePath, "-an", "-r", "1/2", "-ss", "" + startMs / 1000, "-t", "" + (endMs - startMs) / 1000, outputFileAbsolutePath};

Here,

-an
Disable audio recording.

-r 1/2 will extract one image frame from every 2 second of video.Similarly,-r 1/4 will extract one image frame from every 4 seconds of video and -r 1 will extract one image frame from every second of video.

Remove -r option(-r 1/2 in above command) if you want to extract all video frames as images from the specified time duration.

Other options already defined in previous commands

Extract audio from video

To extract audio from a video we can use below command

String[] complexCommand = {"-y", "-i", inputFileAbsolutePath, "-vn", "-ar", "44100", "-ac", "2", "-b:a", "256k", "-f", "mp3", outputFileAbsolutePath};

-vn

Disable video recording

-f

format

Other options already defined in previous commands

Add Fade In Fade Out effect at start and end of video

To add Fade In and Fade Out effect to start and end of video respectively we can use below command

String[] complexCommand = {"-y", "-i", inputFileAbsolutePath, "-acodec", "copy", "-vf", "fade=t=in:st=0:d=5,fade=t=out:st=" + String.valueOf(duration - 5) + ":d=5", outputFileAbsolutePath};

Here,

-acodec

Set the audio codec

vf filtergraph (output)

Create the filtergraph specified by filtergraph and use it to filter the stream.

fade=t=in:st=0:d=5

Fade in first 5 seconds of video
fade=t=out:st=”+String.valueOf(duration-5)+”:d=5″

Fade out last 5 seconds of video

Other options already defined in previous commands

Fast Motion Video

To create fast motion video we can use below command-

String[] complexCommand = {"-y", "-i", inputFileAbsolutePath, "-filter_complex", "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]", "-map", "[v]", "-map", "[a]", "-b:v", "2097k", "-r", "60", "-vcodec", "mpeg4", outputFileAbsolutePath};

-filter_complex filtergraph (global)

Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or outputs.

[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]

The filter works by changing the presentation timestamp (PTS) of each video frame. For example, if there are two succesive frames shown at timestamps 1 and 2, and you want to speed up the video, those timestamps need to become 0.5 and 1, respectively. Thus, we have to multiply them by 0.5.

You can speed up or slow down audio with the atemto audio filter.The atempo filter is limited to using values between 0.5 and 2.0 (so it can slow it down to no less than half the original speed, and speed up to no more than double the input).To speed up the audio to double of its speed we have to use atempo value 2.0 .

-map

-map option is a way to tell FFmpeg which streams do you want to select/copy from input to an output.When you want to control which streams are included then you will need/want to specify the “-map” command manually, and change these parameters.

-map [v] -map [a] – Select the streams labeled v and a
-map 0 -Select all streams from input 0.

Check out this for detailed explanation on map option

Other options already defined in previous commands

Slow Motion Video

To create a slow motion video we can use the below command-

String[] complexCommand = {"-y", "-i", inputFileAbsolutePath, "-filter_complex", "[0:v]setpts=2.0*PTS[v];[0:a]atempo=0.5[a]", "-map", "[v]", "-map", "[a]", "-b:v", "2097k", "-r", "60", "-vcodec", "mpeg4", outputFileAbsolutePath};

The filter works by changing the presentation timestamp (PTS) of each video frame.To slow down your video, you have to use a multiplier greater than 1. For example, if there are two succesive frames shown at timestamps 1 and 2, and you want to slow down the video, those timestamps need to become 2 and 4, respectively.Thus, we have to multiply them by 2.0.

You can speed up or slow down audio with the atemto audio filter.The atempo filter is limited to using values between 0.5 and 2.0 (so it can slow it down to no less than half the original speed, and speed up to no more than double the input).To slow down the audio to half of its speed we have to use atempo value 0.5 .

Other options already defined in previous commands.

Reverse Video

For reversing video,first we need to divide video into segments with duration of 10 seconds or less because reverse video command for ffmpeg will not work for long duration videos unless your device has 32 GB of RAM.

Hence,to reverse a video-

1.Divide video into segments with duration of 10 seconds or less.
2.Reverse the segmented videos
3.Concatenate reversed segmented videos in reverse order.

For dividing video into segments with duration of 6 seconds we can use the below command-

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};

-c:v libx264

encodes all video streams with libx264

-crf

Set the quality for constant quality mode.

-segment_time

time for each segment of video

-g

GOP size

-sc_threshold

set scene change threshold.

-force_key_frames expr:gte(t,n_forced*n)

Forcing a keyframe every n seconds

 

After segmenting video,we need to reverse the segmented videos.For that we need to run a loop where each segmented video file will be reversed.

To reverse a video with audio(without removing its audio) we can use the below command-

String command[] = {"-i", inputFileAbsolutePath, "-vf", "reverse", "-af", "areverse", outputFileAbsolutePath};

To reverse a video with audio removing its audio we can use the below command-

String command[] = {"-i", inputFileAbsolutePath, "-an", "-vf", "reverse", outputFileAbsolutePath};

To reverse a video without audio we can use the below command-

String command[] = {"-i",inputFileAbsolutePath, "-vf", "reverse", outputFileAbsolutePath};

 

After reversing segmented videos,we need to concatenate reversed segmented videos in reverse order.For that we sort videos on the basis of last modified file using Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_REVERSE).

Then, to concatenate  reversed segmented videos(with audio) we can use the below command-

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};

To concatenate  reversed segmented videos(without audio) we can use the below command-

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};

 

-filter_complex [0:v0] [0:a0] [1:v1] [1:a1]…[N:vN] tells ffmpeg what streams to send to the concat filter.In the above case, video stream 0 [0:v0] and audio stream 0 [0:a0] from input 0,video stream 1 [1:v1] and audio stream 1 [1:v1] from input 1 and so on.

concat filter is used to concatenate audio and video streams, joining them together one after the other.The filter accepts the following options:

n

Set the number of segments. Default is 2.
v

Set the number of output video streams, that is also the number of video streams in each segment. Default is 1.
a

Set the number of output audio streams, that is also the number of audio streams in each segment. Default is 0.

Adding presets

FFmpeg provides certain presets which are collection of options that provide certain speed to the process. Presets in descending order of speed are: ultrafast,superfast, veryfast, faster, fast, medium, slow, slower, veryslow. The default preset is medium.Utrafast preset is specially useful where command is taking too much time to execute and you want to speed up the process.Example while compressing,fading or reversing large size videos.To use preset just add “-preset”, “ultrafast” to the command.
Example-
String command[] = {“-i”, inputFileAbsolutePath,”-preset”, “ultrafast”, “-vf”, “reverse”, “-af”, “areverse”, outputFileAbsolutePath};

The general guideline is to use the slowest preset that you have patience for.
Please check out here for detailed explanation on choosing a preset.

 

Please feel free to post any queries,doubts or suggestions in comments section or contact me and I will get back to you as soon as possible!

If you like my post please rate it as it will mean a lot to me!

Advertisements

70 thoughts on “FFmpeg Video Editor

    • Hi Omi,

      For merging audio and video where input video file contains audio ,you can use below command-

      String command[] = {"-i",videoFileAbsolutePath,"-i",audioFileAbsolutePath, "-c:v", "copy", "-c:a", "aac","-map", "0:v:0", "-map", "1:a:0","-shortest", destinationAbsolutePath};

      For merging audio and video where input video file does not contain any audio stream ,you can use below command-

      String command[] = {"-i",videoFileAbsolutePath,"-i",audioFileAbsolutePath, "-c:v", "copy", "-c:a", "aac","-shortest", destinationAbsolutePath};

      Like

      • how can we merge video and audio , when audio is shorter , put it in a loop, and change volume of both audio and video file

        Like

      • 1.Get the duration of audio file and video file using MediaMetadataRetriever.
        2.When audio is shorter,calculate how many times we need to concatenate audio so that its duration is equal or more than video.For example if audio is 30 seconds and video is of 2 minutes we need to concatenate audio 4 times.
        3.Run concatenate audio ffmpeg command.
        4.Merge the concatenated audio with video.

        Like

    • You can use below command to create a slow motion video removing audio from original video-

      String[] complexCommand = {"-y", "-i", inputFileAbsolutePath,"-an", "-filter:v", "setpts=2.0*PTS", "-b:v", "2097k", "-r", "60", "-vcodec", "mpeg4", outputFileAbsolutePath}

      Here -an removes audio

      Like

  1. Hi, How can i combine two commands to run one after the other before getting the output file. I have a working code for cutting a video and a separate code for decreasing speed, but i want them to run together so that when the command is invoked, a selected section of the video is cut and then its speed reduced before saving the final output.

    Also is there a code to convert video to gif format using ffmpeg?

    Thanks for your response in advance.

    Like

  2. Hello!
    What is the best way to compress the video? What parameters should I use?
    I tried to do it your way and I can’t open the file when I search it in my phone. I get Cannot play video…..Unsupported file type

    Code:
    String[] command = {“-y”, “-i”, filePath, “-s”, “640×480”, “-r”, “25”, “-vcodec”,
    “mpeg4”, “-b:v”, “150k”, “-b:a”, “48000”, “-ac”, “2”, “-ar”, “22050”, compressedFilePath};
    executeFFmpegBinary(command);

    Like

      • Yeah i figured it out…!! also used image overlay.. everything work so great… but my app size increased from 5mb to 23mb.. 🙂

        Like

    • You cant do anything about that.. i searched about that… But you can add in string this “-preset”, “ultrafast”
      this will make conversion a lot faster!!

      Like

    • To speed up video 4x times use-

      [0:v]setpts=0.25*PTS[v];[0:a]atempo=2.0[2a];[2a]atempo=2.0[4a]

      The atempo filter is limited to using values between 0.5 and 2.0 (so it can slow it down to no less than half the original speed, and speed up to no more than double the original speed in single atempo filter). To get around this limitation we need to use multiple atempo filter.

      Similarly to speed up video 3x times use-

      [0:v]setpts=0.33*PTS[v];[0:a]atempo=2.0[2a];[2a]atempo=1.5[3a]

      Remember to change -map option accordingly.
      Example-

      String[] complexCommand = {"-y", "-i", inputFileAbsolutePath, "-filter_complex", "[0:v]setpts=0.33*PTS[v];[0:a]atempo=2.0[2a];[2a]atempo=1.5[3a]", "-map", "[v]", "-map", "[3a]", "-b:v", "2097k", "-r", "60", "-vcodec", "mpeg4", outputFileAbsolutePath};

      Now you can calculate for 5x times!

      Like

  3. I’m currently using your FFmpeg-Video-Editor-Android-master Application, I’d like to know i could change the complexCommand such that i can extract every frame image from the last 45 frames of a 30fps video.

    Current Complex Command:
    String[] complexCommand = {“-y”, “-i”, yourRealPath, “-an”, “-r”, “1/2”, “-ss”, “” + startMs / 1000, “-t”, “” + (endMs – startMs) / 1000, dest.getAbsolutePath()};

    Like

    • Remove “-r”, “1/2” if you want to extract all video frames as images.Since your video is 30 fps video and you want to extract last 45 frames..that means you want to extract all frames of last 1.5 second video(1500 milliseconds).So ,your startMs should be equal to total duration of video in milliseconds – 1500 milliseconds and endMs should be equal to total duration of video in milliseconds.

      Like

  4. unable to use backpress with ffmpeg

    when use this code in an activity and the ffmpeg.execute() is called it disables onBackPressed() , since there is a progress dialog and it is set to alog.setCancelable(false); there is no way to stop the command

    ffmpeg can be disabled

    this is the command I am trying

    @Override
    public void onBackPressed() {
    Toast.makeText(videStickerTryAct.this, “back press”, Toast.LENGTH_SHORT).show();

    if(ffmpeg!= null) {
    if (ffmpeg.isFFmpegCommandRunning()) {
    ffmpeg.killRunningProcesses();
    }
    if (progressDialog!= null)
    {
    progressDialog.cancel();
    }
    }
    }

    but back press is not called at all?

    Like

    • Set

      progressDialog.setCancelable(true)

      if you want to dismiss dialog on backpress while command is running.Use

      progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                  @Override
                  public void onCancel(DialogInterface dialog) {
                      if(ffmpeg.isFFmpegCommandRunning())
                      ffmpeg.killRunningProcesses();
                  }
              });
      

      to kill running processes while dismissing dialog.

      Like

  5. unable to use backpress with ffmpeg

    when use this code in an activity and the ffmpeg.execute() is called it disables onBackPressed() , since there is a progress dialog and it is set to alog.setCancelable(false); there is no way to stop the command

    ffmpeg can be disabled

    this is the command I am trying

    @Override
    public void onBackPressed() {
    Toast.makeText(tryer.this, “back press”, Toast.LENGTH_SHORT).show();

    if(ffmpeg!= null) {
    if (ffmpeg.isFFmpegCommandRunning()) {
    ffmpeg.killRunningProcesses();
    }
    if (progressDialog!= null)
    {
    progressDialog.cancel();
    }
    }
    }

    but back press is not called at all?

    Like

    • Set

      progressDialog.setCancelable(true)

      if you want to dismiss dialog on backpress while command is running.Use

      progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                  @Override
                  public void onCancel(DialogInterface dialog) {
                      if(ffmpeg.isFFmpegCommandRunning())
                      ffmpeg.killRunningProcesses();
                  }
              });
      

      to kill running processes while dismissing dialog.

      Like

      • unfortuantely there is an error in the writingminds code according to this (there is no proper support aswell, they updated the code but not the gradle, giving out old code instead )

        https://github.com/WritingMinds/ffmpeg-android-java/issues/79

        I downlaoded and tried the writingmids code as normal android files, but It gives me error of device not supported, any idea how we can use the JNI , Obj and Libs that they have provided, in our code directly (I mean just download the code and build an app with it, like we do with other projects on github, instead of using gradle )

        Like

    • Use below command to create video from images placed in same folder

      String command[]={"-y", "-r","1/5" ,"-i",src.getAbsolutePath(),
          "-c:v","libx264","-vf", "fps=25","-pix_fmt","yuv420p", dest.getAbsolutePath()};

      Here ,

      src.getAbsolutePath() is the absolute path of all your input images.

      For example,
      If all your images are stored in Images folder inside Pictures directory with names
      **extract_picture001.jpg,extract_picture002.jpg,extract_picture003.jpg……**

      .
      Then,

          String filePrefix = "extract_picture";
          String fileExtn = ".jpg";
          File picDir = Environment.getExternalStoragePublicDirectory(
          Environment.DIRECTORY_PICTURES);
          File dir = new File(picDir, "Images");
          File src = new File(dir, filePrefix + "%03d" + fileExtn);
      

      For creating video from images placed in different folder you
      have to create a text file and add image paths to it and then specify
      the path of that text file as an input option.
      Example,

      Text File

          file '/storage/emulated/0/DCIM/Camera/P_20170807_143916.jpg'
          duration 2
          file '/storage/emulated/0/DCIM/Pic/P_20170305_142948.jpg'
          duration 5
          file '/storage/emulated/0/DCIM/Camera/P_20170305_142939.jpg'
          duration 6
          file '/storage/emulated/0/DCIM/Pic/P_20170305_142818.jpg'
          duration 2
      

      Command

          String command[] = {"-y", "-f", "concat", "-safe", "0", "-i", textFile.getAbsolutePath(), "-vsync", "vfr", "-pix_fmt", "yuv420p", dest.getAbsolutePath()};
      

      where textFile.getAbsolutePath() is the absolute path of your text file

      After video is created you can use merge audio and video command which i previously posted in a comment to add audio to it.

      Like

      • Hi,
        Thanks a lot’s for posting this tutorial it’s very useful for me.one more thing i creatded video can not display proper resolution

        Like

      • Hii,
        I use this command
        String command[] = {“-y”, “-f”, “concat”, “-safe”, “0”, “-i”, mFileTemp.getAbsolutePath(), “-aspect”, “16:9”, “-s”, “1280X720”, “-c:a”, “copy”, “-vcodec”, “mpeg4”, “-b:v”, “60k”, “-vsync”, “vfr”, dest.getAbsolutePath()};

        Like

  6. Hi,
    Thanks a lot’s for posting this tutorial it’s very useful for me.One more things i want to create video from images with effects and Audio so what is the command for that.

    Like

    • Use below command to create video from images placed in same folder

      String command[]={"-y", "-r","1/5" ,"-i",src.getAbsolutePath(),
          "-c:v","libx264","-vf", "fps=25","-pix_fmt","yuv420p", dest.getAbsolutePath()};

      Here ,

      src.getAbsolutePath() is the absolute path of all your input images.

      For example,
      If all your images are stored in Images folder inside Pictures directory with names
      **extract_picture001.jpg,extract_picture002.jpg,extract_picture003.jpg……**

      .
      Then,

          String filePrefix = "extract_picture";
          String fileExtn = ".jpg";
          File picDir = Environment.getExternalStoragePublicDirectory(
          Environment.DIRECTORY_PICTURES);
          File dir = new File(picDir, "Images");
          File src = new File(dir, filePrefix + "%03d" + fileExtn);
      

      For creating video from images placed in different folder you
      have to create a text file and add image paths to it and then specify
      the path of that text file as an input option.
      Example,

      Text File

          file '/storage/emulated/0/DCIM/Camera/P_20170807_143916.jpg'
          duration 2
          file '/storage/emulated/0/DCIM/Pic/P_20170305_142948.jpg'
          duration 5
          file '/storage/emulated/0/DCIM/Camera/P_20170305_142939.jpg'
          duration 6
          file '/storage/emulated/0/DCIM/Pic/P_20170305_142818.jpg'
          duration 2
      

      Command

          String command[] = {"-y", "-f", "concat", "-safe", "0", "-i", textFile.getAbsolutePath(), "-vsync", "vfr", "-pix_fmt", "yuv420p", dest.getAbsolutePath()};
      

      where textFile.getAbsolutePath() is the absolute path of your text file

      After video is created you can use merge audio and video command which i previously posted in a comment to add audio to it.

      Like

  7. Thanks a lot for building this. Had a veryyy Hard time to find some new & fresh implementation of FFMpeg – Android.. You Saved my life. I have a Nougat device for which I had to modify the gradle and after that everything works like a charm.

    Liked by 1 person

  8. Hi!
    Thanks a lot for posting this tutorial it’s very useful for me 🙂 ı have a question,I want to shred a video in 10 seconds and I should record them.
    Please help me, thank you 🙂

    Like

  9. Oh well i work a lot with ffmpeg lately.. one thing that bothers me and cant really fix yet is that when proccess is running (ffmpeg cutting or etc.) if i close app from recents.. it doesnt clear any data or whatever.. and when i go to do an edit again it doesnt really work.. i really think the problem is in the data that dont clear..
    if someone can help me it would be great

    Like

    • Whenever you create destination file,do check if a file with same name and extension at same path already exists and if same file is already there then either delete that old file first or name the new file in such a way that no other file with same name exists at that path as done in my sample project.Secondly,inside onpause and onstop you can check if your application/activity is being destroyed and in that case if your process is not yet completed delete the destination file which you created since your process is incomplete and getting destroyed.

      Like

  10. Hi,
    I am getting error “call requires API level19(current min is 19) :android .provider.DocumentsContract.isDocumentUri” in getPath function.
    please help me.

    Like

    • I hope by combine music u mean to concatenate music.To concatenate audio with another audio use below command-

      String command[] = {"-i",inputAudioFileAbosolutePath1,"-i",inputAudioFileAbsolutePath2,"-filter_complex","[0:0] [1:0]concat=n=2:v=0:a=1[out]","-map","[out]",outputFileAbsolutePath()};

      For merging resultant audio with video where input video file does not contain any audio stream ,you can use below command-

      String command[] = {"-i",videoFileAbsolutePath,"-i",audioFileAbsolutePath, "-c:v", "copy", "-c:a", "aac","-shortest", destinationAbsolutePath};

      Here, -shortest is for finishing encoding when the shortest input stream ends.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s