Tuesday, December 4, 2012

3gp compresser and container


Multimedia Container Formats

A container format is a file format that can contain various types of data, compressed in a manner of standardized codecs. The container file is simply used to identify and interleave the different data types inside it.
Advanced container formats such as Ogg and MKV can support audio, video, subtitles, chapters, and meta-data (tags), along with the synchronization information needed for playback.

The most popular multimedia containers are:
  • AVI (standard Microsoft Windows container).
  • MOV (standard QuickTime container).
  • MP4 (standard container for the MPEG-4 multimedia portfolio).
  • Ogg (standard container for Xiph.org codecs).
  • Matroska (not standard for any codec or system, but it is an open standard).
  • ASF (standard container for Microsoft WMA and WMV).
  • RealMedia (standard container for RealVideo and RealAudio).
The differences between various container formats arise from five main issues:
  • Popularity; how widely supported a container is. This is the reason that the AVI format is still the most popular format.
  • Overhead. This is the difference in file-size between two files with the same content in a different container. For a two-hour film, when in AVI, the file may be up to 10MB larger than when in Matroska.
  • Support for advanced codec functionality. Older formats such as AVI do not support new codec features like B-frames, VBR audio, VFR natively, although the format may be tweaked to add support, creating compatibility problems.
  • Support for advanced content, such as chapters, subtitles, meta-tags, user-data.
  • Support of streaming media, media streaming on demand via the Internet.
Below in this page you can see a full comparative table between several container formats.

Format Comparison


AVIMP4OGGMKVASF
 Standard ownerMicrosoftMPEGXiph.orgMatroska.orgMicrosoft
 B-frames supportby tweaksYesYesYesYes
 VBR audioYes*YesYesYesYes
 Variable frame rateNoYesNoYesNo
 ChaptersNoNoYesYesNo
 SubtitlesNottxtOgg WritAnythingNo
 StreamableNoYesYesYesYes

* ACM cannot handle VBR audio streams in AVI files. Thus, software using ACM (Audio Compression Manager) to read audio from AVI files will not be able to handle VBR audio streams correctly, even though such files are compliant to the AVI file specification. This is a limitation of the ACM, not of the AVI file format.

AVI

Audio-Video Interleave (AVI) is a multimedia container format introduced by Microsoft in 1992, as part of the Video for Windows technology. These files contain both audio and video data in a standard container that allows simultaneous playback. Most AVI files also use the file format extensions developed by the Matrox OpenDML group in February 1996. These files are supported by Microsoft, and are known unofficially as 'AVI 2.0'.

MOV

A QuickTime MOV file contains one or more tracks, each of which store a particular type of data, such as audio, video, effects, or subtitles. Each track in turn contains track media, either the digitally encoded media stream (using a specific codec such as Cinepak, Sorenson codec, MP3, JPEG, DivX, or PNG) or a data reference to the media stored in another file or elsewhere on a network. It also has an 'edit list' that indicates what parts of the media to use.

The ability to contain abstract data references for the media data, and the separation of the media data from the media offsets and the track edit lists means that QuickTime is particularly suited for editing, as it is capable of importing and editing in place (without data copying) other formats such as AIFF DV, MP3, MPEG-1, and AVI.

MP4

MPEG-4 Part 14 or MP4 is a container file format specified as a part of the ISO/IEC MPEG-4 international standard. It is used to store media types defined by the ISO/IEC Moving Picture Experts Group, and can be used to store other media types as well.

MP4 allows streaming over the internet. It also allows multiplexing of multiple video and audio streams in one file, variable frame- and bit-rates, subtitles and still images.

Ogg

Ogg Media Container is developed by Xiph.org as the framework of a larger initiative aimed at developing a set of components for the coding and decoding of multimedia content which are both freely available and freely re-implementable in software.

The term Ogg often incorrectly refers to the Vorbis audio codec. Other prominent components of Ogg are its video codec Theora, and the speech audio compression format, Speex.

If you are wondering about the OGM format, refer to this page for detailed information. DivXLand.org suggests to use the Matroska container, since OGM is no longer developed.

Matroska

Matroska aims to be the standard for multimedia container formats. It incorporates features you would expect from a modern container format, like:
  • Fast seeking in the file
  • High error recovery
  • Chapter entries
  • Selectable subtitle streams
  • Selectable audio streams
  • Modularly Extendable
  • Streamable over internet (HTTP and RTP audio / video streams)
  • DVD-style menus

The Matroska file extensions are:

  • .mkv: generally video files, as well those containing audio (movies) or video only.
  • .mka: audio only files, can contain any supported audio compresion format, such as MP2, MP3, Vorbis, AAC, AC3, DTS, PCM.
  • .mks: a so called 'elementary' matroska stream containing any subtitles stream.

To open Matroska files, you need to install either the DivX Total Pack or the Matroska Pack filter. For extended information regarding the Matroska container format, visit its website.

ASF

Advanced Systems Format (formerly Advanced Streaming Format) is Microsoft's proprietary digital audio and video container format, especially designed for streaming media. ASF is part of the Windows Media framework.

The format does not specify how the video or audio should be encoded, but instead just specifies the structure of the video/audio stream. What this means is that ASF files can be encoded with basically any audio/video codec and still would be in ASF format. This is similar to the function performed by the QuickTime, AVI, or Ogg formats.

The most common filetypes contained within an ASF file are Windows Media Audio (WMA) and Windows Media Video (WMV).

RealMedia

RealMedia is a multimedia container format created by RealNetworks. It is typically used in conjunction with RealVideo and RealAudio compression and is popular for streaming content over the internet.

RM content can be played with RealPlayer, or with any DirectShow based player by installing third party filters such as RealAlternative.


REF


http://www.divxland.org/en/article/15/multimedia_container_formats
http://en.wikipedia.org/wiki/3GP_and_3G2
http://www.reganam.com/3gp-video-format.htm
http://www.youtube.com/watch?v=OTayZD-0j54






http://edutechwiki.unige.ch/en/Video_streaming
http://edutechwiki.unige.ch/en/Multimedia_container_format

3GP is a new multimedia container format which is defined as Third Generation Partnership Project (3GPP). This format is used for 3G UMTS multimedia services. It is used in 3G mobile phones but some 2G phones also support 3GP file format. The Technical Specifications for 3Gp are found in ETSI 3GPP technical specification. 3GP is required for IP multimedia subsystem (IMS), Multimedia Messaging Service (MMS), Multimedia broadcast/multicast services (MBMS) and transparent end to end packet streaming services (PSS).It is a third generation video standard that incorporates mp3,mp4,3gpp and 3gp.
3GP stores video streams in MPEG-4 or H 263 format while audio streams are stored AMR-NB or AAC-LC format. 3GP defines the image sizes and bandwidth requirements as a result the content fits the small mobile screen efficiently. Unlike the MP3 format, 3GP format includes both video and audio streams. Thus both video and audio currents are stored in a single file for this format.
The 3GP format is actually a multimedia format. The extension .3gp clearly shows that this technology is mainly incorporated in 3rd generation mobile phones. It is based on ISO base media file format. This format was defined to minimize the storage and bandwidth requirements so that mobile phones can store and download these files. A 3GP always follows the big-endian format so that the most significant byte is stored and transferred first. The 3GP format is mainly intended to use for mobile phones and devices capable of handling multimedia. Most of the mobile phone records and then play back the video using this 3GP format. A specific player is required in order to watch you mobile made 3GP videos on the PC.
The basis for 3GP file format is MPEG-4 part 12 of ISO.Some older versions didn’t support all the capabilities defined in MPEG-4 part 12 but new versions fully support MPEG-4 part 12. This format is closely related to MPEG-4 part 14 (MP4) format because MPEG-4 part 14 is also based on MPEG-4 part 12. The file extension for 3GP files is .3gp.3GP files can be viewed on PC using software like QuickTime or real player etc. In 3GP file format various things like audio, video and bit rate information is stored in a single file. Due to the compressed nature of 3GP format the size of 3GP file is very small as it is to be stored on a mobile or similar device. As stated earlier, the file with extension ‘.3gp’ stores the video content in the Mp4 format and the audio data in AMR format.
Now a day’s mobile phone and internet industry is growing fast and quick .Some websites allow the users to download content directly in to their mobile .So websites usually prefer the 3GP format for videos so that it can be easily downloaded and played in the users’ mobile. As a result the demand for 3GP videos is increasing day by day. So we can say that 3GP format is a sensation for mobile users as users can now easily browse internet and videos on websites. Also large multimedia files can be transferred easily and video conferencing is very easy now. The 3GP format is supported by all the systems like windows, MACs and Linux.
Despite the relative small size of 3GP format the quality of video is very good.3GP files can be easily converted to other formats like wmv,avi,mp4 etc  with the help of different software which are easily available on the internet. One major conversion nowadays is from DVD to 3GP which allows you to watch your favorite DVD movies on wireless devices which supports 3GP format. Also FLV to 3GP conversion is a vital one these days. It enables you to download videos from internet websites like YouTube or some other and then change its format to #GP after which you will be able to watch that video on your cell phone or PDA.
Today the use of Cell phone has been increased enormously. More than 90% of these cell phones play videos in 3GP format. Thus you need to convert the videos before watching them in your cell phone. It is expected that in the near future full length and high quality videos are available from the internet in the 3GP format. This enables you to watch all the TV shows, different plays and much more on your cell phone screen.
If you are searching for videos that can be watched on your mobile phone, you might look for the cell phone’s company website for supported videos as your first option. There you may find some small videos or video trailers. Some companies make available these videos free for all while some may charge for downloading these videos, you can use 3GP Player to watch 3GP videos.
If you want to download full length 3GP videos, you may go to some specific 3GP videos websites. These websites offer you free 3GP videos which might include some funny ones, popular TV commercials and many more. You can easy download these 3GP videos and put them in your mobile phone. Moreover if you don’t find your required video anywhere on the internet than you might download some suitable converter like 3GP Converter which convert most of the latest formats into 3GP after which you can easily watch your favorite video on the cell phone.
3GP is the simplified version of the well-known Mp4 format. This is mainly to reduce the size of the original video to a considerable extent and thus can easily be seen in low memory mobile phones. The most common extensions in which 3GP files come are .3gp and .3g2. As 3GP files are the compressed form of Mp4 file, thus the size of 3GP file is significantly reduced. This makes the 3GP format perfect for the cell phones whose may not have a considerable memory.

###########################################################################################


Compress high quality 3GP videos for mobiles — guide

Filed Under (guide, mobiles, sony ericsson, video) by Abbas on 03-09-2008

Tagged Under : , , , 

If you used to search the web for a 3GP version of your favorite video so that you could enjoy some high quality movies on your mobile phone, your search is over. No you won’t have to ask others to compress a video for your mobile phone because at the end of this tutorial, you’ll be able to compress any of your favorite video or movie to a high quality .3GP format movie yourself.
If you regularly watch videos on your mobile phone, you already know how pixelated and badly compressed most of those movies look. With this tutorial, we’ll follow some steps, use a nice compression software, and tune up a few things so that you’ll get videos with the the highest quality possible, and even that with a minor increase in the file size.
In order to compress the movie, first you’ll be needing this very nice audio/video compression tool called Super © video converter, to download it go here and you’ll see a very lengthy page, go to the very end of the page and you’ll see a link saying “start downloading Super (C)”, click on that link and you’ll be forward to a final page, where you can download the program (Yes, I know the download is a little awkward, but thats how the Super (C) wants people to go through their pages before they’re able to get a download).
After you’re done with downloading the setup for Super C video converter and install it. During the installation process, you might get a few messages just ignore them.
Once Super C is installed, open it up (if you’re on vista, you might need to right click on the icon and run it as an administrator). Super C will check some requirements that it needs, whatever message it gives, just press ok (as normally any current PC is ok to run Super C, unless you want to compress huge videos as then you’ll need more RAM and CPU power).
Since we’ll be compressing our videos to 3GP format, select “3GP” as the output format, MPEG4 as the video codec and AAC LC as the Audio codec just as shown in the pictur below.
After choosing the right options, now we have to select the video options. If you’re using a phone like Sony Ericsson’s K750, W700, W800, W810, W550 etc, then select the 176:144 “Video Scale Size” from the Video row, 25 frames per second, with 250 kbps bitrate.
If you’re using Sony Ericsson’s K790, K800, K810, K850, W850, W900 etc then because of the large screen and powerful mobile cpu you can choose 240:320 “Video Scale Size” (which’ll give you far superior video quality (as you can see from the top image of this post)). Same 25 frames/sec video speed and choose a bitrate of 450 kbps for the video, just like as shown in the screenshot below.

The next step is to select some nice audio options so that you can enjoy a good audio experience along with he nicely compressed 3GP video. Choose 22050 as the sampling frequency, 2 Channels and choose the bitrate to 96 kbps (if you’re using K750, W700, W800, W810 etc you can also choose 64kbps audio quality if you are going to compress very long videos like movies for example, it’ll save your mobile videos from lagging). Select the options as shown in the screenshot below.
After choosing these options, now all you have to do is to select your favorite movie or video, and get it encoded by Super C. To select the media file that you want to encode, (1) right click on the area below OUTPUT, as shown in the following image, and (2) click on “Add Multimedia Files”.  A browse window should open up and now just locate and select the required video file.
Now you’ll see the video file in the list. In my case I’m compressing Alizee’s La Isla Bonita (very famous video of this hot and nice singer). After the video is in the list just click on “Encode (Active Files)”. Make sure the video is ticked in the list just like as shown below.

Now give Super C a little time to compress your video. The compression doesn’t take very long, time-taken depends on the video size and the compression options. After the compression process is done, your compressed 3GP file will be stored in C:/Program Files/eRight Software/Super/Output directory.
As you can see by the status bar screenshot below, Super C has compressed a 49MB file to a nice and neat, high quality 13MB 3GP file (320:240 version),
i’ve followed the 320:240 size as I wanted this video for my Sony Ericsson K790. For the 176:144 video phones like K750, W700, W800, W810 etc, the size of the compressed 3GP video file will be much smaller.
The end product will look something like this: :)
I hope you’d love the end product :)  This 3GP video is now worth watching over your cell phone over and over again. Oh and do comment about how you found this post, and of course, how hot do you think Alizee is? :)
Share:


video and audio parameters including video resolution, frame rate, encoder, bit rate, and audio sample rate, channel, encoder, bit rate, and volume so that you can the best video quality.


REF
http://techlighten.com/guide/compress-high-quality-3gp-videos-for-mobiles-guide/
http://www.video-compressor.com/3gp-video-compressor.html

Monday, December 3, 2012

3GP and 3G2



http://www.cnwrecovery.com/html/3gp_recovery.html
http://www.mplayerhq.hu/DOCS/HTML/en/encoding-guide.html

Recovery of deleted and fragmented 3GP and MP4 files

CnW Recovery software can recover many fragmented video files - a feature that very few data recovery packages even try.  A deleted file is often fragmented, and some files are created fragmented.  Many packages just use data carving which finds sequential files, but can not recreate a fragmented file.
Cell phones and mobile phones often produce video files that are based on the Quick time format, with extensions such as .3GP, .MP4, .MOV.  As with any file, it is often possible for these file to be fragmented, and so if recovered with data carving, the file will not be valid.  CnW defragmenting routine is an option within data carving - at the end of carving the files may be optionally defragmented.  This option is part of even the most basic CnW package - because it is very important for successful recovery procedures.
The details below give a technical description but for most users it is only necessary to run the program.  New variations are being found and implemented all of the time - CnW are happy to accept new examples which will be implemented at no cost to the user. 

Typical data structure

    The file structure is a series of 4 byte lengths followed by 4 byte tags
    00000000   00 00 00 18 66 74 79 70 - 33 67 70 35 00 00 03 00        ftyp3gp5
    This type of file can be recognised by it’s header which started with a 4 byte length (normally 0x14, 0x18, 0x1c 0x20 or 0x24) followed by the string ‘ftyp’.  The next 4 bytes gives the file type, such as 3gp, or mp42.  There are about 30 recognised file types - CnW software will convert most to be MP4.  See here for more details www.ftyps.com
    The next tag is often a ‘moov’ tag which contains all data pointers etc.  The structure is moderately complex, and can allow for multiple tracks, typically one for video, and the other for audio
    00000010   6D 70 34 32 6D 70 34 31 - 00 00 0B E6 6D 6F 6F 76    mp42mp41   æmoov
    The final important tag is ‘mdat’ that contains all the video and sound data.
    To reconstruct the files, the process is to analyze the moov segment and determine where each video frame starts.  (This is based on information in the stco and stsz tags).  On may files, the start of the video frame is fixed data, and so data cluster can be searched for and tested to make sure they contain a frame start (or starts) at a known offset within the cluster.
    One significant problem with the above description is that many files are structured  ftyp-moov-mdat, but other ones are ftyp-mdat-moov. In the later case, it is necessary to search for the matching moov fragment before reconstructing the mdat segment.  With file fragmentation, the mdat is the one most likely to be fragmented as the moov segment is often less than 64K in length.  V3.29 will process both  ftyp-moov-mdat  and ftyp-mdat-moov files up to a maximum file size of 16MB.  Later versions will support any file length..  Current success rate is between 0 and 100%, it all depends how fragmented the files are, and if the fragments do actually exist.  We have also seen files where there is an incomplete mdat segment and no moov segment at all.  Also, the length of the ftyp header is zero  Current development plan working on reconstructing the a missing moov segment based on a sample from the same camera.  Due to variations this development is on a per codec basis.

How defragmenting works

    The basic structure of the file is one of a four byte length, then a four byte tag, followed by data.  This means that the location of the next tag is always known, although the type of tag can only be guessed.  For the mdat segment, unfortunately there is only a single header and tag, but the moov segment may have a 100 or so tags.  Typically the moov segment is short, but a complete one is essential to view a possibly incomplete mdat.
    With defragmenting, it is assumed that data is always in original clusters, although the location of a cluster is not known.  This mens that if a tag is expected at location 0x579421 in a file, and the cluster size is 0x4000, then clusters are tested to see if they have a suitable tag in location 0x1421  (ie 0x579421 modulus 0x4000).  For many moov segments this will produce a good reliable result.  Problems arise on long files, and sometimes the tag ‘stts’ and ‘stsz’ can be very long. If this sits over a fragment location, then different functions are required to analyse data and try and add the relevant pieces.
    To reconstruct mdat segments is it largely essential to have a valid moov segment.  From this, key elements can be found, eg frame starts, and matched with possible data clusters.

No moov segment

    Video has been come across where the camera did not complete the file.  ie it has a dummy ftyp header, a mdat section but no moov.  The indication that this is an incomplete file, rather than just fragmented is that the ftyp header length is set as zero.  CnW is currently working on creating a moov section to enable the mdat to be displayed.

Non sequential recording

    An issue with several cameras is that the data is not recorded onto the memory chip sequentially.  This is because the moov segment can only be created when the mdat segment is complete.  The approach is to record the segements as ftyp-mdat-moov with each segment on a cluster boundary.  The FAT on the disk can then be changed to that logically the data is ftyp-moov-mdat.  However, when files are deleted, this modified FAT is lost and recovery difficult.  Fortunately, CnW Recovery defragmentation software detects this pattern and corrects the files, allowing for very successful recovery.

User support

    CnW is very keen to help ever customer.  If a situation arises where recover has not been possible, CnW will assist.  If necessary, the media, or a copy, can be sent to CnW who will extract the files.  As this is both good customer support, and useful development, there is no extra charge for this work - except possible postage costs.
    3GP is actually a simplified version of MPEG-4 (MP4).  Video frames can either be MPEG-4 or H.263

Incomplete files - or not finalised

    Occasionally a camera will not finalise a file.  One example is when a camera is dropped and the battery drops out.  This can leave a file with a complete mdat fragment, but no meta data (ie the moov fragment).  This type of file cannot be viewed by normal packages.  CnW is developing tools to overcome this problem.  This involves recreating a moov fragment from scratch - often using a sample working file from the same camera.  The success rate does depend on whether or not CnW soltware recognised the video encoding system used, ie the codec.  CnW are always happy to undertake new examples as part of on going development - there is no charge for this.
Click here for a white paper on the subject.
 _____________________________________________________________________

3GP (3GPP file format) is a multimedia container format defined by the Third Generation Partnership Project (3GPP) for 3G UMTS multimedia services. It is used on 3G mobile phones but can also be played on some 2G and 4G phones.
3G2 (3GPP2 file format) is a multimedia container format defined by the 3GPP2 for 3G CDMA2000 multimedia services. It is very similar to the 3GP file format, but has some extensions and limitations in comparison to 3GP.

Contents

Specifications

3GP is defined in the ETSI 3GPP technical specification.[1] 3GP is a required file format for video and associated speech/audio media types and timed text in ETSI 3GPP technical specifications for IP Multimedia Subsystem (IMS), Multimedia Messaging Service (MMS), Multimedia Broadcast/Multicast Service (MBMS) and Transparent end-to-end Packet-switched Streaming Service (PSS).[2][3][4][5]
3G2 is defined in the 3GPP2 technical specification.[6]

Technical details

Relations between ISO Base Media File Format, MP4 File Format, 3GPP file format and 3GPP2 file format. Based on the 3GPP2 technical specification published on 18 May 2007.[7]
The 3GP and 3G2 file formats are both structurally based on the ISO base media file format defined in ISO/IEC 14496-12 - MPEG-4 Part 12,[8][9][10] but older versions of the 3GP file format did not use some of its features.[7] 3GP and 3G2 are container formats similar to MPEG-4 Part 14 (MP4), which is also based on MPEG-4 Part 12. The 3GP and 3G2 file format were designed to decrease storage and bandwidth requirements in order to accommodate mobile phones.
3GP and 3G2 are similar standards, but with some differences:
  • 3GPP file format was designed for GSM-based Phones and may have the filename extension .3gp
  • 3GPP2 file format was designed for CDMA-based Phones and may have the filename extension .3g2
Some cell phones use the .mp4 extension for 3GP video.

3GP

The 3GP file format stores video streams as MPEG-4 Part 2 or H.263 or MPEG-4 Part 10 (AVC/H.264), and audio streams as AMR-NB, AMR-WB, AMR-WB+, AAC-LC, HE-AAC v1 or Enhanced aacPlus (HE-AAC v2). 3GPP allowed use of AMR and H.263 codecs in the ISO base media file format (MPEG-4 Part 12), because 3GPP specified the usage of the Sample Entry and template fields in the ISO base media file format as well as defining new boxes to which codecs refer. These extensions were registered by the registration authority for code-points in ISO base media file format ("MP4 Family" files).[11] [12] For the storage of MPEG-4 media specific information in 3GP files, the 3GP specification refers to MP4 and the AVC file format, which are also based on the ISO base media file format. The MP4 and the AVC file format specifications described usage of MPEG-4 content in the ISO base media file format.[8]
A 3GP file is always big-endian, storing and transferring the most significant bytes first.

3G2

The 3G2 file format can store the same video streams and most of the audio streams used in the 3GP file format. In addition, 3G2 stores audio streams as EVRC, EVRC-B, EVRC-WB, 13K (QCELP), SMV or VMR-WB, which was specified by 3GPP2 for use in ISO base media file format.[12] The 3G2 specification also defined some enhancements to 3GPP Timed Text. 3G2 file format does not store Enhanced aacPlus (HE-AAC v2) and AMR-WB+ audio streams.[7] For the storage of MPEG-4 media (AAC audio, MPEG-4 Part 2 video, MPEG-4 Part 10 - H.264/AVC) in 3G2 files, the 3G2 specification refers to the MP4 file format and the AVC file format specification, which described usage of this content in the ISO base media file format. For the storage of H.263 and AMR content 3G2 specification refers to the 3GP file format specification.[13]

Device support

  • Most 3G capable mobile phones support the playback and recording of video in 3GP format (memory, maximum filesize for playback and recording, and resolution limits exist and vary).
  • Some newer/higher-end phones without 3G capabilities may also playback and record in this format (again, with said limitations).
  • Audio imported from CD onto a PlayStation 3 when it is set to encode to the MPEG-4 AAC codec will copy onto USB devices in the 3GP format.
  • The Nintendo DSi supports .3gp on an SD card.

Software support

When transferred to a computer, 3GP movies can be viewed on Linux, Mac, and Windows platforms with MPlayer and VLC media player. Programs such as Media Player Classic, K-Multimedia Player, Totem, RealPlayer, QuickTime, and GOM Player can also be used.
3GP files can be encoded and decoded with open source software FFmpeg.[14]

See also

References

  1. ^ ETSI 3GPP 3GPP TS 26.244; Transparent end-to-end packet switched streaming service (PSS); 3GPP file format (3GP) Retrieved on 2009-06-02.
  2. ^ ETSI (2009-04) ETSI TS 126 234 V8.2.0 (2009-04); 3GPP TS 26.234; Transparent end-to-end Packet-switched Streaming Service (PSS); Protocols and codecs Page 58. Retrieved on 2009-06-02.
  3. ^ ETSI (2009-01) ETSI TS 126 140 V8.0.0 (2009-01); 3GPP TS 26.140; Multimedia Messaging Service (MMS); Media formats and codes Page 11. Retrieved on 2009-06-02.
  4. ^ ETSI (2009-06). "ETSI TS 126 346 V8.3.0 (2009-06); 3GPP TS 26.346; Multimedia Broadcast/Multicast Service (MBMS); Protocols and codecs". ETSI. p. 85. Retrieved 2009-10-13.
  5. ^ ETSI (2009-01) ETSI TS 126 141 V8.0.0 (2009-01); 3GPP TS 26.141; IP Multimedia System (IMS) Messaging and Presence; Media formats and codecs Page 10. Retrieved on 2009-06-02.
  6. ^ 3GPP2 (2003). 3GPP2 C.S0050, 3GPP2 File Formats for Multimedia Services, File Format for Multimedia Services for cdma2000. 3GPP2. Retrieved 2009-06-12.
  7. ^ a b c 3GPP2 (18 May 2007) (PDF). 3GPP2 C.S0050-B Version 1.0, 3GPP2 File Formats for Multimedia Services. 3GPP2. pp. 67, 68. Retrieved 2009-06-12.
  8. ^ a b ETSI 3GPP (2008-12-11) (PDF). 3GPP TS 26.244; Transparent end-to-end packet switched streaming service (PSS); 3GPP file format (3GP). ETSI. p. 9. Retrieved 2009-05-30.
  9. ^ ISO (2006-04). ISO Base Media File Format white paper - Proposal. archive.org. Archived from the original on 2008-07-14. Retrieved 2009-12-26.
  10. ^ ISO (2009-10). ISO Base Media File Format white paper - Proposal. chiariglione.org. Retrieved 2009-12-26.
  11. ^ International Organization for Standardization (2008) (PDF). ISO/IEC 14496-12:2008, Information technology -- Coding of audio-visual objects -- Part 12: ISO base media file format. International Organization for Standardization. p. 95. Retrieved 2009-05-30.
  12. ^ a b Registered types - Codecs. Registration authority for code-points in "MP4 Family" files - mp4ra.org. 2008. Archived from the original on 19 April 2009. Retrieved 2009-05-31.
  13. ^ 3GPP2 (18 May 2007) (PDF). 3GPP2 C.S0050-B Version 1.0, 3GPP2 File Formats for Multimedia Services. 3GPP2. p. 21. Retrieved 2009-06-12.
  14. ^ "FFmpeg, General Documentation, Supported File Formats and Codecs". FFmpeg. Retrieved 2009-06-1
  15.  
  16.  
  17.  

AVI example code for creating AVI files


AVI example code for creating AVI files

(c) 2002 Lucian Wischik. This code is free, and anyone can do with it whatever they like, including incorporating it in commercial products.
This code is concerned with creating AVI files, including video and audio. The video can be compressed using whichever filters are installed on your computer - you can make it pop up a system dialog box asking the user which filter to use, or you can remember this information to avoid the dialog box in future, or you can assume no compression and avoid the dialog box totally. As for compressing the audio, I believe that this is impossible using the AVI functions. Instead, you'll have to create an AVI with uncompressed audio, and then compress it using some external utility like Windows Movie Maker.
The code consists of seven functions, written in (classless) C++ and using Video for Windows (which is built into all versions of windows). I use this code as a unit (avi_utils.cpp, avi_utils.h) added to my own project. This web page contains examples of how to use the functions to create AVI files, the header file and the source code. You should copy the code and paste it into your own project. The code is plain Win32, and compiles cleanly under Borland C++Builder5 and Visual Studio .NET, and should work on other compilers without problems.
Borland compilers normally allow FPU exceptions. This can cause a problem, because some filters (e.g. DivX) raise FPU exceptions. Therefore, Borland users should use this code at some point before creating the AVI -- I do it at the start of WinMain. (This is not necessary for Visual C++, since that disables the exceptions by default).
#include <float.h>
_control87(MCW_EM, MCW_EM); // reprogram the FPU so it doesn't raise exceptions

Examples of how to create AVIs

To create an AVI from a bunch of files. The following code creates an AVI out of five bitmaps (1.bmp, 2.bmp, ... 5.bmp) and a WAV file (wav.wav).
const char *fns[] = {"1.bmp","2.bmp","3.bmp","4.bmp","5.bmp"};
HAVI avi = CreateAvi("test.avi",1000,NULL); // 1000ms is the period between frames
for (int i=0; i<sizeof(fns)/sizeof(fns[0]); i++)
{ HBITMAP hbm=(HBITMAP)LoadImage(NULL,fns[i],IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
  AddAviFrame(avi,hbm);
  DeleteObject(hbm);
}
AddAviWav(avi,"wav.wav",SND_FILENAME);
CloseAvi(avi);
To create an AVI with DivX compression. This code creates the same AVI, with DivX compression for the video, and without the audio. The code actually just suggests DivX and pops up a dialog to let the user control more details (hwnd is some window to be used as the parent for that dialog). You might keep a copy of the opts structure so as to give the same defaults to the user next time. Or you can pass false to the SetAviVideoCompression function to suppress the user-interface dialog, if the opts structure is already filled out correctly.
const char *fns[] = {"1.bmp","2.bmp","3.bmp","4.bmp","5.bmp"};
HAVI avi = CreateAvi("test.avi",1000,NULL);
for (int i=0; i<sizeof(fns)/sizeof(fns[0]); i++)
{ HBITMAP hbm=(HBITMAP)LoadImage(NULL,fns[i],IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
  if (i==0) // Set up compression just before the first frame
  { AVICOMPRESSOPTIONS opts; ZeroMemory(&opts,sizeof(opts));
    opts.fccHandler=mmioFOURCC('d','i','v','x');
    SetAviVideoCompression(avi,hbm,&opts,true,hwnd);
  }
  AddAviFrame(avi,hbm);
  DeleteObject(hbm);
}
CloseAvi(avi);
To create an AVI from dynamically-drawn images. This code shows how to draw your own animations for the AVI file, rather than just relying on existing bitmap files. Note: you must use DIBSections instead of normal device-dependent bitmaps.
HDC hdcscreen=GetDC(0), hdc=CreateCompatibleDC(hdcscreen); ReleaseDC(0,hdcscreen);
BITMAPINFO bi; ZeroMemory(&bi,sizeof(bi)); BITMAPINFOHEADER &bih = bi.bmiHeader;
bih.biSize=sizeof(bih);
bih.biWidth=200;
bih.biHeight=200;
bih.biPlanes=1;
bih.biBitCount=24;
bih.biCompression=BI_RGB;
bih.biSizeImage = ((bih.biWidth*bih.biBitCount/8+3)&0xFFFFFFFC)*bih.biHeight;
bih.biXPelsPerMeter=10000;
bih.biYPelsPerMeter=10000;
bih.biClrUsed=0;
bih.biClrImportant=0;
void *bits; HBITMAP hbm=CreateDIBSection(hdc,(BITMAPINFO*)&bih,DIB_RGB_COLORS,&bits,NULL,NULL);
//
HGDIOBJ holdb=SelectObject(hdc,hbm);
HPEN hp = CreatePen(PS_SOLID,16,RGB(255,255,128));
HGDIOBJ holdp=SelectObject(hdc,hp);
//
HAVI avi = CreateAvi("test.avi",100,NULL);
for (int frame=0; frame<50; frame++)
{ // static background
  DWORD seed=GetTickCount(); DWORD *dbits=(DWORD*)bits;
  for (unsigned int i=0; i<bih.biSizeImage/sizeof(DWORD); i++) {dbits[i]=seed; seed+=79;}
  // a line moving
  MoveToEx(hdc,0,0,NULL); LineTo(hdc,frame*3,100);
  AddAviFrame(avi,hbm);
}
CloseAvi(avi);
//
SelectObject(hdc,holdb); SelectObject(hdc,holdp);
DeleteDC(hdc); DeleteObject(hbm); DeleteObject(hp);

Header-file 'avi_utils.h'

#ifndef _avi_utils_H
#define _avi_utils_H

// AVI utilities -- for creating avi files
// (c) 2002 Lucian Wischik. No restrictions on use.


DECLARE_HANDLE(HAVI);
// An HAVI identifies an avi file that is being created


HAVI CreateAvi(const char *fn, int frameperiod, const WAVEFORMATEX *wfx);
// CreateAvi - call this to start the creation of the avi file.
// The period is the number of ms between each bitmap frame.
// The waveformat can be null if you're not going to add any audio,
// or if you're going to add audio from a file.

HRESULT AddAviFrame(HAVI avi, HBITMAP hbm);
HRESULT AddAviAudio(HAVI avi, void *dat, unsigned long numbytes);
// AddAviFrame - adds this bitmap to the avi file. hbm must point be a DIBSection.
// It is the callers responsibility to free the hbm.
// AddAviAudio - adds this junk of audio. The format of audio was as specified in the
// wfx parameter to CreateAVI. This fails if NULL was given.
// Both return S_OK if okay, otherwise one of the AVI errors.

HRESULT AddAviWav(HAVI avi, const char *wav, DWORD flags);
// AddAviWav - a convenient way to add an entire wave file to the avi.
// The wav file may be in in memory (in which case flags=SND_MEMORY)
// or a file on disk (in which case flags=SND_FILENAME).
// This function requires that either a null WAVEFORMATEX was passed to CreateAvi,
// or that the wave file now being added has the same format as was
// added earlier.

HRESULT SetAviVideoCompression(HAVI avi, HBITMAP hbm, AVICOMPRESSOPTIONS *opts, bool ShowDialog, HWND hparent);
// SetAviVideoCompression - allows compression of the video. If compression is desired,
// then this function must have been called before any bitmap frames had been added.
// The bitmap hbm must be a DIBSection (so that avi knows what format/size you're giving it),
// but won't actually be added to the movie.
// This function can display a dialog box to let the user choose compression. In this case,
// set ShowDialog to true and specify the parent window. If opts is non-NULL and its
// dwFlags property includes AVICOMPRESSF_VALID, then opts will be used to give initial
// values to the dialog. If opts is non-NULL then the chosen options will be placed in it.
// This function can also be used to choose a compression without a dialog box. In this
// case, set ShowDialog to false, and hparent is ignored, and the compression specified
// in 'opts' is used, and there's no need to call GotAviVideoCompression afterwards.

HRESULT CloseAvi(HAVI avi);
// CloseAvi - the avi must be closed with this message.



unsigned int FormatAviMessage(HRESULT code, char *buf,unsigned int len);
// FormatAviMessage - given an error code, formats it as a string.
// It returns the length of the error message. If buf/len points
// to a real buffer, then it also writes as much as possible into there.


#endif

Source-code 'avi_utils.cpp'

#define STRICT
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <vfw.h>
#include "avi_utils.h"


// First, we'll define the WAV file format.
#include <pshpack1.h>
typedef struct
{ char id[4];         //="fmt "
  unsigned long size; //=16
  short wFormatTag;   //=WAVE_FORMAT_PCM=1
  unsigned short wChannels;       //=1 or 2 for mono or stereo
  unsigned long dwSamplesPerSec;  //=11025 or 22050 or 44100
  unsigned long dwAvgBytesPerSec; //=wBlockAlign * dwSamplesPerSec
  unsigned short wBlockAlign;     //=wChannels * (wBitsPerSample==8?1:2)
  unsigned short wBitsPerSample;  //=8 or 16, for bits per sample
} FmtChunk;

typedef struct
{ char id[4];            //="data"
  unsigned long size;    //=datsize, size of the following array
  unsigned char data[1]; //=the raw data goes here
} DataChunk;

typedef struct
{ char id[4];         //="RIFF"
  unsigned long size; //=datsize+8+16+4
  char type[4];       //="WAVE"
  FmtChunk fmt;
  DataChunk dat;
} WavChunk;
#include <poppack.h>




// This is the internal structure represented by the HAVI handle:
typedef struct
{ IAVIFile *pfile;    // created by CreateAvi
  WAVEFORMATEX wfx;   // as given to CreateAvi (.nChanels=0 if none was given). Used when audio stream is first created.
  int period;         // specified in CreateAvi, used when the video stream is first created
  IAVIStream *as;     // audio stream, initialised when audio stream is first created
  IAVIStream *ps, *psCompressed;  // video stream, when first created
  unsigned long nframe, nsamp;    // which frame will be added next, which sample will be added next
  bool iserr;         // if true, then no function will do anything
} TAviUtil;


HAVI CreateAvi(const char *fn, int frameperiod, const WAVEFORMATEX *wfx)
{ IAVIFile *pfile;
  AVIFileInit();
  HRESULT hr = AVIFileOpen(&pfile, fn, OF_WRITE|OF_CREATE, NULL);
  if (hr!=AVIERR_OK) {AVIFileExit(); return NULL;}
  TAviUtil *au = new TAviUtil;
  au->pfile = pfile;
  if (wfx==NULL) ZeroMemory(&au->wfx,sizeof(WAVEFORMATEX)); else CopyMemory(&au->wfx,wfx,sizeof(WAVEFORMATEX));
  au->period = frameperiod;
  au->as=0; au->ps=0; au->psCompressed=0;
  au->nframe=0; au->nsamp=0;
  au->iserr=false;
  return (HAVI)au;
}

HRESULT CloseAvi(HAVI avi)
{ if (avi==NULL) return AVIERR_BADHANDLE;
  TAviUtil *au = (TAviUtil*)avi;
  if (au->as!=0) AVIStreamRelease(au->as); au->as=0;
  if (au->psCompressed!=0) AVIStreamRelease(au->psCompressed); au->psCompressed=0;
  if (au->ps!=0) AVIStreamRelease(au->ps); au->ps=0;
  if (au->pfile!=0) AVIFileRelease(au->pfile); au->pfile=0;
  AVIFileExit();
  delete au;
  return S_OK;
}


HRESULT SetAviVideoCompression(HAVI avi, HBITMAP hbm, AVICOMPRESSOPTIONS *opts, bool ShowDialog, HWND hparent)
{ if (avi==NULL) return AVIERR_BADHANDLE;
  if (hbm==NULL) return AVIERR_BADPARAM;
  DIBSECTION dibs; int sbm = GetObject(hbm,sizeof(dibs),&dibs);
  if (sbm!=sizeof(DIBSECTION)) return AVIERR_BADPARAM;
  TAviUtil *au = (TAviUtil*)avi;
  if (au->iserr) return AVIERR_ERROR;
  if (au->psCompressed!=0) return AVIERR_COMPRESSOR;
  //
  if (au->ps==0) // create the stream, if it wasn't there before
  { AVISTREAMINFO strhdr; ZeroMemory(&strhdr,sizeof(strhdr));
    strhdr.fccType = streamtypeVIDEO;// stream type
    strhdr.fccHandler = 0; 
    strhdr.dwScale = au->period;
    strhdr.dwRate = 1000;
    strhdr.dwSuggestedBufferSize  = dibs.dsBmih.biSizeImage;
    SetRect(&strhdr.rcFrame, 0, 0, dibs.dsBmih.biWidth, dibs.dsBmih.biHeight);
    HRESULT hr=AVIFileCreateStream(au->pfile, &au->ps, &strhdr);
    if (hr!=AVIERR_OK) {au->iserr=true; return hr;}
  }
  //
  if (au->psCompressed==0) // set the compression, prompting dialog if necessary
  { AVICOMPRESSOPTIONS myopts; ZeroMemory(&myopts,sizeof(myopts));
    AVICOMPRESSOPTIONS *aopts[1];
    if (opts!=NULL) aopts[0]=opts; else aopts[0]=&myopts;
    if (ShowDialog)
    { BOOL res = (BOOL)AVISaveOptions(hparent,0,1,&au->ps,aopts);
      if (!res) {AVISaveOptionsFree(1,aopts); au->iserr=true; return AVIERR_USERABORT;}
    }
    HRESULT hr = AVIMakeCompressedStream(&au->psCompressed, au->ps, aopts[0], NULL);
    AVISaveOptionsFree(1,aopts);
    if (hr != AVIERR_OK) {au->iserr=true; return hr;}
    DIBSECTION dibs; GetObject(hbm,sizeof(dibs),&dibs);
    hr = AVIStreamSetFormat(au->psCompressed, 0, &dibs.dsBmih, dibs.dsBmih.biSize+dibs.dsBmih.biClrUsed*sizeof(RGBQUAD));
    if (hr!=AVIERR_OK) {au->iserr=true; return hr;}
  }
  //
  return AVIERR_OK;
}


HRESULT AddAviFrame(HAVI avi, HBITMAP hbm)
{ if (avi==NULL) return AVIERR_BADHANDLE;
  if (hbm==NULL) return AVIERR_BADPARAM;
  DIBSECTION dibs; int sbm = GetObject(hbm,sizeof(dibs),&dibs);
  if (sbm!=sizeof(DIBSECTION)) return AVIERR_BADPARAM;
  TAviUtil *au = (TAviUtil*)avi;
  if (au->iserr) return AVIERR_ERROR;
  //
  if (au->ps==0) // create the stream, if it wasn't there before
  { AVISTREAMINFO strhdr; ZeroMemory(&strhdr,sizeof(strhdr));
    strhdr.fccType = streamtypeVIDEO;// stream type
    strhdr.fccHandler = 0; 
    strhdr.dwScale = au->period;
    strhdr.dwRate = 1000;
    strhdr.dwSuggestedBufferSize  = dibs.dsBmih.biSizeImage;
    SetRect(&strhdr.rcFrame, 0, 0, dibs.dsBmih.biWidth, dibs.dsBmih.biHeight);
    HRESULT hr=AVIFileCreateStream(au->pfile, &au->ps, &strhdr);
    if (hr!=AVIERR_OK) {au->iserr=true; return hr;}
  }
  //
  // create an empty compression, if the user hasn't set any
  if (au->psCompressed==0)
  { AVICOMPRESSOPTIONS opts; ZeroMemory(&opts,sizeof(opts));
    opts.fccHandler=mmioFOURCC('D','I','B',' '); 
    HRESULT hr = AVIMakeCompressedStream(&au->psCompressed, au->ps, &opts, NULL);
    if (hr != AVIERR_OK) {au->iserr=true; return hr;}
    hr = AVIStreamSetFormat(au->psCompressed, 0, &dibs.dsBmih, dibs.dsBmih.biSize+dibs.dsBmih.biClrUsed*sizeof(RGBQUAD));
    if (hr!=AVIERR_OK) {au->iserr=true; return hr;}
  }
  //
  //Now we can add the frame
  HRESULT hr = AVIStreamWrite(au->psCompressed, au->nframe, 1, dibs.dsBm.bmBits, dibs.dsBmih.biSizeImage, AVIIF_KEYFRAME, NULL, NULL);
  if (hr!=AVIERR_OK) {au->iserr=true; return hr;}
  au->nframe++; return S_OK;
}
  


HRESULT AddAviAudio(HAVI avi, void *dat, unsigned long numbytes)
{ if (avi==NULL) return AVIERR_BADHANDLE;
  if (dat==NULL || numbytes==0) return AVIERR_BADPARAM;
  TAviUtil *au = (TAviUtil*)avi;
  if (au->iserr) return AVIERR_ERROR;
  if (au->wfx.nChannels==0) return AVIERR_BADFORMAT;
  unsigned long numsamps = numbytes*8 / au->wfx.wBitsPerSample;
  if ((numsamps*au->wfx.wBitsPerSample/8)!=numbytes) return AVIERR_BADPARAM;
  //
  if (au->as==0) // create the stream if necessary
  { AVISTREAMINFO ahdr; ZeroMemory(&ahdr,sizeof(ahdr));
    ahdr.fccType=streamtypeAUDIO;
    ahdr.dwScale=au->wfx.nBlockAlign;
    ahdr.dwRate=au->wfx.nSamplesPerSec*au->wfx.nBlockAlign; 
    ahdr.dwSampleSize=au->wfx.nBlockAlign;
    ahdr.dwQuality=(DWORD)-1;
    HRESULT hr = AVIFileCreateStream(au->pfile, &au->as, &ahdr);
    if (hr!=AVIERR_OK) {au->iserr=true; return hr;}
    hr = AVIStreamSetFormat(au->as,0,&au->wfx,sizeof(WAVEFORMATEX));
    if (hr!=AVIERR_OK) {au->iserr=true; return hr;}
  }
  //
  // now we can write the data
  HRESULT hr = AVIStreamWrite(au->as,au->nsamp,numsamps,dat,numbytes,0,NULL,NULL);
  if (hr!=AVIERR_OK) {au->iserr=true; return hr;}
  au->nsamp+=numsamps; return S_OK;
}



HRESULT AddAviWav(HAVI avi, const char *src, DWORD flags)
{ if (avi==NULL) return AVIERR_BADHANDLE;
  if (flags!=SND_MEMORY && flags!=SND_FILENAME) return AVIERR_BADFLAGS;
  if (src==0) return AVIERR_BADPARAM;
  TAviUtil *au = (TAviUtil*)avi;
  if (au->iserr) return AVIERR_ERROR;
  //
  char *buf=0; WavChunk *wav = (WavChunk*)src;
  if (flags==SND_FILENAME)
  { HANDLE hf=CreateFile(src,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
    if (hf==INVALID_HANDLE_VALUE) {au->iserr=true; return AVIERR_FILEOPEN;}
    DWORD size = GetFileSize(hf,NULL);
    buf = new char[size];
    DWORD red; ReadFile(hf,buf,size,&red,NULL);
    CloseHandle(hf);
    wav = (WavChunk*)buf;
  }
  //
  // check that format doesn't clash
  bool badformat=false;
  if (au->wfx.nChannels==0)
  { au->wfx.wFormatTag=wav->fmt.wFormatTag;
    au->wfx.cbSize=0;
    au->wfx.nAvgBytesPerSec=wav->fmt.dwAvgBytesPerSec;
    au->wfx.nBlockAlign=wav->fmt.wBlockAlign;
    au->wfx.nChannels=wav->fmt.wChannels;
    au->wfx.nSamplesPerSec=wav->fmt.dwSamplesPerSec;
    au->wfx.wBitsPerSample=wav->fmt.wBitsPerSample;
  }
  else
  { if (au->wfx.wFormatTag!=wav->fmt.wFormatTag) badformat=true;
    if (au->wfx.nAvgBytesPerSec!=wav->fmt.dwAvgBytesPerSec) badformat=true;
    if (au->wfx.nBlockAlign!=wav->fmt.wBlockAlign) badformat=true;
    if (au->wfx.nChannels!=wav->fmt.wChannels) badformat=true;
    if (au->wfx.nSamplesPerSec!=wav->fmt.dwSamplesPerSec) badformat=true;
    if (au->wfx.wBitsPerSample!=wav->fmt.wBitsPerSample) badformat=true;
  }
  if (badformat) {if (buf!=0) delete[] buf; return AVIERR_BADFORMAT;}
  //
  if (au->as==0) // create the stream if necessary
  { AVISTREAMINFO ahdr; ZeroMemory(&ahdr,sizeof(ahdr));
    ahdr.fccType=streamtypeAUDIO;
    ahdr.dwScale=au->wfx.nBlockAlign;
    ahdr.dwRate=au->wfx.nSamplesPerSec*au->wfx.nBlockAlign; 
    ahdr.dwSampleSize=au->wfx.nBlockAlign;
    ahdr.dwQuality=(DWORD)-1;
    HRESULT hr = AVIFileCreateStream(au->pfile, &au->as, &ahdr);
    if (hr!=AVIERR_OK) {if (buf!=0) delete[] buf; au->iserr=true; return hr;}
    hr = AVIStreamSetFormat(au->as,0,&au->wfx,sizeof(WAVEFORMATEX));
    if (hr!=AVIERR_OK) {if (buf!=0) delete[] buf; au->iserr=true; return hr;}
  }
  //
  // now we can write the data
  unsigned long numbytes = wav->dat.size;
  unsigned long numsamps = numbytes*8 / au->wfx.wBitsPerSample;
  HRESULT hr = AVIStreamWrite(au->as,au->nsamp,numsamps,wav->dat.data,numbytes,0,NULL,NULL);
  if (buf!=0) delete[] buf;
  if (hr!=AVIERR_OK) {au->iserr=true; return hr;}
  au->nsamp+=numsamps; return S_OK;
}



unsigned int FormatAviMessage(HRESULT code, char *buf,unsigned int len)
{ const char *msg="unknown avi result code";
  switch (code)
  { case S_OK: msg="Success"; break;
    case AVIERR_BADFORMAT: msg="AVIERR_BADFORMAT: corrupt file or unrecognized format"; break;
    case AVIERR_MEMORY: msg="AVIERR_MEMORY: insufficient memory"; break;
    case AVIERR_FILEREAD: msg="AVIERR_FILEREAD: disk error while reading file"; break;
    case AVIERR_FILEOPEN: msg="AVIERR_FILEOPEN: disk error while opening file"; break;
    case REGDB_E_CLASSNOTREG: msg="REGDB_E_CLASSNOTREG: file type not recognised"; break;
    case AVIERR_READONLY: msg="AVIERR_READONLY: file is read-only"; break;
    case AVIERR_NOCOMPRESSOR: msg="AVIERR_NOCOMPRESSOR: a suitable compressor could not be found"; break;
    case AVIERR_UNSUPPORTED: msg="AVIERR_UNSUPPORTED: compression is not supported for this type of data"; break;
    case AVIERR_INTERNAL: msg="AVIERR_INTERNAL: internal error"; break;
    case AVIERR_BADFLAGS: msg="AVIERR_BADFLAGS"; break;
    case AVIERR_BADPARAM: msg="AVIERR_BADPARAM"; break;
    case AVIERR_BADSIZE: msg="AVIERR_BADSIZE"; break;
    case AVIERR_BADHANDLE: msg="AVIERR_BADHANDLE"; break;
    case AVIERR_FILEWRITE: msg="AVIERR_FILEWRITE: disk error while writing file"; break;
    case AVIERR_COMPRESSOR: msg="AVIERR_COMPRESSOR"; break;
    case AVIERR_NODATA: msg="AVIERR_READONLY"; break;
    case AVIERR_BUFFERTOOSMALL: msg="AVIERR_BUFFERTOOSMALL"; break;
    case AVIERR_CANTCOMPRESS: msg="AVIERR_CANTCOMPRESS"; break;
    case AVIERR_USERABORT: msg="AVIERR_USERABORT"; break;
    case AVIERR_ERROR: msg="AVIERR_ERROR"; break;
  }
  unsigned int mlen=(unsigned int)strlen(msg);
  if (buf==0 || len==0) return mlen;
  unsigned int n=mlen; if (n+1>len) n=len-1;
  strncpy(buf,msg,n); buf[n]=0;
  return mlen;
}

Keywords

The code on this page demonstrates the following functions and data structures:
WAV file format, RIFF file, Chunk, WAVE_FORMAT_PCM, IAVIFile, PAVIFile, WAVEFORMAT, WAVEFORMATEX, IAVIStream, PAVIStream, AVIFileInit, AVIFileOpen, AVIFileExit, AVIStreamRelease, AVIStreamClose, AVIFileRelease, DIBSECTION, GetObject, device independent bitmap, AVISTREAMINFO, streamtypeVIDEO, streamtypeAUDIO, AVIFileCreateStream, AVICOMPRESSOPTIONS, AVIMakeCompressedStream, AVIStreamSetFormat, mmioFOURCC, AVIStreamWrite.
 http://www.wischik.com/lu/programmer/avi_utils.html
http://istec.colostate.edu/me/facil/dynamics/avis.htm
http://redmine.yorba.org/projects/shotwell/wiki/AVISamples

MPEG Parser


MPEG Parser is the program for viewing of internal structure of MPEG-files. It can view fields of structures of MPEG file consists.
 MPEG Parser show such data about MPEG file: Resolution, Frame rate, Size, Aspect ratio, Bitrate ... 



Multimedia files such as video files Parsing Header information is a program that MPEG personal needs (AVI File Format, mp4 file analysis) after a long time, a program created by the upgraded learn if you think this would be helpful. ^ ^ AVI Size Sample of cursor to display the sample information does not. was created by a father, a leader (AviReader20021120.exe) AVI information If perhaps use if you find problems : DaeYoung, Im. production tools: Turbo C + + 2006 Version: 0.6.3 Support media formats: .3 gp,. mp4, avilimitations: 1) based on ISO14496-1 mp4 file. Unimplemented for some Tag mp4 file consisting of the Track .) 2) less than 10 less than 3) 4G ( avi file can not save more files (test failed) 4) Hex View - 256 ( automatically by considering the speed and Memory, etc. If you enter a value greater than 256KB) to convert 256K Usage: Drag & Drop or File Open file selection. Tag to evaluate the information from the TreeView : 0.6.3 Supported media format: .3 gp, mp4, avi update date: 2010.01.22 [modifications] 1) AVI file reading speed improvement 2) offfset greater than 0x7FFFFFFF if you had read the address 0x0 problem 3) AVI additional open-DML--------------------------------------------- ----------------------------------- Version: 0.6.2 Supported media format: .3 gp, mp4, avi update date: ------------------------------ 2008.12.04 [modifications] 1) Unicode problem appears to be broken-------------------------------------------------- Memory area cracked open Version: 0.6.1 Supported media format: .3 gp, mp4, avi update date: 2008.04.18 [modifications] ) .3gp/.mp4 times when Fixed 2) .3 gp / ES ID Descriptor one bug fix bug fixes. mp4 TreeView in lowercase letters were added to the list 3) AMR format was marked as "Unknown Format" 4) Apple to begin with String (0xA9 String) support. 5) iods box only for the old box info can exist concurrently in the box provided 6) upda cprt, titl, auth, dscp, pref, for gnre albm in box Sample Rate information provides 7) SBR file info "* 2". -------------------------------------------------- ---------------------------- Version: 0.5 Supported media format: .3 gp, mp4, avi update date: 2008.04.14 - -------------------------------------------------- ----------------------------- 


Ref
http://www.fileguru.com/MPEG-Parser/info
http://msdn.microsoft.com/en-us/library/windows/desktop/dd390972(v=vs.85).aspx
http://multimedia.cx/parse-ipmve.c
http://www.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_res&no=514
http://cbuilder.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_res&no=390

I B P frame

I-P-B frames Explained

A quick explaination of an MPEG "GOP", or, "Group Of Pictures",

GOP - Begins with an "I" frame, followed usually by a number of "P" and "B" frames (divx5 only uses B frames I believe)
- each GOP is independant: all frames needed for predictions are
contained within each GOP
- GOP's can be as small as a single I frame, or as large as desired, but usually no more than 15 frames in length.

- the longer the GOP, the more efficient, but less rubust the
coding

I frame - "Intra-coded" frames : average 7:1 reduction.
- like JPEG, every video frame is broken into blocks of 8x8
pixels of Y, R-Y, and B-Y (although, I am not sure how
this "1/4 pixels" divx5 has plays into all this)

- blocks are grouped into "macroblocks" of 16x16

- macroblocks are grouped horizontally into slices which
have similar average block levels.

- multiple slices form a frame, and these frames are the
resulting "I" frames.

P frame - P frames are predicted based on prior I or P frames plus
the addition of data for changed macroblocks.

- average about 20:1 reduction, or about half the size of I
frames - I don't think divx5 uses these, MPEG2 does though.
B frame - Bidirectionally predicted frames based on appearance and positions of past and future frames macroblocks.

- B frames require less data than P frames, averaging about
50:1 reduction.

- B frames require more decoder buffer memory because 2
frames are compared during the reconstruction process.

- B frames also require manipulation of the coding order:
frames moving from the coder to the decoder are NOT in
presentation sequence.
Basically, the the B frame will say something like "this frame is the same as the GOP's "I" frame except this one part, I will only contain the data needed to encode this one part, and combine it with the info from the I frame", in laymen's terms of course. This give DivX5 it's optimal reduction capability. This also means of course, that your P3500 media box in you living room might struggle with decoding a high rate D5 encode (not sure about that, but D5 is a more intense encoding/decoding process, but DVD's use I, P, and B frames, sooooooo...

Oh, BTW, in MPEG2 at least, a GOP order is always IPBBPBBPBBIPBBPBB etc etc. (pending on your GOP size), but it is always 1 I, 1 P, and 2 B's, then you can stack more groups of "PBB"'s in that one GOP if needed (usually up to 15 total frames.

Note: this has no role in 'fps'


One thing though:
DivX5 doesn't use only B-frames, it uses P-frames as well like its predecessor. Contrary to MPEG2, DivX5 uses a "PB" sequence chain instead of "PBB". The latter would result in better compression, but the way I understand it the avi format won't work correctly with more that one sequential B-frame.
Still, using "PB" instead of only P-frames results in a serious size decrease already, so it was definately worth it.
To be entirely accurate it uses "BP" grouping (i.e. frame n is B and frame n+1 is P) but it appears as "PB" because you cant decode a frame until the frames it predicted off are decoded.
And so p frames have to be decoded before the B frames between them. 1/4 Pixel accuracy is used in motion estimation to get the best fit for each macro-block. say you have a panning camera and each frame the picture hasnt moved an entire number of pixels accross the screen then 1/4 accuracy helps get the predicted macro-blocks in a much better possition. This isnt used in I-Frames because motion estimation isnt used in I-frames because it is basically a JPEG encoded frame using a different Quant value (typically 16).
I dont think MPEG-2 uses more than 1 B frame but i could be wrong.
The use of B-Frames does improve the compression/quality of the codec by a considerable amount but requires a lot more motion estimation (a large portion of hte encoding time) to be done hence hte much longer encoding times. B frames are typically 1/2 the size of P-Frames but require more encoding and decoding.




http://forum.digital-digest.com/f20/i-p-b-frames-explained-9785.html
http://en.wikipedia.org/wiki/Video_compression_picture_types

http://forum.doom9.org/archive/index.php/t-145126.html