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

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

Related

how to add mkv file in avasset and extract video and audio from that?(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

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.

Rendered audio plays in slow-mo

When decoding the audio data of an mp3 file I fetched, rendering it with my OfflineContext, and exporting it back to a .wav file, the sound is in slo-mo with a different pitch. Is it because the sample rates of my mp3 file and OfflineContext are different? If it is, how can I export the mp3 file in a different sample rate while not changing the pitch?
Edit:
I run decodeAudioData with the OfflineAudioContext that I use for the rendering: offlineContext.decodeAudioData(this.arrayBuffer). The sample rate of offlineContext is 48000, while the sample rate of my audioContext (used for normal playback, which works well) is 41000.
While creating the WAV file, the same sample rate than the offline context should be set in the WAV file header. For example, a WAV file with a sample rate of 44100 in the header that contains data chunks with a sample rate of 48000 will cause the playback to be in "slow motion" in iTunes.

Record audio on iPhone with smallest file size

I want to record audio with iPhone and then upload it to server.
I could record the audio, but my question is about which format should I use to record audio, so that the Recorder will result a file with smallest file size.
Here are the results for few encoding supported by iPhone. Size of audio file in KB of duration 10 sec.
kAudioFormatMPEG4AAC : 164,
kAudioFormatAppleLossless : 430,
kAudioFormatAppleIMA4 : 475,
kAudioFormatULaw : 889,
kAudioFormatALaw : 889,
Among these kAudioFormatMPEG4AAC is having smallest size.
Apple iOS supports playback audio in these formats:
AAC (MPEG-4 Advanced Audio Coding)
ALAC (Apple Lossless)
HE-AAC (MPEG-4 High Efficiency AAC)
iLBC (internet Low Bitrate Codec, another format for speech)
IMA4 (IMA/ADPCM)
Linear PCM (uncompressed, linear pulse code modulation)
MP3 (MPEG-1 audio layer 3)
µ-law and a-law
For recording following formats are possible:
AAC (MPEG-4 Advanced Audio Coding)
ALAC (Apple Lossless)
iLBC (internet Low Bitrate Codec, for speech)
IMA4 (IMA/ADPCM)
Linear PCM (uncompressed, linear pulse-code modulation)
µ-law and a-law
while only AAC supports hardware-assisted encoding (see Apple iOS SDK documentation)
For the universality in availability I prefer MP3.
Check these links to find exact code to record audio - Recording Audio on an iPad with AVAudioRecorder
It depends on the type of audio you are recording and the audio quality you want.
If for example, you are recording voice with the built in mic, iLBC will give you the smallest audio file (15.2 kbit/s for 20 ms frames, 13.33 kbit/s for 30 ms frames).

.caf vs .wav in iOS application

I'm using cocos2d and it is possible to play both formats using SimpleAudioEngine (obviously did not tried .caf) What format is preferable and why ?
I recommend you to use caf format with IMA4 compression for sound effects and aac for BGM.
CocosDenshion FAQ - What sound formats can I use?
For sound effects played with
CDSoundEngine it is recommended to use
16 bit mono wave files for
uncompressed audio and IMA4 for lossy
compressed audio. IMA4 sounds are
around one quarter the size of the
corresponding wave file.
How do I choose the best audio formats in iPhone OS?