How do I create an mp4 file from a collection of H.264 frames and audio frames? - audio

I have a program that captures and stores H.264 encoded video as well as audio into a proprietary format file. I need to be able to export that video and audio to an mp4 file. I prefer C# but will use C++ if necessary. Any suggestions?

To produce MPEG-4 Part 14 .MP4 file you need a multiplexer. There is a choice of multiplexers out there:
FFmpeg (libavformat)
DirectShow filters (free and open source from GDCL, commercial)
Windows 7+ Media Foundation file sink
API and complexity might vary because some of multiplexers are expected to be a part of pipeline, they are not completely standalone classes. You might want to check respective samples (and license agreements, perhaps, too) to see what is best for you.

Take a look at libmp4v2. Fairly straightforward to use..
http://code.google.com/p/mp4v2/

Related

How can I apply audio compression to an MP4 file?

I am using moviepy to generate MP4 files from sets of shorter clips, each with their own audio. The problem is that the resulting MP4 often has a very high dynamic range from one clip to the next and I would like to apply audio compression to make it easier on the ears. In Google I can only find results about audio information compression, but not about audio compression from the audio engineering perspective.
I would like to know if there is some way of doing this with moviepy, or with some other library. I have no issue with invoking (non interactive) command line utilities either.
Thank you.

File information of .raw audio files using terminal in linux

How to get file information like sampling rate, bit rate etc of .raw audio files using terminal in linux? Soxi works for .wav files but it isn't working for .raw.
If your life depended on discovering an answer you could make some assumption to tease apart the unknowns ... however there is no automated way since the missing header would give you the easy answers ...
The audio analysis tool called audacity allows you to open up a RAW file, make some guesses and play the track
http://www.audacityteam.org
In audacity goto File -> Import -> Raw Data...
Above settings are typical for audio ripped from a CD ... toy with trying stereo vs mono for starters.
Those picklist widgets give you wiggle room to discover the format of your PCM audio given that the source audio is something when properly rendered is recognizable ... would be harder if the actual audio was noise
However if you need a programmatic method then rolling your own solution to ask those same questions which appear in above window is possible ... is that what you need or will audacity work for you ? We can go down the road of writing code to play off the unknowns mentioned in #Frank Lauterwald's comment
To kick start discovering this information programmatically, if the binary raw audio is 16 bit then each audio sample (point on the audio curve) will consume two bytes of your PCM file. For mono audio then the following two bytes would be your next sample, however if its stereo then these two following bytes would be the sample from the other channel. If more than two channels then just repeat. Typical audio is little endian. Sampling rate is important when rendering the audio, not when programmatically parsing raw bytes. One approach would be to create an output file with a WAV header followed by your source PCM data. Populate the header with answers from your guesswork. This way you could listen to this output file to help confirm your guesses.
Here is a sample 500k mono PCM audio file signed 16 bit which can be imported into audacity or used as input to rolling your own identification code
The_Constructus_Corporation_Long_Street-ycexQvMy03k_excerpt_mono.pcm

How to read audio and video packets from mp4 file

I am trying to write a code in c/c++ (objective c) to parse the audio and video data from mp4 file.
I know that data in mp4 file contains under the mp4 atom but not sure how i can parse out the audio and video data separately.
Thanks in advance for any help.
Mp4 format is fairly complicated. I suggest you use a library. But if you can't use a library, or just wan to learn the format, Than you must parse about a dozen boxes or atoms under the root moov box. The information from there can be used to find frames within the mdat atom. The full specifications is numbered ISO/IEC 14496-12 You should be able to find a copy online.

ffmpeg - Can I draw an audio channel as an image?

I'm wondering if it's possible to draw an audio channel of a video or audio file as an image using ffmpeg, or if there's another tool that would do it on Win2k8 x64. I'm doing this as part of an encoding process after a user uploads a video or audio file.
I'm using ColdFusion 10 to handle the upload and calling cfexecute to run ffmpeg.
I need the image to look something like this (without the horizontal lines):
You can do this programmatically very easily.
Study the basics of FFmpeg. I suggest you to compile this sample. It explains how to open a video/audio, identify the streams and loop over the packets.
Once you have the data packet (in this case you are interested only in the audio packets). You will decode it (line 87 of this document) and obtain the raw data of an audio. It's the waveform itself (the analogue "bitmap" for an audio).
You could also study this sample. This second example is how to write a video/audio file. You don't want to write any video, but with this sample you can easily understand how the audio raw data packet works, if you see the functions get_audio_frame() and write_audio_frame().
You need to have some knowledge about creating a bitmap. Any platform has an easy way to do that.
So, the answer for you: YES, IT IS POSSIBLE TO DO THIS WITH FFMPEG! But you have to code a little bit in order to get what you want...
UPDATE:
Sorry, there are ALSO built-in features for this:
You could use those filters... or
showspectrum, showwaves, avectorscope
Here are some examples on how to use it: FFmpeg Filters - 12.22 showwaves.

Direct show samples (AMCap) on Platform SDK with MP4 file

I want to generate .mp4 file using Direct show samples (AMCap). But i don't know how to implement this.
Can anyone please help me about this?
Thanks in advance,
Dhaval Kariya
AMCap Sample captures and displays video. No encoding and choices of multiplexing into files (only basic capture/recording through a basically obsolete helper interface).
Video capture application.
This sample application demonstrates the following tasks related to
audio and video capture:
Capture to a file
Live preview
Allocation of the capture file
Display of device property pages
Device enumeration
Stream control
The items above might be confusing as they mention capture and file allocation. This is a trail of 15 years old history when file capture was a big deal. The helper object to initialize capture targets AVI and ASF/WMV only, you neither can extend it to support other formats, nor you need to.
You need to check how to store video/audio into files (see below) and follow the same steps in building the pipeline with MPEG-4 encoders and multiplexer. You will need to use a third party MPEG-4 multiplexer for MP4 file format because Windows does not provide you with such out-of-the-box usable component.
See:
Capturing Video to a File
Free DirectShow Mpeg-4 Filters

Resources