bhuvnesh123 / FFmpeg-Video-Editor-Android

Sample android project using ffmpeg for cutting and compressing video,reversing video,extracting image frames from video,extracting audio from video,add fade in fade out effect,create fast and slow motion video
540 stars 165 forks source link

Merge Audio And Video. #35

Closed SuryaChundawat closed 4 years ago

SuryaChundawat commented 4 years ago

Hi Bhuvnesh can you please guide how to merge audio and video. As I can see in your play store app has this functionality. Thanks for help.

bhuvnesh123 commented 4 years ago

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