Home:ALL Converter>Trying to merge audio with video using ffmpeg

Trying to merge audio with video using ffmpeg

Ask Time:2019-07-09T15:46:22         Author:vikram

Json Formatter

I am using ffmpeg for merging audio and video. I download a 4 second long MP3 file trying to merge but not successful. i am also trying to merge silent audio. It works but the video become half of its original length. The following command works for silent audio but cuts the video:

String mergecmd1[]={"-i",output,"-f", "lavfi" ,"-i", "aevalsrc=0", " - 
shortest", "-y", output};     

This is the command I have used for MP3 audio but it does not work:

   String cmd1[]={"-i", output ,"- 
   i","/storage/emulated/0/FestiveApp/Assets/audio.mp3" ,"-codec", "copy", 
   "-shortest", output};

         ffmpeg = FFmpeg.getInstance(Donts_Activity.this);
    try {

        ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {

            @Override
            public void onStart() {

// Log.e("ffmpeg","Exaction Start"); }

            @Override
            public void onProgress(String message) {}

            @Override
            public void onFailure(String message) {
                progressDialog.dismiss();
                Log.e("ok",message);
            }

            @Override
            public void onSuccess(String message) {
                new Sessionmanager(Donts_Activity.this).SetImageToVideoPath(output);

                Log.e("ok","success");


                progressDialog.dismiss();

                Intent intent=new Intent(Donts_Activity.this,MediaRecorderRecipe.class);
                startActivity(intent);
                finish();
            }

            @Override
            public void onFinish() {

            }
        });
    } catch (FFmpegCommandAlreadyRunningException e) {
        Log.e("ffmpeg",e.toString());
        progressDialog.dismiss();
    }

My first goal generate video with audio but video length does not be reduce or cut if i am using mp3 or silent ffmpeg audio command

Author:vikram,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/56947697/trying-to-merge-audio-with-video-using-ffmpeg
yy