Merging two MP3 audio files - android

I am trying to use ffmpeg library for mixing two MP3 or wav audio files using the commands available that I searched over Internet like given below:
ffmpeg -i input1.mp3 -i input2.mp3 -filter_complex amerge -c:a libmp3lame -q:a 4 output.mp3
From link How to overlay two audio files using ffmpeg
Also, tried some many other solutions given on the different forms.
But none of them is working for the the library downloaded from link:
https://github.com/hiteshsondhi88/ffmpeg-android-java.
But when I am trying to run the commands available on the intener, in some commands I am getting different different error like,
-- Unable to find suitable output format for 'ffmpeg' ffmpeg: Invalid argument
And I also tried one more command,
String res = "ffmpeg -y -i " + a.getAbsolutePath() + " -i " + b.getAbsolutePath() + " -filter_complex '[0:0][1:0] amix=inputs=2:duration=longest' -c:a libmp3lame " + c.getAbsolutePath();
It's giving error, No such filter:" Error configuring filters.

What is your version of FFmpeg?
I believe it's old and that's why it's not working.
First setp download newest version from official site try if your command it's working if yes than find another (or build your own) compiled for android executable file

Well First check your FFmpeg version. The way you have used the amix filter have to be changed. amix filter mix audios. So following is what I'm suggesting.
ffmpeg -i input_audio1 -i input_audio2 -filter_complex "aevalsrc=0:d=10[s1];
[s1][1:a]concat=n=2:v=0:a=1[ac1];
[0:a][ac1]amix[aout]" -map [aout] -c:a libmp3lame output_audio
you can append a silent audio which duration is same as the first audio and them use amix over them. So the original audio's will not overlap. aevalsrc will create a silent audio with a duration of 10 sec. Also you need to select appropriate codec for your output accordingly. You can find those codec here.
Hope this helps!

I know it's been some time since this question was posted, but I think your main problem is that you shouldn't include "ffmpeg" on your string.
So your cmd line would be:
String res = "-y -i " + a.getAbsolutePath() + " -i " + b.getAbsolutePath() + " -filter_complex '[0:0][1:0] amix=inputs=2:duration=longest' -c:a libmp3lame " + c.getAbsolutePath();

Related

ffmpeg - 'No such file or directory' though the file exists

I am running following command to extract audio from videos and merge them into a single file:
-y -hide_banner -i /storage/emulated/0/Videos/video_4.mp4 -i /storage/emulated/0/WhatsApp/Media/WhatsApp Video/VID-20210430-WA0010.mp4 -i /storage/emulated/0/WhatsApp/Media/WhatsApp Video/VID-20210430-WA0052.mp4 -filter_complex [0:a]atrim=duration=1119.028,volume=1[a_0];[1:a]atrim=duration=84.057,volume=1[a_1];[2:a]atrim=duration=278.029,volume=1[a_2];[a_0][a_1][a_2]concat=n=3:v=0:a=1[audio] -map [audio] -acodec aac -vn /storage/emulated/0/Videos/audio.aac
But ffmpeg says
/storage/emulated/0/Videos/video_4.mp4: No such file or directory
I can ensure that the file exist on that specified path. What might cause the issue?
Note: The same error occures for some other comands too, but in all the cases the video file exist in the specified path.
I had the same problem, I installed it using snap.
So, as a solution, I tried uninstalling using remove and purge, and then I used mv /snap/bin/ffmpeg /snap/bin/ffmpeg_old.
Then I installed using apt-get install ffmpeg, and worked. I guess the problem was the version of ffmpeg.

How to merge multiple .mp4 file in single .mp4 ffmpeg android

I am merging multiple .mp4 file into single .mp4 after merging only first .mp4 is displayed properly and other video is not displayed.
I used this ffmpeg command
ffmpeg -f concat -i " + strTextPath + " -c copy " + strFinalMergedVideoPath;

Command in ffmpeg for merge image and generated video

I am using ffmpeg in android for create video from multiple images, it has done and now i want to add more images in generated video. i found many times but not getting any proper command in ffmpeg for that.please help
Try using this command,
1.
ffmpeg -y -framerate 1/2 -start_number 1 -i img/%1d.jpg -vf scale=720:756 -c:v libx264 -r 10 -pix_fmt yuv420p videos.mp4
If you want to add watermark image to your generated video, you can use this one:
2.
ffmpeg -i videos.mp4 -i watermark_img.jpg -filter_complex "overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -codec:a copy watermark_videos.mp4
In order to create video from random images, You have to keep all images in dir called img, as you can see in first command, and just name all images in the dir, like: 1.jpg,2.jpg...N.jpg,etc , you have to name all the images in sequential number format, which is required by the ffmpeg command as you can see in the first command -i img/%1d.jpg , here -start_number 1 indicates it should start from image preceding with 1 number, and go on with all the images stored in img/ dir, sequentially.
In order to understand the ffmeg command please read all of it's CLI parameters:
man ffmpeg
OR
ffmpeg --help

Convert aac to mp3 using ffmpeg binary command in android

I'm trying to use ffmpeg binary to convert aac format to mp3 format in andorid
I am too referring to a example here: https://github.com/sjitech/ffmpeg-android
What I tried with failure is
p = Runtime.getRuntime().exec("/data/data/myapp/app_bin/ffmpeg -i /sdcard/chua.aac -acodec libmp3lame -ac 2 -ab 160 /sdcard/chua.mp3");
I make sure that "/sdcard/chua.aac" exists on my phone
I guess the problem may come from libmp3lame in the command which is disabled in ffmpeg binary when building before with the example but I'm not very sure
Please someone reveal what my problem is and how to fix it.

ffmpeg commands for merge the image with video file in android

I am working on add watermark on video file in android with the use of ffmpeg jni what i have not found any solution for the same . i am using this command "ffmpeg -i alldone.mp4 -i cancel_bttn.png -filter_complex "overlay=main_w/2-overlay_w/2:main_h/2-overlay_h/2" record.mp4 " but this was not worked.

Categories

Resources