how to add mkv file in avasset and extract video and audio from that?(swift) - swift

i want to extract mkv's video and audio in AVasset and merge it in mp4 container and display it in swift UI?
i tried this Convert .mkv file into .mp4 file in swift 3 but that's does not worked

Related

Adding audio to video with ffmpeg not working

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.

Avplayer implement subtitles using .srt file in iOS swift

How to implement subtitles using .srt file with avplayer in iOS. When using the avplayer is there a way to use .srt file in avplayer to show the subtitle on the player
You can't just put .srt file in your AVPlayer and show them.
If you can put subtitles inside your .m3u8 HLS stream on server side - this will be the solution to handle subtitles by AVPLayer automatically.
Until then - I'm using this library
Very simple to use and is handling all for you.

How to record audio in .aac, .mp3, .wav format

I am new in ios developement.I have created a simple voice recording using file extension of .caf format. It will record in .caf file.while tap the play button it working fine.But I want to record in .aac,mp3,wav format and also i need to implement quality like low,medium, high.
Please help me to do this.
What you can achieve is convert the .caf file to .wav or .mp3 after you have downloaded it successfully.
Here some ways are mentioned
How to use afconvert to convert from .caf to .mp3 format?
Converting mp3 to caf file for iPhone
How to convert a wav or caf audio file on iPhone
Please have a look at them . Hope they help.
I have also faced same problem.I wanted to record audio in .mp3 format, but i didn't find any code for doing that.But what you can do is you can rename the extension of your audio file.
You just rename extension .caf to .mp3 and it also works great..
You can check it..
Cheers,
Nirav
You can record a wav file by setting AVFormatIDKey to kAudioFormatLinearPCM

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