Compile and use FFMPEG in Windows XP

Source: Internet
Author: User

Recently, we are developing streaming media. on the server side, live555 does not support MP4, Avi, and other video container formats. Therefore, we plan to use FFMPEG for extension. Use FFMPEG to parse the MP4 file and parse it into the basic video stream format supported by live555 (such as H. 264, etc.) and audio stream format, and then use live555 to process the basic audio and video streams, and then send them to the client for decoding and playback. This applies to the FFMPEG library, in order to facilitate debugging, the development environment is initially selected in windows, so FFMPEG needs to be compiled in windows. Then expand the live555 source code. The version used is ffmpeg0.8.5. this article describes how to compile FFMPEG and how to call it by vc6.0.

1. Build the compiling environment: 1. Operating System: Windows XP sp32, vc6.03, mingw + msys   To begin ...... The mingw + msys system has been installed. The installation path is c: \ mingw,
The msys directory is c: \ mingw \ msys \ 1.0.4, FFMPEG folder, go to the yasm official website (http://yasm.tortall.net/Download.html under a Windows fit the latest version, change the name to yasm.exe put in c: \ windows \ system32 (mainly to save the need to add environment variables) or put in C: \ mingw \ msys \ 1.0 \ bin folder. It is best to get one for NASM, and some libraries are often compiled and used. It doesn't matter if you don't put it, that is, the generated items do not support assembly, so the speed will be very affected.

Ii. compilation process

 

1. Edit the c: \ mingw \ msys \ 1.0 \ msys. BAT file and add a line at the beginning.

   Call "C: \ Program Files \ Microsoft Visual Studio \ vc98 \ bin \ vcvars32.bat"

The following path is the corresponding path of the VC installed on the machine. When the FFmpeg is compiled in this line, the corresponding lib of the DLL will be called in Windows to facilitate the VC call. (Viewed online)

2. Double-click c: \ mingw \ msys \ 1.0 \ msys. run bat and enter the FFMPEG source code Directory D: \ ffmpeg0.8.5. The command in this window is similar to that in shell. It is different from that in cmd. You need to change the right slash to the left slash, and then drive letter D: also change to/d, enter CD/D/FFMPEG/ffmpeg0.8.5, and enter the FFMPEG main directory.

3. start compiling FFMPEG and continue the input:

 "./Configure -- enable-shared -- disable -- Static -- enable-memalign-hack" configuration

4. After waiting for a while, enter make (ignore warning)

5. After waiting for a long time, enter make install

 

   At this point, the compilation process ends. The required results are stored in the C: \ mingw \ msys \ 1.0 \ localdirectory, with the corresponding header file (include中), dllin the liblibrary file (bin中), and ffmpeg.exe and other running programs.

   At the time of Self-compilation, ffmpeg1.0 was compiled first. However, due to version issues, the extended code always reports the error that the memory cannot be read. It is suspected that the problem is caused by the FFMPEG version, so try it down to 0.8. However, no matter which version is compiled later in 0.8, after configure is configured, make cannot find the corresponding file and make cannot be used. This problem has plagued you for a long time, I once wanted to give up and operate on Linux. Then I found some clues on the Internet. Simply uninstall mingw, reinstall it, and configure make. The specific reason is not further explored.

 Note: After the make command, the generated DLL and Lib are already in the FFMPEG directory. However, we recommend that you execute the make install command.
Because it will sort out the required header files for you (too considerate, I think there are too many copies, it is too troublesome to choose, and it is not correct ), then the DLL file size will be reduced (Automatic File slimming ).

 Finally, use vc6.0 to call the generated library. In the include path of vc6.0, add the includ path in the local generated above. Add the bin path in local to the link path, and then add the generated static library avformat. Lib avutil. Lib avcodec. lib to the link created by yourself.

In this way, you can call the FFMPEG library.

 

Appendix: problems encountered during compilation:

  

1. Cannot open include file: 'inttypes. H': no such file or director Solution

1. Find FFMPEG \ common. h In the include directory.
2. Add the following code after "# define common_h", delete "# include <inttypes. h>", and save:

# If defined (win32 )&&! Defined (_ mingw32 __)&&! Defined (_ cygwin __)
#Define config_win32
# Endif
# If defined (win32 )&&! Defined (_ mingw32 __)&&! Defined (_ cygwin __)&&! Defined (emulate_inttypes)
#Define emulate_inttypes
# Endif
# Ifndef emulate_inttypes
#Include <inttypes. h>
# Else
 Typedef signed Char Int8_t;
 Typedef signed short int16_t;
 Typedef signed intInt32_t;
 Typedef unsigned char Uint8_t;
 Typedef unsigned short uint16_t;
 Typedef unsigned intUint32_t;
#Ifdef config_win32
    Typedef signed _ int64Int64_t;
    Typedef unsigned _ int64 uint64_t;
#Else
    Typedef signed longInt64_t;
    Typedef unsigned long uint64_t;
#Endif
# Endif

 

2, error c3861: 'uint64 _ C': identifier not found
Find FFMPEG \ common. h In the include directory.
Add a macro definition to the function header:

// Customize your own definition to handle uint64_c undefined errors

# Ifndef int64_c

# Define int64_c (C) (C # l)

# Define uint64_c (C) (C # UL)

# Endif

 

3. Handle macro definition format errors... Change to n

# If av_gcc_version_at_least (4, 3)

   # Define av_alloc_size (n) _ attribute _ (alloc_size (_ va_args __)))

# Else

   # Define av_alloc_size (N)

# Endif

 

4. Cannot open include file: 'stdint. H': no such file or directory appears.

Just note the # include <stdint. h>

 

5. method for processing template errors. Check macro definitions before extern.

# UNDEF _ cplusplus

Extern "C "{

# Include "libavutil/avutil. H"

# Include "libavformat/avformat. H"

}

# DEFINE _ cplusplus

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.