Adding audio to video with ffmpeg not working - flutter

I try to add audio to a video with ffmpeg.
Here´s my code:
ffmpeg -i $videoPath -i ${finalSong.path} -codec copy -shortest $tempPath/$newVideoFileName.mp4")
Without the -shortest the video duration is the long duration from my .mp3 file. So the file exists as well. Also if I try to play it with an audio player it works well. But the exported video always is without audio...
Do you have an idea where the issue is?
By the way: I´m using it on a Flutter application.

Related

flutter_ffmpeg - Can we trim a part of the video in flutter while recording

I am making a flutter app, in which a user can record a video and pause in between, and when the user pauses the video a clip is formed.
So if the 4 clips are there, then 4th clip can be removed from the video (according to the time of the last clip).
By a clip I just mean the time interval between two continuous pauses. The video is being recorded continuously.
There's a way to trim a video after it's being record, for example,
ffmpeg -ss 00:01:00 -i input.mp4 -to 00:02:00 -c copy output.mp4
But I think it's possible only when the video is recorded.
So, Is there any way to to trim a video (using flutter_ffmpeg) or the last clip, while the recording is paused ?

How to record using AVAudioRecorder without the .caf container?

I am using a AVAudioRecorder instance to record with the setting for AVFormatIDKey set to kAudioFormatMPEG4AAC. It records the audio in AAC format but a .caf audio container packages the audio file. (I can see the caff header in the recorder file).
How do I record so that the caff container is not there but in pure m4a format so that I can use the files across platforms.
Found the answer.
There is a weird way the AVAudioRecorder works.
The format in which the AVAudioRecorder will save your file depends on the URL/string you specify for the file you save. It depends on the extension of the file name you are saving.
If you don't specify any extension or one that the recorder can't understand then it will add the Core Audio container.
So, basically see to that the extension and the AVFormatIDKey match.
Like for aac use format use .aac extension with kAudioFormatMPEG4AAC as the AVFormatIDKey

how to create flv videoframe from h.264 AAC samples in mp4

I have a mp4 file which has only mdat box(h.264, aac) and I can specify the video samples. I need to convert video samples to flv frames, how can be done?
This can be done using ffmpeg.
ffmpeg -i in.mp4 out.flv

How to add video to audio file on iphone SDK

I got success to combine audio and video with the help of this link.
How to add audio to video file on iphone SDK
It create video file of video length but i want to create it of audio length.
For example my video file is of 10 seconds and audio file of 20 seconds then combined video must be 20 seconds.Any idea ?
See: http://www.ffmpeg.org/ffmpeg-doc.html#SEC12

SoundManager + FFMPEG causing loud popping sound when streaming MP3s?

I built an application that plays both uploaded original mp3 files, and copies that have been converted with FFMPEG. I am finding that in some cases the FFMPEG files have a horrible popping/clicking/screeching sound for a split second at startup (hear below). But when I analyze the file in an audio editor there is nothing there, so it seems to be either the browser or soundManager reacting badly to something in that file. Wondering if there is any way I can fix this either by adjusting FFMPEG settings, soundManager settings, or..... Any suggestions?
I've uploaded the offending sound in the link below (before the music starts playing).
Hear sound
Screeching/clicking at the beginning often points to a badly formed mp3 file. (There are a lot of them in the wild.)
Try checking both the original and converted files with mp3check -e -B
If you get errors, adding mp3check --cut-junk-start to your pipline should work.